Hi everyone. Considering myself relatively experienced HA user, but can’t work out the following: I have defined a template sensor in YAML with several attributes. When displaying this sensor in a standard entity card, it get’s rounded down to 1 or 2 decimals (depending on the value).
Since it represents the electricity price, I want it to display always 3 decimals. Whatever I did, I couldn’t get it to work. However, when I defined the same calculation as a sensor (instead of attribute of a sensor), it does work?!
Here is how the sensor and the sensor+attribute show up in the developer tools:
But this is how they show in the entity cards:
Of course, I can easily define 5 separate sensors instead of attributes, but I just want to understand if I’m doing something wrong? Thanks.
YAML:
- name: "Utilities Price Electricity Current Full"
unique_id: utilities_price_electricity_current_full
# state_class: measurement
device_class: monetary
unit_of_measurement: "€/kWh"
state: >
{% if is_state('sensor.utilities_db_prices_current_compare_electricity', 'Dynamic') %}
...more script...
{{ (market_price + purchase_fee + energy_tax) * (1 + vat / 100) | float }}
- name: "Utilities Price Full Electricity"
unique_id: utilities_price_full_electricity
# state_class: measurement
device_class: monetary
unit_of_measurement: "€/kWh"
state: "{{ states('sensor.current_electricity_market_price') }}"
attributes:
price_full_current: >
{% if is_state('sensor.utilities_db_prices_current_compare_electricity', 'Dynamic') %}
...more script...
{{ (market_price + purchase_fee + energy_tax) * (1 + vat / 100) | float }}