How to set up an MQTT binary door sensor?

I’ve been trying all day to get this to work, but inexplicably it does not. Can anyone suggest what the problem might be? Here’s an example of the MQTT topic:

mosquitto_sub -h localhost -t MCThings/00010868/Data
{"time":"1493829297829","Door":true}
{"time":"1493829301172","Door":false}

And here is the config that I thought should work with it:

  - platform: mqtt
    state_topic: "MCThings/00010868/Data"
    name: "Office Door"
    qos: 0
    payload_on: "false"
    payload_off: "true"
    device_class: opening
    value_template: '{{ value_json.Door }}'

Instead I get NOTHING. The only thing the logs contain is the initial instantiation of the sensor:

17-05-04 06:46:00 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: old_state=None, new_state=<state binary_sensor.office_door=off; friendly_name=Office Door, device_class=opening @ 2017-05-04T06:46:00.762356+10:00>, entity_id=binary_sensor.office_door>

Any help would be gratefully appreciated.

Try removing the quotes around true and false.

1 Like

You are my new hero. Thank you!

Hi I had the same probleme, I’m french and I wouldlike to put the state topic open/closed in french (ouverte/fermé) how can I do it ?

Thanks

can you share your code thanks