Did you create the input_datetime in the Helper UI? I had this same problem last week, where I couldn’t change the state. When I cleared the browser cache though, it was working fine!
After modifying the automation, did you run Configuration > Server Controls > Reload Automations?
I don’t see any syntax or logic errors in your automation. I just created and tested the following automation and it works. It’s fundamentally the same as your automation.
Thanks for your tests. I’ve made some more tries, with the following results:
I cleared the navigator cache, as Adam suggested, with no noticeable result.
If I set the datetime as a string like datetime: '2020-05-30 21:20:05', it works, and the datetime is set.
The service input_datetime.set_datetime performs a check of the datetime format, and must be set according the format above, if not, it won’t work.
My impression is that there is a problem with the format that the automation is passing to the service, but I don´t know how set it up in other way.
eHc
I can’t see anything wrong with what you have setup and the fact that Taras replicated your code without fault and given it’s basically exactly the same as the examples in the documentation, shows that there’s a hidden problem here.
I would recommend creating an input_datetime in the configuration.yaml and see if the problem goes away.
One other query… Is the code you posted exactly what is in you automations.yaml? If you try and put a data_template in to the Automations UI, you will inevitable end up with: -
When I execute the script, I get the following error in the log:
Error executing script. Invalid data for call_service at pos 1: Invalid datetime specified: {{ now().strftime("%Y-%m-%d %H:%M:%S") }} for dictionary value @ data[‘datetime’]
I am now seeing the same problem as ehc… I had a working script which updated an input_datetime when motion was detected (an MQTT message with a specific value), but this stopped working and was giving all sorts of duplication - maybe after the latest update - and my database shot up to 1Gb with thousands of motion notifications, but these were not real.
Anyway, tried to fix it and recreated the automation, but despite the templating showing the correct format, I cannot manage to update the input_datetime, even using “services” via Developer Tools and get the same error as ehc (Error executing script. Invalid data for call_service at pos 1:, etc.)