Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question - Template - Status #50

Closed
olibos opened this issue Feb 1, 2023 · 6 comments
Closed

Question - Template - Status #50

olibos opened this issue Feb 1, 2023 · 6 comments

Comments

@olibos
Copy link
Contributor

olibos commented Feb 1, 2023

Hello @tijsverkoyen ,

Since #22 , my templates shows the status code instead of the readable state.
Do you know how I can "translate" those magic numbers?

{{states('sensor.inverter_1_inverter_status')}}

get: 512
desired: Grid connection

@tijsverkoyen
Copy link
Owner

Which version of Home Assistant are you using?

@GiorgioUghini
Copy link
Contributor

I think this relates with HA and not directly with this integration.
Displaying 512 instead of a string is the wanted behavior as you can interpret 512 as a state that does not change if you change localization.
See this pull request in HA core: home-assistant/core#65743

P.s.: really need to have the localization in your template? As a temporary solution you can use a custom component like this one: https://github.com/PiotrMachowski/Home-Assistant-custom-components-Custom-Templates

@olibos
Copy link
Contributor Author

olibos commented Feb 1, 2023

Hello @tijsverkoyen ,
Here is my setup:

Home Assistant 2023.2.0
Supervisor 2023.01.1
Operating System 9.5
Frontend 20230201.0 - latest

Here is a sample of my Issue:
image
With the following YAML

  - entity: sensor.inverter_1_active_power
    type: custom:template-entity-row
    secondary: |
      {{states('sensor.inverter_1_inverter_status')}}
    icon: mdi:solar-power
    name: Soleil

As @GiorgioUghini says, it's not related to your integration but more a general question.
And I agree in most scenarios it's easier to handle codes than texts but for Lovelace dashboard it's not really user friendly 🤪.

I'll try @GiorgioUghini 's workaround in the meaning time, I'll let you know if it works for me

@olibos
Copy link
Contributor Author

olibos commented Feb 1, 2023

Unfortunately, it does not solve my problem 🙁.
After installing @PiotrMachowski 's package:

Template:

Sun State: {{ states("sun.sun") }}
Sun Label: {{ ct_state_translated("sun.sun", "en") }}
Inverter State: {{ states('sensor.inverter_1_inverter_status') }}
Inverter Label: {{ ct_state_translated("sensor.inverter_1_inverter_status", "en") }}

Result

Sun State: below_horizon
Sun Label: Below horizon
Inverter State: 0
Inverter Label: 0

@PiotrMachowski
Copy link

@olibos PiotrMachowski/Home-Assistant-custom-components-Custom-Templates#1

@olibos
Copy link
Contributor Author

olibos commented Feb 2, 2023

Thank you @PiotrMachowski ,
I've installed the version 1.0.1 and it works perfectly!

Template:

Sun State: {{ states("sun.sun") }}
Sun Label: {{ ct_state_translated("sun.sun", "en") }}
Inverter State: {{ states('sensor.inverter_1_inverter_status') }}
Inverter Label: {{ ct_state_translated("sensor.inverter_1_inverter_status", "en") }}

Result: 👍

Sun State: above_horizon
Sun Label: Above horizon
Inverter State: 512
Inverter Label: Grid connection

I hope, your proposal reach HomeAssistant Core 😉. But in the meantime it's a good workaround!
Thanks @GiorgioUghini for the suggestion!

@tijsverkoyen , it could be good to mention @PiotrMachowski integration in the README to help people in the same use case.
What do you think?
If it helps, I can make a PR with some text suggestions.

@olibos olibos closed this as completed Feb 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants