Hello, thank you for receiving my query. I have a signal hub that receives measurements from many sensors (temperature, humidity, signal and battery), this hub sends the data to the Broker's MQTT queue (all data is in a single JSON). I try to filter each sensor by mac but I don't know the language... as an example I get messy information using: $[1].temperature, $[1].humidity, $[1].rssi and $[1].battery ( but the sensor that displays it is unknown). The JSON in question is as follows: (I want to obtain the values ??of the 4 measurements for the sensors "AC233FA2110B" and "AC233FA2111A"...)

[{"timestamp":"2022-10-14T13:21:19Z","type":"S1","mac":"AC233FA2110B","bleName":"","rssi":-66,"battery ":100,"temperature":-6.63,"humidity":75.17},{"timestamp":"2022-10-14T13:21:20Z","type":"S1","mac":"AC233FA2111A" ,"bleName":"","rssi":-78,"battery":100,"temperature":8.08,"humidity":59.96},{"timestamp":"2022-10-14T13:21:22Z" ,"type":"S1","mac":"AC233FA2111A","bleName":"","rssi":-81,"battery":100,"temperature":8.08,"humidity":59.96}, {"timestamp":"2022-10-14T13:21:22Z","type":"S1","mac":"AC233FA2110B","bleName":"","rssi":-65,"battery" :100,"temperature":-6.63,"humidity":75.17},{"timestamp":"2022-10-14T13:21:23Z","type":"S1","mac":"AC233FA2111A", "bleName":"","rssi":-79,"battery":100,"temperature":8.04,"humidity":60.41}]

I have not been able to filter by devices independently. I hope you can help me, I am grateful.


Article Comments

Hi rorropon,

I'm afraid it is not possible to filter them according to the mac. I would recommend to create for each mac a new sensor. The mac information can be displayed as sensors message. For this you need to enter the path in option Sensor Message JSON Path under MQTT specific. This will allow you to display the mac and for all other values you can enter the paths to the channel fields. To find the right paths I would recommend to use JSONPathfinder.


Kind regards

Felix Wiesneth - Team Tech Support


Oct, 2022 - Permalink

Hi Felix,

Sensor name: AC233FA2110B
Sensor Message JSONPath: $[*].mac
Channel #1 JSONPath: $[*].temperature

Result:
"The received value is an array instead of a single value. Array size is: 3 Channel 1: The received value is an array instead of a single value. Array size is: 2"

It is important to mention that within the JSON the results are out of order, that is, the arrival of the macs is random. Example, at time 0 the mac=AC233FA2110B comes in the first position of the JSON and at time 1 it can come in the second position of the JSON. For the above I do not use $[1].mac


Oct, 2022 - Permalink