Hi,
I have a flow for a Settopbox which gets the status of the box in a JSON string. This is Injected every second (at the moment I have turned repeat off).
The goal is to SYNC the remotes ON/OFF button (which is a Toggle button) with an ON/OFF switch in Domoticz (domotics software)
One of the attributes of the JSON string is the msg.payload.setopboxState
This has 2 Values: ONLINE_RUNNING (box is ON) and ONLINE_STANDBY (box is Off)
I have created 2 function nodes to publish an MQTT message to topic: domoticz/in
// Turn ON domoticz device when payload is ONLINE_RUNNING
if (msg.payload.setopboxState == 'ONLINE_RUNNING') {
msg.payload = {
"idx": 385,
"nvalue": 1,
}
return msg;
}
and
// Turn OFF domoticz device when payload is ONLINE_RUNNING
if (msg.payload.setopboxState == 'ONLINE_STANDBY') {
msg.payload = {
"idx": 385,
"nvalue": 0,
}
return msg;
}
The problem is the domoticz/in topic also receives every second the msg.payload.
How do I publish only one msg.payload: when the msg.payload.setopboxState value changes?