Make action not trigger on home assistant startup

I have an action that triggers after my washing machine finishes (wattage is lower than 5 for 2 minutes). But this also triggers every time I start up Home Assistant. How do I avoid that?

  - alias: Washing Machine
    trigger:
      platform: numeric_state
      entity_id: sensor.vaskemaskin_power_3
      below: 5
      for:
        minutes: 2
    action:
      service: notify.pushover
      data:
        title: "Washy washy"
        message: "Vaskemaskinen er ferdig"

add a condition to ensure HA hasn’t started in the last [say] 5 min?
I have an automation that runs at startup and check that this automation hasn’t ran in the last 5 min:

    - condition: template
      value_template: '{{(as_timestamp(now()) - as_timestamp(states.automation.hass_start_sound.attributes.last_triggered | default(0))) | int > 300}}'
1 Like

Good idea!

I created this automation:

  - alias: HA started
    trigger:
      platform: event
      event_type: homeassistant_start
    action:
      - service: script.noop

And this script:

noop:
  alias: "noop"
  sequence:
    delay: 00:00:00

But somehow states.automation.ha_started.attributes.last_triggered is null:

{
  "last_triggered": null,
  "friendly_name": "HA started"
}

Any idea why?

Never mind, I figured out that I should use the homeassistant platform instead:

- trigger:
    platform: homeassistant
    event: start
1 Like

was just about to point this out :slight_smile:
Have fun

1 Like

That seems like a good solution. As an alternative, what I’ve seen others do is use the Uptime Sensor. E.g., check out this topic.

3 Likes

The uptime sensor looks even more intuitive, thanks!

But anyway, it looks like these solutions just delay the notification by 5 minutes :frowning:

Back to the drawing board?

set an input_boolean to track when you turn the machine on and use it as a condition for your notification.
Obviously make sure that the default state for the boolean is off :wink:

That doesn’t make sense to me, unless sensor.vaskemaskin_power_3 is changing to values above and below 5 constantly or often. If it is below 5 at startup, and stays that way for 2 minutes, then yes, you’ll get an undesired notification (which should be eliminated with an uptime condition.) After that, it has to go to 5 or above, and then back below 5, and stay that way for 2 minutes, before the automation will trigger again.

If you add a condition like the following to your original automation, I don’t see how you’ll still get a notification after startup (again, unless the sensor’s value is changing.)

condition:
  condition: numeric_value
  entity_id: sensor.uptime
  above: 3

This assumes you enable sensor.uptime with a value of minutes.

If the value is indeed fluctuating around 5, then I would think you have more of a problem than just an undesired notification at startup.

Ahhh, I figured it out. My telldus zwave mini switch only sends updates every 600 seconds when idle. So setting the idleness to 12 minutes fixed the issue. I could also configure the switch to send updates more often. Thanks for all the feedback! For reference, this is all that I had to do.

In automations.yaml:

  - alias: Washing Machine
    trigger:
      platform: numeric_state
      entity_id: sensor.vaskemaskin_power_3
      below: 5
      for:
        minutes: 2
    condition:
      - condition: numeric_state
        entity_id: sensor.ha_uptime
        above: 12
    action:
        - service: notify.pushover
          data:
            title: "Washy washy"
            message: "Vaskemaskinen er ferdig"

In configuration.yaml:

sensor:
  - platform: uptime
    name: 'HA uptime'
    unit_of_measurement: minutes
1 Like