lovelace-multiple-entity-row
lovelace-multiple-entity-row copied to clipboard
Numbers are formatted not accordingly to global settings
The card should use global format settings:
This card contains:
- conventional
input_number
row; -
multiple-entity-row
with the same row with different formats.
Note that:
- the conventional row displays WRONG format (frontend issue);
-
multiple-entity-row
displays WRONG format in some cases.
- type: entities
entities:
- entity: input_number.test_negative_1
name: test value
- type: custom:multiple-entity-row
entity: sun.sun
entities:
- entity: input_number.test_negative_1
name: unformatted
show_state: false
- type: custom:multiple-entity-row
entity: sun.sun
entities:
- entity: input_number.test_negative_1
name: invert
format: invert
show_state: false
- type: custom:multiple-entity-row
entity: sun.sun
entities:
- entity: input_number.test_negative_1
name: kilo
format: kilo
show_state: false
- type: custom:multiple-entity-row
entity: sun.sun
entities:
- entity: input_number.test_negative_1
name: precision
format: precision4
show_state: false
- type: custom:multiple-entity-row
entity: sun.sun
entities:
- entity: input_number.test_negative_1
name: position
format: position
show_state: false
Now, lets choose "None" format:
The card now shows RIGHT format:
See https://github.com/benct/lovelace-multiple-entity-row/pull/212#issuecomment-997214320 and following. Might be related to the same root cause.
Introduced with v4.3.0 I think.
Guess I missed numberFormat
on invert
and position
. Anything else?
Anything else?
No, I think only these two options are with problems.
Confirm (Win10x64, Chrome):
The conventional entity-row has wrong format (frontend issue).
Have a look at https://community.home-assistant.io/t/multiple-entity-row-card-local-number-formatting-update-broke-view/370718 for examples when this local number awareness feature is going too far.
Here is one more issue - again formatting does not work.
There are 2 sensors from systemmonitor
:
- sensor.memory_free
- sensor.memory_use
This sensor is a sum of those sensors:
- platform: template
sensors:
memory_total:
unit_of_measurement: MB
icon_template: mdi:chip
value_template: >-
{% set FREE = 'sensor.memory_free' -%}
{%- set USE = 'sensor.memory_use'-%}
{{ ((states(FREE)|float) + (states(USE)|float)) | round(1) }}
And here is a card:
- type: entities
entities:
- entity: sensor.memory_free
- entity: sensor.memory_use
- entity: sensor.memory_total
- type: custom:multiple-entity-row
entity: sun.sun
entities:
- entity: sensor.memory_free
name: free
- entity: sensor.memory_free
name: free
unit: false
- entity: sensor.memory_use
name: use
- entity: sensor.memory_total
name: total
unit: false
- entity: sensor.memory_total
name: total
show_state: false
The same value is displayed differently if it is w/o unit:
My guess that it could be connected to using round(...)
function in value_template
.
Current settings:
Not quite sure how to fix this, as the problem lies in HA's compute_state_display
function which uses formatNumber
on states that have a unit_of_measurement
or state_class
. Removing or having no unit prevents it from running the formatting.
Potential workaround while I figure this out:
-
unit: false
if you dont want the value formatted -
unit: ' '
if you need the formatting
I think that unit: false
is not the same as "no unit_of_measurement is specified": the 1st is a frontend setting (display the unit or not), the 2nd is a core system stuff.
Probably this function should not depend on frontend setting...
2023.5.4, still same issue with a template sensor:
- with UoM
- when this UoM is not displayed (
unit: false
) - round(1) is used in a sensor.