Templates in the data: block of Dev->Services aren't casted/converted to the expected type #7497
Replies: 9 comments
-
Hey there @home-assistant/core, mind taking a look at this issue as its been labeled with an integration ( |
Beta Was this translation helpful? Give feedback.
-
In fairness, this is probably a frontend or template engine issue and not directly related to the datetime integration. I'd move it if I could. |
Beta Was this translation helpful? Give feedback.
-
This is still an issue with 0.116, and another user saw the issue templates feeding into the Tinkerer pointed out that 0.117 will return native types and may address this and hopefully that will unify the behavior of scripts & the dev tools. |
Beta Was this translation helpful? Give feedback.
-
The service dev tool does not render templates. |
Beta Was this translation helpful? Give feedback.
-
And yet, it does, just with this quirk :) |
Beta Was this translation helpful? Give feedback.
-
This still doesn't work properly in 0.117, despite the change to have templates return native data types. I created an The service data is this:
And the error is this:
It seems like we're in a sort of middle ground where templates are evaluated in dev tools, but types aren't being handled properly. I see people running across this regularly in Discord, and it makes it difficult to support them when the behavior in DevTools doesn't reflect what will happen in a script/automation. Here's the latest example: https://discord.com/channels/330944238910963714/672223497736421388/769651662541291530 |
Beta Was this translation helpful? Give feedback.
-
Nah, it's not a middle ground. Dev tools do not support templates. Persistent notification and notify do support templates in their own service handling. |
Beta Was this translation helpful? Give feedback.
-
Should we move this to the frontend as a feature request? |
Beta Was this translation helpful? Give feedback.
-
Would you expect the frontend to process the data and then call the service? Or would you expect the websocket API call service command to get a flag to "render templates"? I kinda like the idea of putting it in the frontend, because we could show the user what the values are that we passed to the service. Transferring. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
The problem
Templates in the
data:
block of Dev->Services aren't casted/coerced into the expected field type, but they are in a script. This example from theinput_datetime
docs works in a script, but not in Dev->Services:In Dev->Services, it results in the following error:
voluptuous.error.MultipleInvalid: expected float for dictionary value @ data['timestamp']
Templates always return strings, but it looks like they're converted to the expected type in a script, but not in the developer tools.
Environment
Problem-relevant
configuration.yaml
I created an
input_datetime
(helper) in the UI for testing, and used this script:That works, while putting the following in the data section of Dev->Services with
input_datetime.set_datetime
results in the error mentioned:Traceback/Error logs
This may actually be a "frontend" issue, so feel free to move if necessary.
Additional information
Beta Was this translation helpful? Give feedback.
All reactions