I’m experimenting with a magnet sensor (reed switch) on a ESP32 that I use with MQTT.
I’m going to put the sensor hidden in my window and pull the wires to the attic so it’s not visible.
I have the ESP32 configured correctly so it published a message for open/closed to the MQTT topic so that part is working.
However when I add the binary sensor to HA it won’t change status and only show that it’s closed.
However even if house/windows/publish is set to true it never changes in HA.
I’m using MQTT Explorer to se the messages and I can se that the ESP32 is sending true/false messages to the topic.
Is there something I’m missing?
I have around 20 switches that are communicating over MQTT so HA has a connection to the broker.
All of the evidence you’ve provided suggests this should work:
You have 20 existing MQTT Switches and all are working therefore Home Assistant has a working connection to the MQTT broker.
MQTT Explorer confirms the topic house/windows/publish is receiving true and false payloads.
The binary_sensor is configured to recognize true as being the payload for on (and false for off).
The binary_sensor entity appears in Home Assistant so the configuration is valid.
Each link in the chain has been confirmed to be operational: [Device] <---> [MQTT broker] <---> [Home Assistant Binary_Sensor]
Nevertheless, the binary_sensor fails to change state and always remains off. It suggests the entity is not, in fact, receiving payloads via its subscribed topic or the payload differs from what it expects to receive.
None of the MQTT topics you posted here contain a leading slash /. Nevertheless, something had to wrong with one of the four pieces of evidence you provided … and it turned out to be the MQTT topic.
It would helpful to others if you marked my post (above) as the Solution in order to make it easier to find for other people who may encounter the same problem. Thank you.
You don’t need to be sorry, people make mistakes. However, you have marked the wrong post as the Solution.
The source of the problem was that the sensor was not receiving payloads via its subscribed topic. This was identified here.
It was identified even though the evidence you presented was misleading. You claimed to be using an MQTT topic without a leading slash when, in fact, it did have one.
The analysis I presented indicated each link in the chain is operational, yet the binary_sensor fails to change state. Therefore one of the links remains broken and some of the details you presented had to be incorrect. I surmised it was either the topic or the payload. It proved to be the topic.