24 hours calculation on house consumption

Hey, I am not a good programmer but is trying so after weeks on this I now ask for help and hope someone have the time.

I want a calculation on the kW the house is using in 24 hours on sensor.power meter.consumption.

My code :

day_kw:
unique_id: “day_kW”
friendly_name: “Day kW”
# This template calculates the used kW per day
trigger:
platform: time
at: “23:59:58”
unit_of_measurement: “kW”
device_class: power
state_class: measurement
state: “{{ (states(‘sensor.power_meter_consumption’)|float(0) / 24 )|round(2) }}”
availability: “{{ states(‘sensor.power_meter_consumption’)|is_number }}”

But it makes my sensor.difference_power_entities go dead which stands above this.

My problem is that I now have a extra sensor in configuration.yaml file which interrupt the sensor above … :frowning:

I also cant find the Day kW in Entities card … :frowning:

How do I solve this … ?

-----> I have restarted the home assistsant … :slight_smile:

See picture “below” or this :

Loads default set of integrations. Do not remove.

default_config:

#themes
frontend:
themes: !include_dir_merge_named themes

utility_meter:
energy:
source: sensor.energy_in_kwh
cycle: monthly

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

sensor:

  • platform: template

    sensors:
    syd_watt:
    unique_id: “syd_watt”
    friendly_name: “Syd Watt”
    # This template calculates the power output in Watts of the PV1
    unit_of_measurement: “Watt”
    value_template: “{{ (float(states(‘sensor.inverter_pv_1_current’)) * float(states(‘sensor.inverter_pv_1_voltage’))) }}”

    nord_watt:
    unique_id: “nord_watt”
    friendly_name: “Nord Watt”
    # This template calculates the power output in Watts of the PV2
    unit_of_measurement: “Watt”
    value_template: “{{ (float(states(‘sensor.inverter_pv_2_current’)) * float(states(‘sensor.inverter_pv_2_voltage’))) }}”

    difference_power_entities:
    friendly_name: “Hus Forbrug Watt”
    unit_of_measurement: “W”
    value_template: “{{ (states(‘sensor.inverter_active_power’) | float - states(‘sensor.power_meter_active_power’) | float) | abs }}”

    day_kw:
    unique_id: “day_kW”
    friendly_name: “Day kW”
    # This template calculates the used kW per day
    trigger:
    platform: time
    at: “23:59:58”
    unit_of_measurement: “kW”
    device_class: power
    state_class: measurement
    state: “{{ (states(‘sensor.power_meter_consumption’)|float(0) / 24 )|round(2) }}”
    availability: “{{ states(‘sensor.power_meter_consumption’)|is_number }}”

Have you tried using a utility with a day cycle for your day_kw?

Hey Tuxinator94, sorry I dont know what a utility with a day cycle is … :frowning:

I have a total kWh counter from my Huawei SmartMeter and it is this value I want to calculate every day so I know how much kWh I have been used from yesterday to today.

But how … ?

Have you tried to set up the energy dashboard?
You will get something like this:


… and this dashboard has views for daily, monthly, etc.
The data for the dashboard is coming from Huawei inverter and power meter, individual consumers of course not.