Inconsistent MQTT payload

I’m struggling with my doorbell (AD110) raising inconsistent MQTT payloads in HA, and not sure where exactly the problem is or how to address.

I’m using an addon (amcrest2mqtt) to raise the events, and in mqtt explorer they seem fine, but within HA they can vary between a nice on off or the byte equivalent b'on' b'off'
Which is driving my head in, because sometimes the doorbell will trigger, and sometimes it won’t (which is kind of an important thing to always work!)

Below is an example of what I’m seeing in the MQTT debug info within HA:

Received 1:15:03 PM

    QoS: 0
    Payload: b'on'

Received 1:15:14 PM

    QoS: 0
    Payload: b'off'

Received 1:17:19 PM

    QoS: 0
    Payload: on

Received 1:17:31 PM

    QoS: 0
    Payload: off

Received 1:20:22 PM

    QoS: 0
    Payload: b'on'

Received 1:20:33 PM

    QoS: 0
    Payload: b'off'


Apologies if this question has been addressed before - but I couldn’t find anything to address it.
Appreciate any help/guidance here - thanks!

Hi Snozzle,

Whatever comes back, run it thru a template sensor and ‘fix’ it that way.

Otherwise do an issue with the Add-on author and see if they can fix it there. You expect it to be consistent.

Thanks - Yeah had considered this approach but thought there might have been an easier way, or if this was a general HA problem. But I guess sounds like more so a problem with the addon instead.

For anyone else coming across this, this was my solution (which seems to work alright so far)

mqtt:
  sensor:
    - name: "doorbellTemplate"
      state_topic: amcrest2mqtt/Z0561A249A1A0/doorbell
      value_template: >
        {% if value is search('on', ignorecase=True) %}
        on
        {% else %}
        off
        {% endif %}
      expire_after: 60
1 Like