History_stats tracking heater usage, not working

I suggest you consider doing this:

Create a History Stats sensor that reports the current day’s total heating time.

  - platform: history_stats
    name: ULkohuone
    entity_id: switch.ulkohuone
    state: "on"
    type: time
    start: "{{ today_at() }}"
    end: "{{ now() }}"

Create Utility Meter sensors that report daily, monthly, and yearly total heating time.

utility_meter:
  ulkohuone_daily:
    source: sensor.ulkohuone
    cycle: daily
  ulkohuone_monthly:
    source: sensor.ulkohuone
    cycle: monthly
  ulkohuone_yearly:
    source: sensor.ulkohuone
    cycle: yearly

The data for Utility Meter sensors is stored in Home Assistant’s statistics table which is not purged and held indefinitely.

That’s the method I use to track heating and cooling time (and I now have over a year’s worth of data).

1 Like