Automation triggered at restart HASS

I have 3 automations for my doorbell in combination with a sonoff module:

  • let’s ring the doorbell between 07:00 and 19:00
  • don’t ring the doorbell but push a notify message between 19:00 and 07:10
  • the last one lets the doorbell rings for the whole day for example when somebody comes to visit ut after 19:00.

But when i restart HASS this automations will be triggered, so when i change some config or something and i want to restart HASS my doorbell rings. I don’t want that :wink:
How can i fix my problem?

you could set those automations as initial: ‘off’ then turn them on after a delay after HA starts.

Similar to this::

- alias: Delay SSL Cert Notify After Homeassistant Startup
  initial_state: 'on'
  trigger:
    - platform: homeassistant
      event: start
  action:
    - delay: '00:05:00'
    - service: automation.turn_on
      entity_id:
        - automation.ssl_expiry_notification
2 Likes

Thank you for your quick reply.
When i switch off the automation and restart HASS the doorbell doesn’t ring.
But when i switch on the automation the doorbell does ring, so the problem is in the automation…

This is my automation:

- id: '1535832688944'
  alias: Deurbel overdag geluid
  trigger:
  - payload: 'ON'
    platform: mqtt
    topic: cmnd/Klik/POWER1
  condition:
  - after: 07:00
    before: '19:00'
    condition: time
  action:
  - data:
      payload: '3'
      topic: cmnd/sonoff-bel/power
    service: mqtt.publish
  - data:
      message: Er staat iemand voor de deur
    service: notify.pushover

I see there is MQTT entities at the trigger level are the “” retain: “” arguments set to false in your configuration.yaml file?

I dont understand what you mean.
I dont make any switch of my doorbell in my configuration.
Can i use the retain option in the condition part of the automation?

At my light switches i use the retain option so home assistant knows what the status of my lights are.

you wrote somewhere the specifications for your MQTT platform like the topics id’s etc…

These are my settings in configuration.yaml

mqtt:
  broker: !secret mqtt_ip
  port: !secret mqtt_port
  client_id: home-assistant-1
  username: !secret mqtt_user
  password: !secret mqtt_password
  discovery: true

No not that part… More like below

- platform: mqtt
  name: "Door Bell"
  state_topic: "your topic"
  command_topic: "your topic"
  payload_on: "ON"
  payload_off: "OFF"
  qos: 0
  retain: false

I haven’t a mqtt topic for my doorbell.
I read the info from my sonoff device log and put in an automation.
I want also make a sensor to read the last time when my doorbell is triggered but also that doesn’t work.

In the trigger part you trigger from a MQTT entity this is the entity i’m talking about

i use that within the connection with the sonoff device.
Both are connected with the same MQTT broker.
What i want is when somebody is pressing the doorbell (the trigger at “cmnd/Klik/Power1”) i receive a message at my phone and the doorbell rings.

so somewhere in your MQTT setup you have to flag the retain message of that topic to false i use to have that problem and this solved it.

I will try to make a button with a retain false option, and try to use that switch as a trigger.

Update:

I have to make a sensor :wink:

1 Like

Thanks for this… I used it… only issue I had was that while developing, and reloading automations, the automations that are intended to be delayed are never started (until a restart of home assistant).
I played around a bit and found a work around for that by firing the turn_on action also after a reload of the automation component… posted on another similar query:

1 Like