Adding static devices without entities into the energy dashboard (without HACS)

Dear Community, I have several power plugs that already track the consumption of my devices. Now I was wondering what is the best way to get devices into the energy dashboard if only the daily consumption is known. As an example my refrigerator. This one consumes 1.29 kW/h per day. What is the smartest way to integrate this? I have already created a helper and typed in the 1.29 - but how to proceed? Do I need a “utility meter”? Something like this or is it completly wrong?

utility_meter:
  daily_energy_refrigerator:
    source: input_number.energy_refrigerator
    name: Daily Energy Refrigerator
    cycle: daily

Best wishes, Anna

Hi, I have already seen this post in the forum - but I am searching a solution without the need of “HACS”. Is it also possible?

You don’t need HACS to install any third party integration or card, it just makes it easier.

Hi Tom, thank you for your answer! I was thinking more of something without a “custom_components” to just stick to the default as much as possible. How else would you implement it in HA?

The utility meter only updates when the state of the entity it is monitoring updates so you can’t use that method.

You can’t use the Riemann Sum integration to integrate power to energy either (same issue, only updates with state changes).

Not sure how you would proceed with this using only core integrations.

Oh, that’s very sad. I thought I would not be alone with my problem. But is it so fancy to implement my requirements in the standard HA? I can not believe that nobody has had the same problem… everyone has installed HACS or a custom-component?

I guess you could do it with a template sensor if you really wanted to.

This only does one state change per day, but you could modify it to rise linearly with a reasonable update interval.

template:
  - sensor:
      - name: Daily energy refrigerator
        unit_of_measurement: "kWh"
        state_class: total_increasing
        device_class: energy
        state: >
          {% set kwh_per_day = states("input_number.energy_refrigerator") %}
          {{ kwh_per_day if now() > today_at("23:00") else 0 }}

I’m doing something similar withe devices that have a constant power consumption.
I add them all together but I’m sure you could adapt this.
I have a template sensor for the power. It updates every minute because the state attribute changes.

  - trigger:
      - platform: homeassistant
        event: "start"
      - platform: time_pattern
        minutes: "/1"
    sensor:
      - name: home_calc_base_power
        unique_id: home_calc_base_power
        unit_of_measurement: "W"
        device_class: power
        state_class: measurement
        icon: mdi:flash
        state: |
          {% set consumer = {
              'shelly1':4*0.7,
              'shelly25':2*0.7,
              'shelly3EM':2*1.0,
              'shellyEM':1*1.0,
              'shellyRGBW':1*0.5,
              'shellyDimmer':2*0.7,
              'shellyPlugS':5*0.7,
              'shellyPlug':2*0.7,
              'sonoff':2*0.5,
              'tuyaBulp':1*0.5,
              'hub_sculpture':1*1.2,
              'bedroom_charger':1*0.0,
              'seantv':1*1.7,
              'traffo':2*0.0
             } 
          %}
          {{ (consumer.values()|map('float',0)|sum)|round(2) }}
        attributes: 
          triggered_at: "{{ now() }}"

Then I calculate the energy with an integration sensor, that can be used in the energy dashboard:

  - platform: integration
    name: home_calc_base_energy
    source: sensor.home_calc_base_power
    round: 2
    unit_prefix: k
    method: left

You would have to calculate the average power by multiplying your daily energy by 1000 and divide that by 24.

Hi everyone,
I want to share now my solution because this is the easiest way to implement it I guess:

template:
  - sensor:
      - name: "Refrigerator Energy"
        unit_of_measurement: "kWh"
        state_class: total_increasing
        device_class: energy
        state: >
          {% set kwh_per_minute = states("input_number.energy_refrigerator") | float /24 /60 %}
          {% set minutes = now().minute | int %}
          {% set hours = now().hour | int %}
          {% set kwh_diff = ((kwh_per_minute * minutes) +  (kwh_per_minute * 60 * hours)) | round(6) %}
          {{ kwh_diff }}

My input helper is the day consumption for my refrigerator. That’s it. I added also a daily utility meter to have a persistence. To calculate the value via minutes and hours will help when you restart HA. :wink: What do you think?

2 Likes