Open gandalfk7 opened 2 years ago
Hard to help without seeing the incoming JSON string. In my setup I have something similar:
"apply": "return JSON.parse(message)[\"DS18B20-3\"].Temperature;"
I'm not JSON savvy and find the syntax very hit or miss, but try:
"apply": "return JSON.parse(message)['0x4EF9'].Humidity;"
or "apply": "return JSON.parse(message)[\"0x4EF9\"].Humidity;"
I've noticed that I solved my issue but never updated this thread, without the "apply" it works well, like:
{
"accessory": "mqttthing",
"type": "humiditySensor",
"name": "Zigbee_Sonoff_Temp02 - HUM",
"url": "mqtt://192.168.10.10:1883",
"username": "user",
"password": "password",
"topics": {
"getCurrentTemperature": "tele/tasmota_ABCDEF/ZB_Sonoff_Temp02/SENSOR$.ZbReceived[*].Temperature"
}
}
},
right now I am trying to make it work in the "apply" block but searching for the problem on google led me to this issue, so I don't keep my hopes low :D
Hi!
This is a request for help on the configuration, I don't think it's a bug, I am not very keen on Json..
I am very happily using homebridge with many devices over MQTT and wanted to refine my config.
I have some Zigbee devices, mainly thermometers, seen via MQTT, like:
Since my topic already defines the device, I wanted to tune the json parsing to avoid specifing the device ID (this is beacause I have friendly names on Tasmota ZBBridge and sometimes the IDs change when reassociating a device).
So I wanted ot use a wildcard, from this:
"apply": "return JSON.parse(message).ZbReceived['0x4EF9'].Humidity;"
to this:"apply": "return JSON.parse(message).ZbReceived[].Humidity;"
but it does not work.
I've already read the json path syntax and tried with an online parser which confirms that ZbReceived[].Humidity should work (I am not very keen on json).
Unfortunately when using [] I receive an error:
same when I try to use [*]:
I am a little lost, could you help me please?
Thank you very much and happy holidays!!