Sum helper entity is unknown

I created a sum entity helper that sums all my daily energy entites but i get unknown. Ive tried adding and removing certain entities but it’s always unknown no matter what

i get an error that the units dont match but how would i get all entites to be kWh? seems like the units is set automatically

Do the units change during the day or they remain the same no matter the energy consumption?

it stays the same. I have a garage outlet entity for example and that’s in kWh but it’s total increasing. I made a utility meter helper off that entity but it automatically converts to Wh

image

I think you could use a Template Sensor to track what you need.

For exemple if you have multiple sensors with different units and their state is a string, let’s say like these:
charger = “0.001 kWh”
living_room = “40.41 Wh”
dehumidifier = “2717 kWh”

The template sensor will be

{{ (charger.split(' ')[0] | float) + ((living_room.split(' ')[0] | float) / 1000) + (dehumidifier.split(' ')[0] | float)}}

we split the string in two parts, we get the number that we need and for each we divide by 1000 if we want kWh instead of Wh where it’s needed.
The above template sensor will report 2717.04141 as its value and you can set the unit of measurement to be kWh in the configuration (see docs).

so i did this but get an error here’s the template

      {{ 
        states('sensor.m_charger_today_s_consumption') | float +
        states('sensor.l_charger_today_s_consumption') | float +
        states('sensor.washing_machine_today_s_consumption') | float +
        states('sensor.crawlspace_dehumidifier_today_s_consumption') | float +
        states('sensor.dehumidifier_today_s_consumption') | float +
        states('sensor.daily_living_room_purifier') | float +
        states('sensor.daily_refrigerator') | float +
        states('sensor.daily_server_rack') | float +
        states('sensor.daily_office_pc') | float +
        states('sensor.daily_garage_outlet') | float +
        states('sensor.daily_sump_pump') | float +
        states('sensor.daily_dryer') | float
      }}

which in the template developer tool i get 4406.982 which is correct but when i add as a template:

- sensor:
  - name: "Daily Electricity"
    unique_id: total_electricity
    unit_of_measurement: "kWh"
    state_class: measurement
    device_class: energy
    state: >
      {{ 
        states('sensor.m_charger_today_s_consumption') | float +
        states('sensor.l_charger_today_s_consumption') | float +
        states('sensor.washing_machine_today_s_consumption') | float +
        states('sensor.crawlspace_dehumidifier_today_s_consumption') | float +
        states('sensor.dehumidifier_today_s_consumption') | float +
        states('sensor.daily_living_room_purifier') | float +
        states('sensor.daily_refrigerator') | float +
        states('sensor.daily_server_rack') | float +
        states('sensor.daily_office_pc') | float +
        states('sensor.daily_garage_outlet') | float +
        states('sensor.daily_sump_pump') | float +
        states('sensor.daily_dryer') | float
      }}

i get TypeError: float() argument must be a string or a real number, not 'Wrapper'

Try to add to each float(0) instead of just float as a default value when sensor is not showing