I have a little battery-powered 6 button scene controller (Zigbee), hooked up to Sonoff Zigbee hub with Tasmota installed.
When I press the first button, and pipe the message through JSON node, I get this:
The unique thing about this button is: 0006!00: ""
When I press other buttons, they give the following:
Button 2: 0006!01: ""
Button 3: 0008!02: "015507000000"
Button 4: 0008!02: "005507000000"
Button 5: 0300!4C: "0145000700000000000000"
Button 6: 0300!4C: "0345000700000000000000"
I don't care about the meaning of these buttons, I just want to be able to do different things in a function node.
This doesn't seem to work, can anyone help me?
(Also pls suggest a better way, the nested IFs are a bit lame!)
if (msg.topic == "tasmotas/zigbee-hub/B67D/tele/SENSOR") {
if (typeof msg.payload.ZbReceived != undefined) {
if (typeof msg.payload.ZbReceived.SceneController1 != undefined) {
if (typeof msg.payload.ZbReceived.SceneController1["0006!00"] != undefined) {
msg.payload = 0
}
if (typeof msg.payload.ZbReceived.SceneController1["0006!01"] != undefined) {
msg.payload = 1
}
if (typeof msg.payload.ZbReceived.SceneController1["0006!03"] != undefined) {
if (msg.payload.ZbReceived.SceneController1["0008!02"] == "015507000000") {
msg.payload = 2
}
if (msg.payload.ZbReceived.SceneController1["0008!02"] == "005507000000") {
msg.payload = 3
}
}
if (typeof msg.payload.ZbReceived.SceneController1["0300!4C"] != undefined) {
if (msg.payload.ZbReceived.SceneController1["0300!4C"] == "0145000700000000000000") {
msg.payload = 4
}
if (msg.payload.ZbReceived.SceneController1["0300!4C"] == "0345000700000000000000") {
msg.payload = 5
}
}
msg.topic = "home/light/gf_pergola/scene"
return msg
}
}
}