MQTT Wifi Doorbell Status not clearing

My Wifi Doorbell works and notifies my broker, the HA automatons run but I can’t get the topic to clear.

When I listen to the topic on HA:

Message 0 received on homeassistant/doorbell at 7:23 PM:
{
“batt”: 3.236328
}
QoS: 0 - Retain: true

When the doorbell is triggered it send the battery voltage to the topic. I don’t really care about the voltage but without the state clearing it causes complications and duplicate future activation.

As a cludge I just reboot the MQTT server nightly but I’d rather just fix whatever mistake I’ve made. Can anyone help?

The product is fireflyelectronix / wifidoorbell

I’ve got the same doorbell and don’t have any issues triggering automations off the battery voltage.

Can you clarify a bit the issues you are having?

If I don’t clear the battery voltage by restarting my mqtt server then anytime I change the automation and hit save the automations that relate to that topic will retrigger.
If someone hits the doorbell and it has already been triggered once all the automations get triggered twice.

Of course the mqtt message is not cleared, it contains the retain flag. You can clear the message by publishing at the end of your automation a message to the topic with empty payload.

1 Like

Thank you very much this is great info.
I’m sorry to follow up but can you give an example of the line I should add to the automation?

I really appreciate your help this has been bugging me since 2017!

  action:
  - data:
      retain: "true"
      topic: homeassistant/doorbell
    service: mqtt.publish
1 Like

This causes an endless loop because it triggers as a push the the group.
It’s kind of funny actually. Alexa is triggered over and over saying dingdong doorbell over and over until I restart my mqtt docker.

Can you show your automation?

I was thinking about your loop. Without knowing the actual automation, I can only guess. But if you have an automation like this :

- id: '1562219853899'
  alias: Test
  trigger:
  - topic: homeassistant/doorbell
    platform: mqtt
  action:
  # other stuff
  - data:
      retain: "true"
      topic: homeassistant/doorbell
    service: mqtt.publish

it will indeed loop. The solution is to add a condition

- id: '1562219853899'
  alias: Test
  trigger:
  - topic: homeassistant/doorbell
    platform: mqtt
  condition:
  - condition: template
    value_template: "{{ trigger.payload != '' }}"
  action:
  # other stuff
  - data:
      retain: "true"
      topic: homeassistant/doorbell
    service: mqtt.publish


1 Like

Thats great thank you very much.
I will have to test on the weekend, I directly commented out some of the code for testing to remove the loop but then I edited after using the GUI interface and it deleted all the text that was commented out.

I will either restore or start again this weekend. I also have to wait to fully do the automation because I exceeded the 150 push notification limit when it started to loop so I have to wait 24 hours anyway.

I really appreciate your help though, thank you very much. If I get this all working on the weekend I will post my result.

Thank you very much here is the completed automation and in testing everything works perfect and fixed my original issue:

  - platform: mqtt
    topic: homeassistant/doorbell
  condition:
  - condition: template
    value_template: '"{{ trigger.payload != '''' }}"'
  action:
  - data:
      data:
        type: tts
      message: Ding Dong, Doorbell
      target:
      - rob's show
      - media_player.<MY ALEXA1>
      - media_player.<MY ALEXA2>
    service: notify.alexa_media
  - data: {}
    entity_id: switch.<MY SWITCH>
    service: switch.turn_on
  - data:
      data:
        attachment:
          content-type: jpeg
        entity_id: camera.<MY CAMERA>
        push:
          category: camera
      message: Who is at the door?
      title: Doorbell
    service: notify.parents
  - data:
      retain: 'true'
      topic: homeassistant/doorbell
    service: mqtt.publish
  initial_state: true