Reset sensor values at specific time

Hello all,
I want to create a power sensor to measure the current consumtion of a device.
Therefor I’m using an INA219 sensor to measure the power in W. I also have an integration sensor to get the energy value in kWh.
Now I want to have some statistics for the energy consumption on Monday, Thuesday,…, this week, last week, this month, last month, and so on.

Unfortunately I have no clue ho to implement this in my code, as I’m new to ESPHome.
Can you give me any advice?

Here is my code:

time:
  - platform: sntp
    id: sntp_time

ensor:
  - platform: ina219
    address: 0x40
    shunt_resistance: 0.085 ohm
      power:
      name: "Solar_Leistung"
      unit_of_measurement: "W"
      icon: "mdi:current-dc"
      device_class: "power"
      state_class: "measurement"
      accuracy_decimals: 2
      id: solar_leistung
    max_voltage: 32.0V
    max_current: 3.2A
    update_interval: 10s

 - platform: integration
    name: "Solar_Energie"
    sensor: solar_leistung
    time_unit: h
    unit_of_measurement: "kWh"
    accuracy_decimals: 3
    device_class: "energy"
    state_class: "total"    
    filters:
      - multiply: 0.001

Thanks for your help.
Bernd

Esphome doesn’t store any data on board. Home assistant does in the database. You can use SQL sensor to find such info.

Then you have to rather look into ha actually. The basics on the esphome side shouldn’t be more than the “Solar_Energie” Sensor the way you have it already.

You can then create various utility meters (like daily, weekly, monthly, … consumption) in ha under this link:

For a basic visualization the energy dashboard should already have you covered

More advanced stuff you need to build yourself or dig a little bit in the forum to find stuff like this for example:

1 Like