Calculate average consumption of a device and alert when result exceeds limit

Probably one of the kids accidentally turned the fridge to full power, resulting in everything inside freezing solid. I do track the consumption of the fridge via a Zigbee smart plug and - of course - the changed setting shows.

How would I go about calculating an average consumption value e.g. over an hour that I could use in an automation to trigger a warning if that value exceeds a set limit?

Hey there is an average sensor for your pourpous.
Here are two of my examples (from my sensors.yaml):

- platform: average
  name: mean_outside_temp_yesterday
  unique_id: df100419-443e-4a68-a14d-c82c89177ddf
  start: '{{ now().replace(hour=0,minute=0,second=0,microsecond=0) - timedelta(days =1) }}'
  end: '{{ now().replace(hour=0,minute=0,second=0,microsecond=0) }}'
  entities: sensor.openweathermap_temperature
  
- platform: average
  name: base_energy_usage
  unique_id: a02d0459-5867-4a3f-a460-568223a1cbbd
  start: '{{ now().replace(hour=3,minute=0,second=0,microsecond=0)}}'
  end: '{{ now().replace(hour=5,minute=0,second=0,microsecond=0) }}'
  entities: sensor.gesamt_leistung
  

The first one contains yesterdays average temperature and the other one the average electricity consumption between 3 and 5 o’clock, a proxy for my baseline.

Hope this helpes.

1 Like

Awesome! Danke schön!