Hello,
I wanted to control a light when the other one in the same room is not connected to my home assistant via zigbee2mqtt (because a physical switch diconnected the bulb from electricity).
It is a simple case of setting on a night light when the main one is off via physical switch (main one is a zigbee bulb but switch is not smart).
In other words, I wanted to detect that the state of my light is "disconnected" instead of classical on/off.
Any ideas on how I can detect this "disconnected" state ? (I'm fine with everything else, it is just this state that is missing in my flow)
Thank you !!
MQTT has the concept of birth and "Last Will & Testament" messages. A lot of us use these to provide an indication as to whether something is off- or on-line.
They do depend on the client supporting them though and require a "heartbeat" type of message - a message that is sent on a known period.
If the device doesn't support that directly, you can simulate it from Node-RED by sending a periodic message to the device that elicits a reply. If the reply isn't received in the right timescale, you can mark the device offline.
Some examples:
![image](https://global.discourse-cdn.com/business6/uploads/nodered/original/3X/4/7/4788c9138f532cba243138676ee01843752057bb.png)
![image](https://global.discourse-cdn.com/business6/uploads/nodered/original/3X/8/3/832c6e006d23bd6b161fd6d66758e2b1c09626d2.png)
![image](https://global.discourse-cdn.com/business6/uploads/nodered/original/3X/5/8/58c1a66895b8afc1392acdfeb87ac52908a9c653.png)
Where devices don't use MQTT natively, I sometimes use a simple timestamp instead, particularly where the device doesn't have a heartbeat and maybe spends most of its time offline (battery operated). The timestamp shows the last time I saw anything from the device:
![image](https://global.discourse-cdn.com/business6/uploads/nodered/original/3X/b/b/bb4d59154837079649ca7b45575e647e76920d48.png)
(Note the amusing number of unknown 433MHz devices my RFXtrx433E has detected in our neighberhood over the last 3 months! Mostly wireless smoke detectors.)
1 Like
Its not too bad until one clashes, the ghosts have switched the fan on again ![:crazy_face: :crazy_face:](https://emoji.discourse-cdn.com/twitter/crazy_face.png?v=12)
Haha, used to have that problem with a previous wireless bell - clashed with something in the house opposite ![:frowning: :frowning:](https://emoji.discourse-cdn.com/twitter/frowning.png?v=12)
Probably will be running down the 433MHz stuff over time though. Zigbee is so much better all round. Except for the DIY sensors - Zigbee is still too complex there for now. I'll stick with Wi-Fi for those.
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.