0.40 ISSUE - automation.turn_off not working?

Since updating to 0.40, this automation no longer works:

automation:
  # Delay automations that trigger on restart; i.e. presence-detection
  - alias: delay on restart
    hide_entity: True
    trigger:
      platform: event
      event_type: homeassistant_start

    action:
      - service: automation.turn_off
        entity_id: automation.notify_open_close_door
      - service: automation.turn_off
        entity_id: automation.notify_home_resident

      - delay:
          minutes: 1

      - service: automation.turn_on
        entity_id: automation.notify_open_close_door
      - service: automation.turn_on
        entity_id: automation.notify_home_resident

While HA says the automation triggered, it doesn’t do what its supposed to do - prevent my door template sensors and resident template sensors from alerting when I restart HA. Heres basically what the door sensors and automation look like:

sensor:
  - platform: template
    sensors:
      garage_door:
        friendly_name: 'Garage Door'
        value_template: >-
          {% if states.binary_sensor.garage_door_tilt_sensor_sensor_27_0.state %}
            {% if is_state('binary_sensor.garage_door_tilt_sensor_sensor_27_0', 'off') %}
              Closed
            {% else %}
              Opened
            {% endif %}
          {% else %}
            Unknown
          {% endif %}

automation:
  # Alert when doors open and close
  - alias: NOTIFY (OPEN CLOSE) Door
    hide_entity: True
    trigger:
      - platform: state
        entity_id:
          - sensor.garage_door
    condition:
      - condition: state
        entity_id: input_boolean.options_notifications_push
        state: 'on'
    action:
      - service: notify.pushetta_carinajesse
        data_template:
          message: >-
            {{ trigger.to_state.attributes.friendly_name }} {{ trigger.to_state.state }}
          title: >-
            {%- if is_state("alarm_control_panel.alarm", "armed_away") or
              is_state("alarm_control_panel.alarm", "armed_home") -%}
              ALARM TRIGGERED -
            {%- else -%}
            {%- endif %}

Might it be easier to default those automations to off? I suspect you’ve tripped across the startup improvements, and things that used to take longer are now finishing before it turns off the automations.

Thanks - how do I do that?

2 Likes

Awesome, thanks

That was it! I set the false positive automations to initial state false and then have another automation to turn them on after 1 min after HA starts. Works great.