Washer says a cycle has finished when I reboot HA

So since the kids forget clothes in the washer, I’ve added a Tasmota power monitor plug to the washer. When the power drops below 10W for 30 seconds, an automation kicks in and tell my living room Alexa to warn that a wash cycle has finished. Trouble is, when I reload HA, after some minutes, the automation will run. Is there a way to prevent that?

Thanks.

This is my automation for the same thing, I faced the same issue as you so added a condition to make sure the switch is actually on, and set the time a little longer for the power to have dropped below the threshold.

There is probably a more elegant way to do it, but this works for me.

- alias: Washing Machine is on Standby - Turn Off
  initial_state: true
  trigger:
    platform: template
    value_template: "{{ states('sensor.kogan_pow_1_energy_power')|int < 10 }}"
    for:
      minutes: 2
  condition:
    - condition: state
      entity_id: switch.kogan_pow_1
      state: "on"
  action:
    - service: switch.turn_off
      entity_id: switch.kogan_pow_1
    - service: media_player.volume_set
      data_template:
        entity_id: media_player.lounge
        volume_level: 0.5
    - service: notify.alexa_media
      data_template:
        target: media_player.lounge
        data:
          type: tts
        message: '{{ ["Your filthy clothes are clean again", "The washing is done", "Go and hang out your clothes", "The washing has finished", "Clothes are clean and smell amazing"] | random }}'

Trouble is, when I reload HA, after some minutes, the automation will run. Is there a way to prevent that?

The key note here is reload of a configuration file and not a restart/reboot of HA correct? This happens when you reload a config file that you have just edited? Does it happen when you restart HA after editing the file?

I noticed this a few weeks ago for me. I was editing a template file. Instead of restarting HA, I use the reload template entities instead. Then, I noticed another automation set off.

I use an intermediate binary_sensor and it‘s state is persistent among restarts. I use that sensor as automation trigger.

binary_sensor:
  - platform: template
    sensors:
      washing_machine:
        value_template: "{{ state_attr('switch.washing_machine','current_power_w') | float > 10.0 }}"

Thanks but my switch is only on so in my case, the condition would always be true

Sorry, I used the wrong term, I meant restart HA

That sounds like a good idea. I’ll give it a try, thanks.

If the switch turns off when the load is complete, you don’t have the washing machine sitting on standby power :wink:

Your example shows a Template Binary Sensor. All Template-based entities don’t have persistent states across restarts. In other words, their state is never stored before a restart and restored on startup. Template-based entities have their templates evaluated at startup.

1 Like

So, what would be a solution to my problem then? How would I prevent the triggering of the automation when HA restarts?

If the templated binary sensor is still the best solution, then I can’t get it to work. I have

image

But

{{ state_attr('sensor.priselaveuse','energy_power') | float }} returns 0. If it’s

{{ state_attr('sensor.priselaveuse_energy_power', 'what do I put here?') | float }}

Anybody? Thanks

You’ve been provided a solution, you have chosen not to use it.

Thanks, but unless I’m missing the obvious, and like I mentioned earlier, my switch is always on so this solution is the same as what I currently have.

what about adding a input_boolean

  washingmachine:
    name: "Washing done" 
    icon: mdi:washing-machine

that get turn on when you get alexa finsh saying her bit

and get turn off when the power over xx W

then adding condition in the alex say bit that has to be off

Yeah, that’s what I’m trying to do but can’t figure out the template.

{{ state_attr('sensor.priselaveuse','energy_power') | float }} returns always 0, so that’s not it…

And not sure what to put in ‘what do I put here?’

{{ state_attr('sensor.priselaveuse_energy_power', 'what do I put here?') | float }}

Thanks.

What happens when paste it into template. That’s your friend

so

find it in states

then in template

and

then once your found got what you want paste the into the templates

That’s the thing, I can’t get it to show me what I need in the template. This the debugger state for that device:
image

So when I enter ‘device_class’ for the attribute, this is what I get:

Fine, but whatever else I enter, like, power, current, voltage, the template output doesn’t change:

But if I completely erase the line and copy it back, I get:

Samething happens if I replace power with voltage or current.

So, what am I doing wrong?

Thanks for sticking up with me :slight_smile:

The first screenshot in your post shows only three attributes:
unit_of_measurement
friendly_name
device_class

What leads you to believe this sensor has other attributes like power, current, voltage, etc?

It seems to me that this sensor reports power in its state value and that’s it.

I’m a bit confused here since to Taras point you seem to be trying to access attributes that don’t exist. I also don’t really understand how those attributes would help?

Based on your entity I could be wrong but it seems like you have everything you need from the state. The difference between start-up and an actual washing machine run seems like it should determinable using the from_state of sensor.priselaveuse_energy_power.

You haven’t shared your actual automation so I don’t know for certain what you’re doing. But based on your description I’m going to assume your trigger is something like this:

trigger:
  platform: numeric_state
  entity_id: sensor.priselaveuse_energy_power
  below: 10
  for:
    seconds: 30

If I am correct about that then you should be able to add a conditional that simply checks to see that the from_state is above your threshold and not below. Because if the washing machine is running then it will only trigger that when it crosses from above 10 to below. But on restart it will trigger since it went from null to 0 and that won’t pass this conditional:

conditions:
- "{{ trigger.from_state.state | float > trigger.below }}"

If your automation is more complicated then that though you’ll have to share it. Those fields in trigger I’m using are only going to work for a numeric state trigger, if you are using a template trigger or something then you’ll need something else.

Well, I’m trying to do what that posts says but for that, I need to read that value in a template. At least, I think I do. Still learning this stuff…

This ‘attribute’ IS power, isn’t that what this ‘unit_of_measurements’ being ‘W’ means??? It states is ‘4’, which to me is 4W. How do I read that in the template example I linked then???