core
core copied to clipboard
state_translated() behavior on 'unknown': not translated
The problem
using an entity with an unknown state in the state_translated() or |state_translated syntax is not translated.
https://next.home-assistant.io/docs/configuration/templating/#state-translated
the state actually is 'unknown' so that is not the issue. it should however be translated in both syntaxes.
What version of Home Assistant Core has the issue?
2024.4.0.dev20240312
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
Template
Link to integration documentation on our website
https://www.home-assistant.io/integrations/template
Diagnostics information
No response
Example YAML snippet
{{ 'binary_sensor.achterdeur_buiten_sensor_motion'| state_translated }}
{{state_translated('binary_sensor.achterdeur_buiten_sensor_motion')}}
Anything in the logs that might be useful for us?
No response
Additional information
Hey there @phracturedblue, @tetienne, @home-assistant/core, mind taking a look at this issue as it has been labeled with an integration (template) you are listed as a code owner for? Thanks!
Code owner commands
Code owners of template can trigger bot actions by commenting:
@home-assistant closeCloses the issue.@home-assistant rename Awesome new titleRenames the issue.@home-assistant reopenReopen the issue.@home-assistant unassign templateRemoves the current integration label and assignees on the issue, add the integration domain after the command.@home-assistant add-label needs-more-informationAdd a label (needs-more-information, problem in dependency, problem in custom component) to the issue.@home-assistant remove-label needs-more-informationRemove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.
(message by CodeOwnersMention)
template documentation template source (message by IssueLinks)
Please don't be thrown off by the erroneous error comments in this issue. The real issue is that state_translated is not translating unknown and unavailable. The misuse of the state_translated function in the beginning of the examples should be ignored.
not valid:
{{states('binary_sensor.achterdeur_buiten_sensor_motion')| state_translated}}
valid
{{state_translated('binary_sensor.achterdeur_buiten_sensor_motion')}}
my apologies, I corrected the opening post and screenshot
Unfortunately at this moment translations for unknown and unavailable states are only available in HA frontend, so they can't be used in templates. Some refactoring is required to make it possible
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 there
Awaitng fix....
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.