benct / lovelace-multiple-entity-row

Show multiple entity states and attributes on entity rows in Home Assistant's Lovelace UI

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Sensor precision not respected

Wesley-Vos opened this issue · comments

The new sensor precision introduced in 2023.3.0 is not respected. The full sensor value is shown instead of the rounded value.

You can reproduce it by adding a multiple-entity-row with a numeric sensor entity. In the more-info dialog of the sensor, change the precision to something non-default and observe that the full state is still shown in the multiple-entity-row.

For more information, see https://developers.home-assistant.io/blog/2023/02/08/sensor_presentation_rounding/

Edit: in the meantime, it can be fixed by adding format:precision<0-9> but in my opinion, the default precision should be used, just as it was before < 2023.3.0.

@Wesley-Vos : Trying to understand your Edit.... (since I dont have a clue how these js-plugins are coded) have you got a workaround for the issue?
(I am a bit worried that this repo isnt that active?)
Edit: Nevermind, I finally RTFM:ed properly.

@TheQue42 You have to add it to your card configuration in HA, not in the plug-in itself luckily.

For example, check out this card configuration:

type: entities
entities:
  - entity: sensor.util_energy_daily
    name: Usage today
    secondary_info: last-updated
    show_state: false
    type: custom:multiple-entity-row
    entities:
      - entity: sensor.util_energy_daily_low
        name: Low
        format: precision2
      - entity: sensor.util_energy_daily_high
        name: High
        format: precision2
      - entity: sensor.util_energy_daily
        name: Total
        format: precision2

The format: precision2 is the additional option I meant. This will do the rounding for now, until it is fixed.

I do not think that the card should use recently added precisions.
imho currently available “format” option is rather sufficient.

Perhaps in absence of any "format" option it should honor the new defined precision for the entity. We get best of both worlds: support for consistency with the new HA feature while still having the option to go with any custom format/precision.

Perhaps in absence of any "format" option it should honor the new defined precision for the entity. We get best of both worlds: support for consistency with the new HA feature while still having the option to go with any custom format/precision.

Yeah I agree! That is the best of both worlds, and is in line with the other built-in HA cards as well.

Well, it probably will be a perfect variant.
Hope one day this functionality will be added.
But as I said - not critical for me.

commented

Thanks, adding
format: precision2

Seems to work. However the docs also say we should be able to use format: number X but that does not work.

the docs also say we should be able to use format: number X but that does not work.

Where?
изображение

commented

the docs also say we should be able to use format: number X but that does not work.

Where? изображение

Never mind, read the type. 🤦‍♂️

Type of what? Consider explaining yourself, otherwise you are saying riddles.
Here "type=number" means that some formats are applied to numbers only.
Your needed format is precisionX as was said.

commented

Type of what? Consider explaining yourself, otherwise you are saying riddles.

I meant the type column in the docs. I misread it as the actual syntax.

No no, It is just an additional explanation: some formatters may be used for numbers, some for datetime.

Progress? Or is everyone happy with the applied format: precisionX (and spent already approx. 2 hours to fix everything in all views like me 😞)?

Just noticed that the latest HA release has added new methods to allow entity state formatting for custom cards.
https://developers.home-assistant.io/blog/2023/08/29/hass-format-state

Almost all of my sensors use a non-default precision, so this issue requires a lot of extra YAML, just to make the multiple entity row behave like the rest of the entity card.