Binary sensor not being updated from MQTT

I am trying to setup a boolean sensor to track the state of a google calendar event. In my configuration.yaml I have defined the following binary sensor:

mqtt:                                                                              
  binary_sensor:                                            
    name: "PelletStoveCalendar"                                
    state_topic: "/home/Living Room/PelletStoveCalendar"                           

If I go to the MQTT integration and subscribe to the topic “/home/Living Room/PelletStoveCalendar” I can see the value change between “on” and “off” as I expect it to:

Message 1 received on /home/Living Room/PelletStoveCalendar at 10:29 AM:

off

QoS: 0 - Retain: false
Message 0 received on /home/Living Room/PelletStoveCalendar at 10:29 AM:

on

QoS: 0 - Retain: true

In the developer tools states table the value is always unknown:


PelletStoveCalendar               unknown 	friendly_name: PelletStoveCalendar

I have other mqtt sensors that are not binary that are working correctly so I am not sure why this one is not,.

I am running HA 2022.11.1 in a Docker container.

Any suggestions would be greatly appreciated.

mqtt:                                                                              
  binary_sensor:                                            
    name: "PelletStoveCalendar"                                
    state_topic: "/home/Living Room/PelletStoveCalendar"
    value_template: "{{ value | upper }}"

By default, MQTT Binary Sensor expects to receive uppercase ON and OFF.

Thank you for the help. I changed the code that publishes the MQTT message to be upper case and it is working now. I originally had payload_off: off and payload_on: on but that did not seem to work, using uppercase did the trick.

1 Like

You’re welcome!

Please consider marking my post above with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic has been resolved. This helps users find answers to similar questions.

For more information about the Solution tag, refer to guideline 21 in the FAQ.