I’d like to use an automation to set one Input Datetime to the value of another each day. Basically I want to be able to be able to set a bedtime for my kids via the UI, but each day have that reset to a usual bedtime, which I can also change via the UI.
My code is below, which returns the following errors when I try to run the actions
Error while executing automation automation.reset_kids_lights_out_time: Invalid time specified: {’[object Object]’: None} for dictionary value @ data[‘time’]
Reset kids lights out time: Error executing script. Invalid data for call_service at pos 1: Invalid time specified: {’[object Object]’: None} for dictionary value @ data[‘time’]
When I replace {{ states(‘input_datetime.lights_out_for_kids_usual’) }} with a time (e.g. ‘19:30:00’) it works fine, and when I try putting {{ states(‘input_datetime.lights_out_for_kids_usual’) }} into the template tool on Developer Tools it displays a time
I’ve also tried {{ state_attr(‘input_datetime.lights_out_for_kids_usual’,‘timestamp’) }}, which seems to return the same error
Still trying to get the hang of how templates work so am sure I am doing something stupid, any help hugely appreciated
Thanks!
alias: Reset kids lights out time
description: ''
trigger:
- platform: time
at: '23:59'
condition: []
action:
- service: input_datetime.set_datetime
data_template:
time: {{ states('input_datetime.lights_out_for_kids_usual') }}
entity_id: input_datetime.lights_out_for_kids_today
mode: single