benct / lovelace-multiple-entity-row

Show multiple entity states and attributes on entity rows in Home Assistant's Lovelace UI
MIT License
813 stars 63 forks source link

Sensor precision not respected #286

Open Wesley-Vos opened 1 year ago

Wesley-Vos commented 1 year ago

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.

TheQue42 commented 1 year ago

@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.

Wesley-Vos commented 1 year ago

@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.

ildar170975 commented 1 year ago

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

sargue commented 1 year ago

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.

Wesley-Vos commented 1 year ago

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.

ildar170975 commented 1 year ago

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

antgustech commented 1 year ago

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.

ildar170975 commented 1 year ago

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

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

antgustech commented 1 year ago

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

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

Never mind, read the type. 🤦‍♂️

ildar170975 commented 1 year ago

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.

antgustech commented 1 year ago

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.

ildar170975 commented 1 year ago

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

bcutter commented 1 year ago

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

mill1000 commented 1 year ago

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

darrenfreeman commented 11 months ago

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.