core icon indicating copy to clipboard operation
core copied to clipboard

state_translated() behavior on 'unknown': not translated

Open Mariusthvdb opened this issue 1 year ago • 8 comments

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

Scherm­afbeelding 2024-03-12 om 13 25 20 Scherm­afbeelding 2024-03-12 om 11 14 37

Mariusthvdb avatar Mar 12 '24 10:03 Mariusthvdb

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 close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign template Removes the current integration label and assignees on the issue, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue.
  • @home-assistant remove-label needs-more-information Remove 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)

home-assistant[bot] avatar Mar 12 '24 10:03 home-assistant[bot]

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')}}

Petro31 avatar Mar 12 '24 11:03 Petro31

my apologies, I corrected the opening post and screenshot

Mariusthvdb avatar Mar 12 '24 12:03 Mariusthvdb

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

PiotrMachowski avatar Mar 13 '24 17:03 PiotrMachowski

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

PiotrMachowski avatar Jun 11 '24 21:06 PiotrMachowski

Awaitng fix....

gadulowaty avatar Jun 18 '24 09:06 gadulowaty

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.