I have a HX711 weight sensor and I’m trying to limit what data it returns to HA. Right now what I have below works almost all the time, however a few times a day HA will receive a crazy huge negative number like -400 for example. I am fine with, and would actually like to see actual negative numbers if they ever happen, but prevent extremes.
I tried to use the lambda - but I am confused on the order of operations of the different filter components. Does any one know what part of what’s below could be allowing (-400) through the filter? Is there something special about 0 for polynomials than needs calibration data points for negative numbers?
For reference, sensor value -140000 is about -10lbs.
sensor:
- platform: hx711
name: "Bed Weight"
dout_pin: D4
clk_pin: D3
gain: 128
update_interval: 1s
accuracy_decimals: 1
filters:
- lambda: |-
if (x >= -140000) return x;
else return {};
- calibrate_polynomial:
degree: 3
datapoints:
- -135500 -> 0
- -132500 -> 5
- -128700 -> 10
- -125500 -> 15
- -119500 -> 20
- -113600 -> 30
- -106000 -> 60
- -104000 -> 65
- -102000 -> 70
- -100000 -> 75
- -98000 -> 80
- -80800 -> 127
- or:
- throttle: 600s
- delta: 0.5