I want to neaten this thread up, so I’ve changed all the information to reflect an accurate example. That is me turning on the kettle which boils for about 45 seconds at a draw of 1950W-2100W. The only thing I haven’t changed is Fridge -> Kettle in the code.
@Jer78
So with everything you’ve suggested the code looks as follows and the only time the code triggers currently is when I start Home Assistant.
The scenario is as follows:
I run HA with the Kettle off so of course the automation will trigger as the draw is below 1900W.
I then turn the Kettle on and see the Draw sit between a value of around 1900 and 2100, at this point after 10 seconds the automation should trigger but it does not.
@HellfireZA Hmm…really not sure why it’s not triggering. Try removing “above: 1900” and just see if it triggers when it goes below 2200. That way there’s less parameters for it to meet and easier to troubleshoot.
@HellfireZA
Even though I’m still new to HA, I’ll give this a shot.
I see that you are using a numeric_state trigger. In the documentation on automation triggers, it shows that the for is supported.
However, according to the current documentation on automation templating, the numeric_state platform does not support trigger.for in the platform’s available data.
Is it possible that using for only works for state triggers, and not numeric_state triggers?
- alias: If Test Power is less than 1900W Restart
hide_entity: False
trigger:
platform: template
value_template: "{{ states.sensor.Test_Draw.state | int < 1900 }}"
action:
- service: switch.turn_off
entity_id: switch.Test
- delay: 00:00:10
- service: switch.turn_on
entity_id: switch.Test
That works, if the value drops to 1700W, the automation will kick in and the “Test” will turn off, wait 10 seconds and turn back on. The problem is though that if it turns back on and it’s still under 1900W, the automation won’t trigger again, so how do I resolve that issue? Thanks
You could write a second automation that gets triggered by the switch being turned on (maybe with a small time delay?) and a condition that checks the power draw, and if it’s below 1900W kicks off the restart again.
@HellfireZA the only other way is to have a time based trigger (example run every 5 mins) and use the template in a condition. I’d write it out for you but I’m on my phone right now, but if you need an example, I can post later tonight