Closed tomlut closed 3 years ago
Hey there @phracturedblue, @tetienne, mind taking a look at this issue as its been labeled with an integration (template
) you are listed as a codeowner for? Thanks!
(message by CodeOwnersMention)
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.
Still an issue in core 2021.6.6
It is correct actually, as templates represent an evaluated result. Thus the result is indeed a number.
This is the attribute temp
containing a string:
temp: '19'
This is the attribute temp
containing a number:
temp: 19
Both return the type number in the template editor when using state_attr()
. This has confused a few people using the template editor to debug templates.
If there is no way around it I'll close the issue and just be aware of it when helping others.
Well, attributes actually support native types, but it is up to the integration to provide them. In this case, it provides strings.
Nevertheless, the output of a template is always evaluated, thus it gets converted in the matching native type.
I agree, in this case, it is confusing and would help if the integration used native typing for its attributes (making them easier to use as well).
In my case it was the core restful sensor integration, but to be fair it's actually my old Air-conditioning unit's bad json typing response that's at fault. Fortunately I'm not using it any more.
The problem
The developer tools template editor is returning an incorrect type for attributes. e.g. From the developer tools states menu,
sensor.json_lounge_aircon
returns this:The attribute
temp
is clearly a string, yet the template editor displays the result shown in Figure 1. in Additional Information below (I cant attach images in this text box).Testing for a number in the template returns the expected result. See Figure 2. below.
What is version of Home Assistant Core has the issue?
core-2021.2.1
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant OS
Integration causing the issue
Developer Tools Template Editor
Link to integration documentation on our website
https://www.home-assistant.io/docs/tools/dev-tools/#template-editor
Example YAML snippet
Anything in the logs that might be useful for us?
Figure 1.
Figure 2.