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?
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.
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.
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.
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:
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:
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???