Sensor that only sends events (not really a state)

Hello. I have an MQTT sensor which doesn’t send state on the topic as payload - it only sends the topic with null payload, which means that an event happened.

What’s the best way to work with such sensor in HA? Is there one? I can’t use a Binary sensor for this really.

Also, the sensor sleeps for 5 minutes after sending the event, so I could assume that the sensor is in the ON state for 5 minutes after sending the event and then switch it to OFF with a timer after the last event, if no other message was received on that topic in the meantime. Could you help me with doing this? I’m not experienced with HA in this field using the internal mechanisms.

I could write a custom component for Binary sensor for this, but I’d like to ask if there is an integrated solution first.

Thank you

You can write an automation that triggers on an incoming MQTT message. The automation could then fill in the state, or do whatever is necessary.

I think you have to declare some sensor that subscribes to the MQTT topic in order to get the message on the event bus to start with, but you should check that (its a while since I did it).

1 Like