How to define binary sensor for MQTT Zigbee Doorbell

I’m trying to configure a binary sensor for a Sage Zigbee Doorbell sensor. The sensor is paired with a Sonoff Zigbee Tasmota Bridge, using zigbee2tasmota, and generates this MQTT payload on the tele/zigbee-bridge/SENSOR topic when I press the doorbell:

{
    "ZbReceived": {
        "0x1D4E": {
            "Device": "0x1D4E",
            "Name": "sage-doorbell-sensor",
            "0006!01": "",
            "Power": 1,
            "Endpoint": 18,
            "LinkQuality": 50
        }
    }
}

I have my sensor defined as follows:

  - platform: mqtt
    name: "Sage Doorbell Sensor"
    state_topic: "tele/zigbee-bridge/SENSOR"
    value_template: '{{ value_json.ZbReceived.0x1D4E.Power}}'
    payload_on: '1'
    qos: 1

…but the sensor does not get set to the ‘on’ state when I press the doorbell.
Could anyone advise on what needs correcting in my sensor definition?

This does not work :

This works :

so try :

  - platform: mqtt
    name: "Sage Doorbell Sensor"
    state_topic: "tele/zigbee-bridge/SENSOR"
    value_template: '{{ value_json.ZbReceived.0x1D4E.Power}}'
    payload_on: 1
    qos: 1
    off_delay: 20
    unique_id: a90e3bd8-342a-42c3-b367-14f0bdda59d6

Thanks. I’ve pasted in your code but the sensor is still not being turned on when the doorbell is pressed.
As far as I can see the only differences between your code and mine were:

  • the value for payload_on was not enclosed in quotes
  • off_delay was specified
  • unique_id was specified.

Was that what you intended?

Sorry, forgot to change :

  - platform: mqtt
    name: "Sage Doorbell Sensor"
    state_topic: "tele/zigbee-bridge/SENSOR"
    value_template: '{{ value_json.ZbReceived['0x1D4E'].Power}}'
    payload_on: 1
    qos: 1
    off_delay: 20
    unique_id: a90e3bd8-342a-42c3-b367-14f0bdda59d6

(See second screenshot)

1 Like

OK this is what I’ve tried:

  - platform: mqtt
    name: "Sage Doorbell Sensor"
    state_topic: "tele/zigbee-bridge/SENSOR"
    value_template: '{{ value_json.ZbReceived[0x1D4E].Power}}'
    payload_on: 1
    qos: 1
    off_delay: 20
    unique_id: a90e3bd8-342a-42c3-b367-14f0bdda59d6

Still no luck (I can see the MQTT messages coming in on the Tasmota console, but the sensor is not being set).
???

Edit: I was wondering: should I be specifying a device_type?

Sorry I just spotted that the device id needed to be in quotes (or double-quotes in configuration.yaml) - it’s now working fine.
Many thanks for the guidance!