History Stats for how long a value of a input_number was over X

Hey Guys,

I am trying to display a history stats counter for a specific input_number. I’d like to showcase for how long for the current day, week, month and year the input_number was larger value X

I am unsure on how to accomplish this since the examples i’ve seen with history_stats only show examples with a boolean on/off scenario.

Can you help me out here?

Thanks!

The history stats integration uses the state values in the recorder database, which only goes back 10 days by default.

https://www.home-assistant.io/integrations/history_stats/#time-periods

happy to report i solved my initial isse: :slight_smile:

created a new template sensor:

  • binary_sensor:
    • name: “Value over 1500”
      state: “{{ ((states(‘sensor.tasmota_powerstation_output_energy_power’) |int + states(‘sensor.pv_speicher_einspeisen_energy_power’) | int ) > 1500) }}”

then used a history stats sensor like this:
sensor:

  • platform: history_stats
    name: E-Heizung EG an (heute)
    entity_id: switch.e_heizung_eg
    state: “on”
    type: time
    start: “{{ now().replace(hour=0, minute=0, second=0) }}”
    end: “{{ now() }}”

what’s missing now is how to retain that information cumulative for ever (yes) like the history stats in the energy dashboard.

how can i prolong this entitiy with daily stats for lets say 3 months, hourly stats for 6 months and monthly stats forever?