Binary_sensor and boolean payload_off value - not working

Hello,

I’ve got a problem with binary sensor configuration. I’ve got Aqara door sensor working and the payload is:

payload: '{"battery":100,"voltage":3035,"linkquality":76,"contact":false}'
payload: '{"battery":100,"voltage":3035,"linkquality":84,"contact":true}'

so according to the documentation something like this should work (binary_sensor):

- platform: mqtt
  state_topic: "zigbee2mqtt/0x00158d000274f749"
  name: "Hall entrance"
  device_class: door
  payload_on: true
  payload_off: false
  value_template: "{{ value_json.contact }}"

and it works fine for payload_on action - if I open the door I can see door opened on the home assistant homepage. But when I close the door nothing happens on frontend - sensor is still in “on” mode.

I’ve tried also with quotes:

  payload_on: "true"
  payload_off: "false"

but then it was not working at all and in the logs I could find:

WARNING (MainThread) [homeassistant.components.binary_sensor.mqtt] No matching payload found for entity: Hall entrance with state_topic: zigbee2mqtt/0x00158d000274f749

What am I doing wrong? :slight_smile:

I’m not sure what’s wrong, but it sounds suspiciously like the problem I just posted about here: https://community.home-assistant.io/t/problem-with-motion-sensors-in-the-adt-pulse-mqtt-add-on/93265

Thank you, I’ll check that topic later today.

One more interesting thing regarding my problem - I’ve got automation set on that door sensor: trigger Telegram notification when door goes from “off” to “on”… and it works fine. So on frontend I can see all the time that the door is Open (which is wrong) but “in reality” it works fine and triggers automation correctly.

Ok the answer is simple, that’s my configuration mistake. The sensor has payload_on when false, and payload_off when true (opposite to what I’ve configured in the first post…).

So the correct configuration for that sensor is:

- platform: mqtt
  state_topic: "zigbee2mqtt/0x00158d000274f749"
  name: "Hall entrance"
  device_class: door
  payload_on: false
  payload_off: true
  value_template: "{{ value_json.contact }}"
1 Like