• Recent
    • Tags
    • Popular
    • Register
    • Login

    Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.

    Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website Mango 5 Documentation Website

    MQTT datapoint parsing help.

    User help
    3
    6
    1.2k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • R
      rob987
      last edited by

      Hi,
      I need some pointers on getting MQTT data into mango.
      I have configured the MQTT Broker OK, and am receiving data,
      but I cannot work out how to parse it.

      INFO  2021-01-11T17:13:09,026 (com.serotonin.m2m2.rt.RuntimeManagerImpl.stopDataSourceShutdown:447) - Data source 'MQTT_NAS' stopped 
      INFO  2021-01-11T17:13:11,949 (com.serotonin.m2m2.rt.RuntimeManagerImpl.initializeDataSourceStartup:408) - Data source MQTT_NAS took 2ms to start 
      WARN  2021-01-11T17:16:46,079 (com.infiniteautomation.m2m2.mqtt.client.MqttClientDataSourceRT.messageArrived:355) - Unknown topic "tele/tasmota_E14FF4/STATE" payload: "{"Time":"2021-01-11T17:16:45","Uptime":"2T23:52:24","UptimeSec":258744,"Heap":26,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":3,"Wifi":{"AP":1,"SSId":"NixNet","BSSId":"E4:8D:8C:3F:D7:A1","Channel":1,"RSSI":80,"Signal":-60,"LinkCount":1,"Downtime":"0T00:00:03"}}" 
      ERROR 2021-01-11T17:16:46,121 (com.infiniteautomation.m2m2.mqtt.client.MqttClientDataSourceRT.messageArrived:375) - Error during read topic: "tele/tasmota_E14FF4/SENSOR" datapoint: "MQTT_NAS - Mealies_Temperature" payload: "{"Time":"2021-01-11T17:16:45","DS18B20":{"Id":"01192718DE3D","Temperature":25.6},"TempUnit":"C"}" exception: "Text '2021-01-11T17:16:45' could not be parsed at index 0" 
      
      

      I have a json timestamp pattern of "yyyy'-'MM'-'dd'T'HH':'mm':'ss"
      Also, the temperature value is NaN :-(

      Thanks

      R 1 Reply Last reply Reply Quote 0
      • R
        rob987 @rob987
        last edited by

        I have been trying different patters, and have a new error which is confusing me.
        The Date could not be parsed, then the message ends with
        :ISO resolved to 2021-01-12T16:46:47 of type java.time.format.Parsed"

        ERROR 2021-01-12T16:46:47,246 (com.infiniteautomation.m2m2.mqtt.client.MqttClientDataSourceRT.messageArrived:375) - Error during read topic: "tele/tasmota_E14FF4/SENSOR" datapoint: "MQTT_NAS - Mealies_Temperature" payload: "{"Time":"2021-01-12T16:46:47","DS18B20":{"Id":"01192718DE3D","Temperature":26.6},"TempUnit":"C"}" exception: "Text '2021-01-12T16:46:47' could not be parsed: Unable to obtain Instant from TemporalAccessor: {},ISO resolved to 2021-01-12T16:46:47 of type java.time.format.Parsed" 
        

        MQTT_Point.png

        1 Reply Last reply Reply Quote 0
        • CraigWebC
          CraigWeb
          last edited by

          I think it might be due to the ' chars in your pattern try this one and see if it works:

          yyyy-MM-dd'T'HH:mm:ss.SSS
          
          1 Reply Last reply Reply Quote 0
          • R
            rob987
            last edited by

            Hi,
            Tried the date format yyyy-MM-dd'T'HH:mm:ss.SSS and the error changed to

            Error during read topic: "tele/tasmota_E14FF4/SENSOR" datapoint: "MQTT_NAS - Mealies_Temperature" payload: "{"Time":"2021-01-13T13:26:48","DS18B20":{"Id":"01192718DE3D","Temperature":28.1},"TempUnit":"C"}" exception: "Text '2021-01-13T13:26:48' could not be parsed at index 19"
            

            I have the Sensor temperature, and WiFi signal strength working now. ( Just using JSON, and not JSON + Timestamp, as I cannot find a parsing string that works )

            Mango is subscribed to two topics, STATE and SENSOR.

            The steps I took were

            1. Connect to MQTT Broker and get a copy of the raw data ( Also checks connection from Mango PC )
            robert@mango:~$ mosquitto_sub  -h 192.168.220.208 -p 1883 -u robert -P XXXXX -t tele/#
            
            Client mosqsub/22329-mango received PUBLISH (d0, q0, r0, m0, 'tele/tasmota_E14FF4/STATE', ... (274 bytes))
            tele/tasmota_E14FF4/STATE {"Time":"2021-01-13T10:46:48","Uptime":"4T17:22:27","UptimeSec":408147,"Heap":25,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":3,"Wifi":{"AP":1,"SSId":"NixNet","BSSId":"E4:8D:8C:3F:D7:A1","Channel":1,"RSSI":92,"Signal":-54,"LinkCount":1,"Downtime":"0T00:00:03"}}
            Client mosqsub/22329-mango received PUBLISH (d0, q0, r0, m0, 'tele/tasmota_E14FF4/SENSOR', ... (96 bytes))
            tele/tasmota_E14FF4/SENSOR {"Time":"2021-01-13T10:46:48","DS18B20":{"Id":"01192718DE3D","Temperature":26.6},"TempUnit":"C"}
            

            Check the Subscribed Data at https://jsonformatter.org/json-parser You can paste the received data string in, and get a readable JSON document.

            tele/tasmota_E14FF4/STATE

            object{9}
            	Time : 2021-01-13T10:46:48
            	Uptime : 4T17:22:27
            	UptimeSec : 408147
            	Heap : 25
            	SleepMode : Dynamic
            	Sleep : 50
            	LoadAvg : 19
            	MqttCount : 3
            	Wifi {8}
            		AP : 1
            		SSId : NixNet
            		BSSId : E4:8D:8C:3F:D7:A1
            		Channel : 1
            		RSSI : 92
            		Signal : -54
            		LinkCount : 1
            		Downtime : 0T00:00:03
            

            And
            tele/tasmota_E14FF4/SENSOR

            object {3}
                Time : 2021-01-13T10:46:48
                DS18B20 {2}
                    Id : 01192718DE3D
                    Temperature : 26.6
                TempUnit : C
            

            Here are the working MQTT Datapoint setups
            Wifi_Signal.png

            And Temperature
            Temperature_MQTT.png

            And The correct values shown on the datasource page
            DataSource_MQTT.png

            If anyone has some ideas on how to parse the Time (JSON + Timestamp) let me know

            Thanks

            T 2 Replies Last reply Reply Quote 1
            • T
              tungthanh500 @rob987
              last edited by

              @rob987 This is the most detail instruction regarding MQTT for new user. I highly recommend using his instruction. New user should check ma.log to check if data source is correct setup to read data from MQTT broker before working on data point.

              1 Reply Last reply Reply Quote 0
              • T
                tungthanh500 @rob987
                last edited by

                @rob987 Hi, have you find solution for you JSON timestamp?

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post