When trying to configure an input_datetime with only time I get a configuration error if I try to set an initial value with just a time value. It seems I can get around the issue by including a date in the intial value but it would be nice if it allowed date and time or just a date or just a time. It would be even better if it validated to the appropriate value based on how has_date and has_time are set.
Here is the error I got:
2017-10-08 07:21:13 ERROR (MainThread) [homeassistant.config] Invalid config for [input_datetime]: Invalid datetime specified: 06:30 for dictionary value @ data['input_datetime']['alarm_clock_time']['initial']. Got '06:30'. (See /home/homeassistant/.homeassistant/configuration.yaml, line 169). Please check the docs at https://home-assistant.io/components/input_datetime/
2017-10-08 07:21:13 ERROR (MainThread) [homeassistant.setup] Setup failed for input_datetime: Invalid config.
input_datetime:
wakeup_alarm:
name: Wake Up Alarm
has_date: false
has_time: true
initial: '2017-06-01 06:00'
As the input_datetime is configured with has_time: true and has_date: false when I check the status I can only see the time.
My problem now if to fire an automation based on comparing this component with the current time.
Time Sensor: {{ states.sensor.time.state }}
Alarm: {{ states.input_datetime.wakeup_dads_alarm.state }}
first one gives me: 16:37 but the input_datetime returns 16:37:00 so something as simple as this below for an automation trigger actually gets complicated with formatting, etc:
Thanks for this @davedan.
I’ve been watching the input_datetime so I can set when I want my coffee machine to come on in the UI.
I tried a bunch of stuff before realing that what @proddy said (what I was trying) doesn’t work…
Does anyone know if there’s a plan to make at and for in platform: time templatable?
It would be very much nicer than having to create both a new time sensor and a template trigger to check if the two match.
@jceloria thanks for sharing. I think that’ll work too. My only concern is how often the trigger is checked (for performance reasons). Is it on every state change of states.sensor.time.state which is every second? not sure.
I’m using the built in HA time and date sensor (HH:MM), and comparing that to a fixed value. I’m not sure how inefficient the built in sensor is, but triggering on state change I would guess that the worse case scenario is that it runs once every minute.
It looks like the original request has been implemented in a recent change… that broke my config
initial (Optional): Set the initial value of this input. Defaults to ‘1970-01-01 00:00’. If has_time is false this must be just a date (e.g.: ‘1970-01-01’). If has_date is false this must be just a time (e.g.: ‘15:16’).