t1gr0u / uv-index-card

A Lovelace card that shows a the UV index and risk level for Home Assistant
MIT License
23 stars 20 forks source link

Accuracy setting from the entity is ignored #25

Open CommanderKSK opened 1 year ago

CommanderKSK commented 1 year ago

Checklist:

Release with the issue:

Last working release (if known):-

Browser and Operating System:-

Description of problem:The card displays all 4 decimals like (7,2669) even if you set the accuracy in Home Assistant to a full number (7 in this case) it ignores this and still displays all 4 decimals.

Javascript errors shown in the web inspector (if applicable):-

Additional information: Screenshot_20230606-124349 Screenshot_20230606-124851

t1gr0u commented 1 year ago

@CommanderKSK Thank you for using the card, please read issue #13

bluediamond1984 commented 3 months ago

@t1gr0u I have read the issue and did some digging. According to the docs the formatting is controlled with rounded=True. https://www.home-assistant.io/docs/configuration/templating/#states

I have the rounded value in the developer tools with this {{ states('sensor.current_uv_index', rounded=True) }} Hopefully this helps solving this issue.

t1gr0u commented 3 months ago

@bluediamond1984 oohhh, interesting, thank you, this may help :)

hajo62 commented 1 month ago

I have the rounded value in the developer tools with this {{ states('sensor.current_uv_index', rounded=True) }} Hopefully this helps solving this issue.

@bluediamond1984: Hhm, I would need more help. Have you created a new template sensor with the rounded value or is there a way to modify the value of the original sensor?

@t1gr0u : Maybe you could add a round parameter? to your card?

bluediamond1984 commented 1 month ago

A template sensor is not needed. sensor.current_uv_index was created by the integration OpenWeatherMap. I have recently changed to OpenUV, and it works the same.

In the GUI go to the entity settings and change the display precision to desire.

hajo62 commented 1 month ago

In the GUI go to the entity settings and change the display precision to desire.

Did so an it reflects i.e. in the integrations site, but not on the card.

image

image

bluediamond1984 commented 1 month ago

I misunderstood it. I used the developer tools to see the difference in the first place. image

I have tested it with a template sensor and it's working with a rounded number.

I was trying to figure out what has to be added. I think something has to be added with this line in the code const entityState = entityId ? this.hass.states[entityId] : undefined;. But I don't understand the language.