Zigbee2MQTT > Aqara Door Sensor > MQTT Cover State

I’ve had a Sonoff SV with Tasmota running on my front gate motor forever and a day but recently after changing the physical gate the wired connection was no longer practical and so I got an Aqara Door/Window sensor to detect the open/closed state.

I have everything working perfectly, it reports the status correctly, the default binary sensor works just fine and the MQTT topic is working perfectly too…but for some reason which is probably some weird syntax I’m not aware of the MQTT Cover simply doesn’t read the state and keeps saying it’s Unknown.

The only difference I find between this and the Sonoff SV setup is that the MQTT message doesn’t have double quotes around the value.

Mosquito is working perfectly and so is the topic.

But when using this MQTT Cover I simply can’t make it work no matter how I change the state_topic.

  - name: "Gate"
    command_topic: "cmnd/tasmota_0299AC/POWER"
    state_topic: "zigbee2mqtt/Front Gate"
    availability_topic: "tele/tasmota_0299AC/LWT"
    payload_open: "ON"
    payload_close: "ON"
    payload_stop: "ON"
    state_open: "false"
    state_closed: "true"
    payload_available: "Online"
    payload_not_available: "Offline"
    value_template: "{{ value.contact  }}"

The button still works and the gate opens and closes, it’s just the status that is broken.

Left is the broken MQTT Cover, far right is the working perfectly binary sensor that I can’t use in the MQTT Cover otherwise I would have done that and just skipped the whole problem.

So by some magic from who knows where between Home Assistant and Mosquito Broker it magically capitalises the mqtt topic data and turns true/false into True/False.

I only discovered this after configuring an MQTT Sensor with the same state topic to output the raw value in Developer Tools.

So correct code is as below…

  - name: "Gate"
    command_topic: "cmnd/tasmota_0299AC/POWER"
    state_topic: "zigbee2mqtt/Front Gate"
    value_template: '{{ value_json.contact  }}'
    availability_topic: "tele/tasmota_0299AC/LWT"
    payload_open: "ON"
    payload_close: "ON"
    payload_stop: "ON"
    state_open: "False"
    state_closed: "True"
    payload_available: "Online"
    payload_not_available: "Offline"