I’m having a heck of a time trying to figure out how to create a statistic sensor so I can create an automation for when my Bathroom sensor detects a spike in Lumens. I want to detect a sudden spike over the last few seconds or minutes not hours as the spread is too much. I have tried
- This doesn’t work for me since the sensor does not always report back frequently and this causes the template to go “unavailable”. When the sensor does report a change it does not spike the template as expected, instead it reports 0 until another change is detected.
state_characteristic: change
max_age:
minutes: 1
- This doesn’t work for me since the sun will actually cause it to go above my threshold over the 1 to 2 hour timeframe
state_characteristic: change
max_age:
hours: 2
So my ask is, how can I create this sensor over a few seconds, there it doesn’t go “unavailable” and can detect a sudden (100lx) spike in lumens?
sensor:
- platform: statistics
name: "Bedroom Bath Illuminance Delta"
entity_id: sensor.bedroom_bath_sensor_illuminance
state_characteristic: change
max_age:
hours: 2
precision: 1