Automation only once

Hi all,

I am new to everything :slight_smile:
New to Home assistant and new to this forum.
I have a problem concerning automation and cannot believe that i seem to be the first who has this kind of problem, but if not i am just not able to use the right search words…
So my problem is:
I have two adapters from Laudrify (i bought them before using Home assistant). The have only the states “running” and “not running”. I wanted to make a notfication via telegram after the dryer or the washing machine is ready (not running). So simple as that i made a automation:
When dryer not running
send notifiation
Fine. Later this night i got a message every 7-10 minutes saying my dryer is done.
And logically HA is right. Every time he’s checking the state, the dryer is not running so he has to send a notifcation.
So i tried a lot of stuff and currently i think my only solution are templates. Here i’d be able to check if the state has changed from running to not running.
I think this can be done by the variable this (Automation trigger variables - Home Assistant)
But honestly i am just too dumb to understand how to use it :slight_smile:

My intention would be to just the write the state of the adapter to an variable (e.g. every 10 minutes) and just compare the current value with the last saved value. if the state has changed when the automation “not running” has started, then a notifcation should be send.
Probably this may need an helper, but there is my entity dryer not available…
All in all i am lost and don’t know what to do (or how) and cannot believe that i am unable to google this problem or that nobody had the same problem before… (in this case i’d also be grateful for someone showing me somebody with a similar problem :slight_smile: )

Thanks a lot
wasty

P.S.: Unfortunately (?) i am from Germany. so a screenshot or so from my automation won’t help a lot of people…

Post your automation (not a screenshot, but properly formatted as per the forum guidelines, between three backticks) and I think the German won’t be much of a problem.

If you use a timed check, that is most likely the problem. There are examples for detecting when a dryer is done, probably some blueprints too.

Most check when power usage is low for a certain amount of time. But in your case, a state condition detecting when the state changes from running to not running will probably do just fine. If that happens periodically then an extra for clause to say now long it must stay not running for it to trigger may also be of use.

If you post your automations code maybe someone would be able to help you

Hi,
Yeah you are absolutely right. I did not think about just posting the YAML-Code :smiley:

alias: "Waschmaschine "
description: ""
trigger:
  - type: not_running
    platform: device
    device_id: id_goes_here
    entity_id: id_goes_here
    domain: binary_sensor
    id: "67"
condition:
  - type: is_not_running
    condition: device
    device_id: id_goes_here
    entity_id: id_goes_here
    domain: binary_sensor
  - condition: trigger
    id:
      - "67"
action:
  - service: notify.homey
    data:
      message: "Test Waschmaschine "
mode: single

The thing with the Id Condition i have just added lately and i think is not necessary…

I would try a state trigger (instead a device), your binary sensor, to off

That would trigger only when your binary sensor goes to off

platform: state
entity_id:
  - binary_sensor.your.name
to: "off"

Thanks! I’ll try this.
Meanwhile i had a power down and no internet and everything for a very short while and i tried my luck with the pages i had already open (which was template).
Do you think this template would also solve my “mystery”?

alias: "Waschmaschine "
description: ""
trigger:
  - type: not_running
    platform: device
    device_id: id_goes_here
    entity_id: id_goes_here
    domain: binary_sensor
    id: "67"
condition:
  - type: is_not_running
    condition: device
    device_id: id_goes_here
    entity_id: id_goes_here
    domain: binary_sensor
  - condition: trigger
    id:
      - "67"
    enabled: false
  - condition: template
    value_template: "{{ trigger.from_state != trigger.to_state }}"
action:
  - service: notify.homey
    data:
      message: "Test Waschmaschine "
mode: single

Also i tried yours now:

platform: state
entity_id:
  - binary_sensor.meine_waschmaschine
to: "off"

But i always receive the error

Message malformed: extra keys not allowed @ data['platform']

i think something with my formatting is wrong

Ah i think i manage to use your example:

alias: "Waschmaschine "
description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.meine_waschmaschine
    to: "off"
  - type: running
    platform: device
    device_id: id_goes_here
    entity_id: id_goes_here
    domain: binary_sensor
    enabled: false
condition:
  - type: is_not_running
    condition: device
    device_id: id_goes_here
    entity_id: id_goes_here
    domain: binary_sensor
action:
  - service: notify.homey
    data:
      message: Test fertig
mode: single

I’ll test both when the machine is running the next time!
Thanks

I am not sure if that condition is needed there.

alias: "Waschmaschine "
description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.meine_waschmaschine
    to: "off"
condition:  []
action:
  - service: notify.homey
    data:
      message: Test fertig
mode: single
1 Like

Hi,
I also used your example. I’ll repost after the next washing/drying!

Thanks to you.
Have a nice evening
Wasty

So just to close this topic and help people which may have the same problem. All of them work :smiley:
This one:

alias: Waschmaschine State
description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.meine_waschmaschine
    to: "off"
  - type: running
    platform: device
    device_id: id_goes_here
    entity_id: id_goes_here
    domain: binary_sensor
    enabled: false
condition:
  - type: is_not_running
    condition: device
    device_id: id_goes_here
    entity_id: id_goes_here
    domain: binary_sensor
action:
  - service: notify.homey
    data:
      message: Waschmaschine fertig ĂĽber State
mode: single

This one:

alias: Waschmaschine Simple
description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.meine_waschmaschine
    to: "off"
condition: []
action:
  - service: notify.homey
    data:
      message: Waschmaschine fertig simple
mode: single

And also this one

alias: Waschmaschine Template
description: ""
trigger:
  - type: not_running
    platform: device
    device_id: id_goes_here
    entity_id: id_goes_here
    domain: binary_sensor
    id: "67"
condition:
  - type: is_not_running
    condition: device
    device_id: id_goes_here
    entity_id: id_goes_here
    domain: binary_sensor
  - condition: trigger
    id:
      - "67"
    enabled: false
  - condition: template
    value_template: "{{ trigger.from_state != trigger.to_state }}"
action:
  - service: notify.homey
    data:
      message: Waschmaschine fertig ĂĽber Template
mode: single

So thanks to mcarty!

one more question, and again i am totally clueless…
How can i measure the time these sensors spent running and write it into my message.
I tried it with a helper (i created a timer helper and tried to trigger its starts with the mode change), but i cannot find a call for the helper (i could only trigger for it).
Also i found that

trigger.for

may be able to help me, but i don’t know how to use it.
i found this post:
https://community.home-assistant.io/t/calculate-how-much-time-sensor-state/423712/6?u=wasty81
and in here the following code:

  entity_id: binary_sensor.office_ep_1_mmwave
  state: "off"
  type: count
  start: "{{ now() - timedelta(hours=24) }}"
  end: "{{ now() }}"

adapted to my usecase this would be

  - platform: history_stats
    name: Waschmaschine.timer
    entity_id: binary_sensor.meine_waschmaschine
    state: "on"
    type: count
    start: "{{ now() - timedelta(hours=24) }}"
    end: "{{ now() }}"

but then, how do i use it in my message?

Thanks again
wasty

i think i did it:

service: notify.homey
data:
  message: >-
    Waschmaschine ist fertig nach {{ (now().timestamp() -   
    as_timestamp(states.binary_sensor.meine_waschmaschine.last_changed))  |
    timestamp_custom('%H.%M.%S')}} Stunden

:slight_smile: