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)
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:
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:
(Note the amusing number of unknown 433MHz devices my RFXtrx433E has detected in our neighberhood over the last 3 months! Mostly wireless smoke detectors.)
Haha, used to have that problem with a previous wireless bell - clashed with something in the house opposite
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.