Lovelace dashhoard card help

I am getting below cell voltage values from my inverter. Displaying entity value in a card on dashboard seems easy. I am not sure how to do any mathematical formula etc using entities. I like to do the following, any help / advice appreciated.

  1. Round the below voltage to 3 decimal
  2. Display the smallest (minimum) value
  3. Display the largest (maximum) value
  4. Display the different of the largest vs smallest (largest - smallest)
    i would be displaying 2, 3 and 4 in a separate card.

You cant do this in Lovelace. You would need to either adjust the value_template in the integration you are using to obtain these readings if it supports one. If it does not you need to make template sensors.

i cannot change the entity data i am getting via mqtt, if i have to achieve this in HA how would you advice?

So they are discovered mqtt sensors, not defined in YAML?

In that case:

1 Like

Thanks Tom,

they are in yaml, example below. Thanks will check the template example.

  - platform: mqtt
    name: "jkbms_VoltageCell01"
    state_topic: "homeassistant/sensor/jkbms_VoltageCell01"
    unit_of_measurement: "V"
  - platform: mqtt
    name: "jkbms_VoltageCell02"
    state_topic: "homeassistant/sensor/jkbms_VoltageCell02"
    unit_of_measurement: "V"

Can you please format your pasted config correctly as per point 11 here.

thanks Tom, updated above

i tried tried rounding within the sensor topic, below obviously didnt works, is there a way to achieve the rounding within the sensor yaml below or will i have to make a template for each of my 16 sensors

thanks

  - platform: mqtt
    name: "jkbms_VoltageCell01"
    state_topic: "homeassistant/sensor/jkbms_VoltageCell01 | float | round(3)"
    unit_of_measurement: "V"

Like this:

  - platform: mqtt
    name: "jkbms_VoltageCell01"
    state_topic: "homeassistant/sensor/jkbms_VoltageCell01"
    value_template: "{{ value|round(3) }}"
    unit_of_measurement: "V"
1 Like

it worked, thanks

I have customized the card by rounding.

I would like to highlight the cell with the highest voltage in this card, either with color, changing icon or some other means. i would like to do the same for the cell with the lowest voltage.

I am looking at how to achieve something similar with templates but i cant get my head around it, any tips / ideas appreciated.

Not exactly what you are after but this card can sort and colour by state: