Hey guys I’m new to home assistant and I’ve been really trying to work this out for myself but I think I just need a little help doing my first automation with templates so I can reference back to it in the future.
I’m trying to automate my washing mashing to notify me when it is done i tried doing a basic if the power falls below 4w for 3 minutes but I got lots of nuisance triggering when the wemo would drop of the network for a second.
I’ve noticed the wemo has a ‘state_detail’ which includes
‘off’ switch turned off
‘standby’ switch on but not drawing power
‘on’ switch on and consuming power
I want my automation to detect a change from the ‘on’ state to the ‘standby’ state only after 3 minutes
I’ve managed to get the template maker to recognise the 3 states with a true or false but I just need help incorporating it into an automation that basically says "if the state_detail changes from ‘on’ to ‘standby’ for 3 minutes run the automation any other combination of state change im not interested in.
Really sorry to have to ask guys but it’s really got the better of me. Just need it explained to me in laymans terms so I can do it myself in future.
For a template trigger, like you’re trying to use, it needs to evaluate to true when you want it to trigger, and something else when it shouldn’t trigger. Note also that it will trigger the first time it evaluates to true, and then after that, it has to evaluate to something other than true, and then back to true for it to trigger again.
But your template is evaluating to ‘washing’, ‘standby’ or ‘off’, and never to ‘true’, so it will never trigger.
Actually, I think the easiest way to do this, especially since you want the “for 3 minutes” condition, and you already have a template sensor whose state is the state_detail attribute, is to use that template sensor in the trigger. But first you should probably get rid of that stray - character. And you should use the state_attr function when possible.
Thanks mate that worked perfectly and sent a notification to my phone via pushbullet. Hopefully now that i can see how to create a sensor and integrate it into an automation I’ll be able to do it myself next time
I’m also trying to create a binary sensor from the state_details for a sump pump that I use on a Wemo Insight but am not having much luck. The notification example above for the washing machine is a good notification solution, but I also want to create a visual cue on a card in the HASS Interface and thought a binary sensor would be an easy way to implement that.
A few things. First, where is sump_pump.yaml, and how is it being included in the overall configuration? That will affect whether platform needs a dash before it, and also if there needs to be a binary_sensor: line before it.
Next, friendly_name needs to be indented under sump_pump_on (at the same indentation level as value_template.)
Next, you need to put quotes around the template.
Lastly, it’s better to use the is_state_attr function.