This morning I discovered that some filters I have processing remote esphome sensor data went offline which I eventually determined was from NULL data values that were somehow stored as sensor state values into the sqlite database during or shortly after a brief network/power outage.
The HA log at startup showed reason due to: TypeError: float() argument must be a string or a number, not 'NoneType’
I deleted the NULL values via SQL and the filter came alive working again. I’ve been running these filters like this for many months without and issue even after many other network and power glitches.
So I’m wondering … there is a way to configure filters to ignore any NULL values that somehow make it into the database? This would be the easiest and most assured way for me to test as I’m not sure how to duplicate this problem at the source. If that’s not feasible I’ll look into templating the data first to strip out any null values and figure out a way to confirm that it is indeed doing the job.
Here’s one of the filters:
- platform: filter
name: "filtered smoke detector1 sensor voltage"
entity_id: sensor.smoke_detector1_sensor_voltage
filters:
- filter: outlier
window_size: 3600
radius: 0.2
- filter: lowpass
time_constant: 15
precision: 2
And here’s the sql I used to rid the NULL values:
SQL> delete from states where entity_id = 'sensor.smoke_detector1_sensor_voltage' and state is null;
thanks