Looking for some help getting an automation working based off of user input in an input_datetime:
I’m just looking to have user input from someone to set a time and when that time gets reached to turn on a switch. Just using it to smarten up our crockpot a little. Sometimes we’ll be at work and need to “delay” in starting it so the easiest thing to do would just to be set a time when it should come on.
I’ll let you know how far I’ve gotten and hope you can help me get it across the finish line.
I created an input_datetime component:
Want to be able to input the date and time because I don’t want it accidentally turning on again tomorrow.
Then added datetime sensor
platform: time_date
display_options:
‘time’
‘date’
‘date_time’
‘time_date’
‘time_utc’
‘beat’
Everything seems to be fine to this point. I put them both in a card and checking the sensors in the dev tools it looks fine.
I set off to make the automation and this is where I’m getting stuck. I think with the template.
Here is my automation (excuse the repurposed christmas tree plug):
I’ve been playing around with the template builder in the tools and I have it close but I’m not sure if it’s not liking it because there isn’t a comma in there or what. I can’t seem to figure out how to get that comma to be in the string. Also not sure if it doesn’t like that the input has seconds or how to get rid of those. I’ve reached the end of my templating skills and hope someone can help.
Here is the output in the template builder.
Perfect! This got me the right format for sure. It’s still not triggering but now that I have this thats one less variable to figure out why it’s not triggering.
Actually that was the fix. The only reason it wasn’t working was you had an extra underscore in your example and I copied and pasted it in my automations.yaml then when I was playing with it in the template I noticed it and took it out and forgot to take it out of my automatons file. Thanks a heap!
Not sure what’s going on here with the nested value_templates. Also, ref @Mutt’s response, you don’t need to add sensor.date_time — you only need sensor.time as your input.date_time is just time (Heure). So:
Wasn’t a criticism — you’re of course correct that if sensor.date_time is being used, it must first be set up. I just wanted to be clear that with a time-only helper set up as per screenshot, there is actually no need for it at all.
For this example, you still need the 'time', yes, and I’ve just noticed it should be platform: time_date, not date_time. Because the automation uses sensor.time, you need:
…and you’ll need to restart HA to load this sensor in.
This integration provides a number of different sensors (read the docs), and allows you to specify only the ones you want to keep things clean and succinct. @Mutt’s point was that the automation you were proposing used sensor.date_time but you had not set that up.
The code I suggested does not use sensor.date_time, just sensor.time, so that’s all you need to set up in this case. If you have other automations using sensor.date or sensor.date_time, you need to add those lines to the display_options.