Restart Home Assistant triggers always notification

Hello,

maybe, somebody can help me with my knot in the head :slight_smile:

I have a power socket behind my washing machine and a door sensor on the bullseye, when door is closing, power socket on, if watt is lower then 10 for more then 5 mins then the power socket gets off and I get a notification that “Washing machine is done”.

When I restart Home Assistant, I will get after 5mins again the notification for the washing machine is done.

How can I avoid it?

Do I need to create another automation just for notification when power socket switch from on → off?

I want to have as less as automations as possible and want to combine things.

Because on → off could happened a lot when baby is playing on the door, thats why I don´t get a notification when the bullseye is just closed without using power :stuck_out_tongue:

alias: Steckdose - Waschmaschine - Aus
description: ''
trigger:
  - type: power
    platform: device
    device_id: c447bf5f97055dc95acabfc6ea178bb2
    entity_id: sensor.steckdose_waschmaschine_power
    domain: sensor
    id: Waschmaschine - Watt
    below: 10
    for:
      hours: 0
      minutes: 5
      seconds: 0
  - type: opened
    platform: device
    device_id: ac71821a819f190273b81af765312a74
    entity_id: binary_sensor.tuersensor_waschmaschine_contact
    domain: binary_sensor
    id: Waschmaschine - Türe
    for:
      hours: 0
      minutes: 5
      seconds: 0
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id: Waschmaschine - Watt
        sequence:
          - type: turn_off
            device_id: c447bf5f97055dc95acabfc6ea178bb2
            entity_id: switch.steckdose_waschmaschine
            domain: switch
          - service: notify.mobile_app_ste_iphone
            data:
              message: Wäsche ist fertig
              title: Waschmaschine
          - service: notify.mobile_app_dis_iphone
            data:
              title: Waschmaschine
              message: Wäsche ist fertig
      - conditions:
          - condition: trigger
            id: Waschmaschine - Türe
        sequence:
          - type: turn_off
            device_id: c447bf5f97055dc95acabfc6ea178bb2
            entity_id: switch.steckdose_waschmaschine
            domain: switch
    default: []
mode: single

Thanks in advance :slight_smile:

1 Like

The reason its doing that is because at the restart this trigger is valid as it gets all the values from your devices. At start the device will send 0 watt (or below 10) and thus triggers the automation.

Just add the integration uptime and use that as a condition for your automation.

3 Likes

Uptime throws out the date and time. So a simple template in the condition would be:

{{ ((as_timestamp(utcnow()) - as_timestamp(states('sensor.uptime'))) | round(0)) > 120 }}

120 seconds in this case, so 2 minutes. You can adjust if needed. ( the round(0) isnt needed)

3 Likes

Thank you, sounds like a good solution :+1:
I will test it, tomorrow!

That is working, thank you very much :slight_smile:

1 Like

I tried this in a template condition and received the error “Error occurred while testing condition
template value should be a string for dictionary value @ data[‘value_template’]. Got None”.

Do you have the integration running?

Yes. I installed the Uptime integration. It shows it’s working.

Can u plaste this in the Developers Tools → Template. Should give out a true
Testing it myself in automation throws out the same error. However running the automation does not.
So i think its a testing limitation/bug.

2 Likes

Thanks, it was true. Should work then.