User Tools

Site Tools


supported_hardware:mqtt

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
supported_hardware:mqtt [2023/03/14 17:25] – [Installing an MQTT Broker:] added config file specifics James Sentmansupported_hardware:mqtt [2023/03/17 13:35] (current) – added info on new parse json path capabilities James Sentman
Line 58: Line 58:
  
 ----- -----
 +
 +====Parsing JSON Payloads:====
 +
 +Many devices send json packets instead of simple values. There are now a couple of ways to parse them. In XTension 9.5.2 I’ve added a section to all the non-special Unit configurations for simple parsing of JSON payloads. 
 +
 +{{ :supported_hardware:mqtt_json_payload_settings.png?500 |}}
 +
 +After entering the Topic Path, check the Parse Payload As JSON Checkbox and enter the path through the JSON to the value you would like to get to. The path through the JSON is also delineated by the same backslash character as the topic path. In the case of JSON dictionaries the section of the path must be the key into the dictionary to move to. In the case of a JSON Array it must be an integer value for the element in the array you wish to navigate to. Once the end of the JSON Path is reached whatever value was there is then passed on to the regular value parsing as handled by the specific Unit type. So Numerical values are converted to numbers, enumerated values will look into the result for the enumerations and the Description Unit will place the result in the Description field. 
 +
 +This is available as an option for all non-special device units.
 +
 +If you have several values to get from a single JSON packet you can create as many Units with the same Topic Path as you wish but with different JSON paths to get the specific data you need.
 +
 +If this is not enough to parse a more complicated JSON packet please see the [[dictionary:more:parsejson|Parse JSON Verb]] for doing the decoding in your ON script.
 +
 +For more information and examples please see the [[supported_hardware:mqtt:jsonpath|JSON Path Information Page]]
 +
 +-----
 +
  
 ====MQTT Unit Types:==== ====MQTT Unit Types:====
supported_hardware/mqtt.1678814702.txt.gz · Last modified: 2023/03/14 17:25 by James Sentman