Closed pedolsky closed 2 weeks ago
The output of Templates is always to a string. So you need to do the logic inside of the template.
Thank you for responding. It would explain why the second example fails.
But why does it make a difference in the first one (uptime)?
Uptime is calculated, but the result is a s string. In the comparson now
results in a date time. So you need to convert to datetime before you can compare.
So I mistakenly assumed that the variable was interpreted as time. Thank you very much for your efforts, much appreciated!
The problem
I have a few automations that use time variables, e.g.
a)
b)
Using these variables as part of a condition results in the following error and the automation will not be executed:
TypeError: '>' not supported between instances of 'str' and 'datetime.timedelta'
Examples: Fails:
Works:
What version of Home Assistant Core has the issue?
core-2024.8.1
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant Supervised
Integration causing the issue
automation
Link to integration documentation on our website
https://www.home-assistant.io/docs/automation/
Diagnostics information
No response
Example YAML snippet
No response
Anything in the logs that might be useful for us?
Additional information
If this is no bug but expected behavior, there should be at least a warning in the logs that the automation failed.