ESPHome, Filter out bad dallas temp readings

I have an ESPHome installed in my pool controller box. Connected to it I also have a dallas temp sensor. A couple times a week I get a bad reading, its spike at 185F. I’m sure it from the electrical interference in the panel.

I was wonder how I could add a filter to my sensor to not transmit any reading above 50c or 122f

  - platform: dallas
    address: 0x130516A1A2C9FF28
    name: "Pool Temperature"
    filters:
    - lambda: return x * (9.0/5.0) + 32.0 + 0.1;
    unit_of_measurement: "°F"

Well that reply was of no help.

But for anyone looking for a way to only send data within a range here’s what I was able to come up with

  - platform: dallas
    address: 0x130516A1A2C9FF28
    name: "Pool Temperature"
    unit_of_measurement: "°F"
    filters:
    - lambda: |-
        float MIN_VALUE = 1.0;
        float MAX_VALUE = 50.0;
        if (MIN_VALUE <= x && x <= MAX_VALUE) return x * (9.0/5.0) + 32.0 + 0.1;
        else return {};

I used “* (9.0/5.0) + 32.0 + 0.1” only convert to Fahrenheit, so just remove that calculation.

3 Likes

There’s also this filter you can use in home assistant: https://www.home-assistant.io/integrations/filter/#outlier

1 Like

185.000000 F or 85.000000 C may also indicate a wiring error.

When using the parasite power mode (only 2 wires going to the sensor), the VDD pin must be tied to ground.

Well I did post the url of the sensor filter documentation, which is what you used.

Ungrateful, we get used to it here.

Thanks for sharing.

So you can return a “empty” value in the filter lambda.
I didn’t know that. I have another issue but this will solve my problem.

I have only used the filter_out in esphome but it only filter out one value.

Thanks for that tip Tom, that would have worked too!
I guess I already had a lambda calculation there so I decided to add o it.

Yes it is a wiring error being sent from the sensor. It only happens like 1-2 times a week. I’m 99% sure it’s electrical interference from the 220v panel it’s installed in.

The error is rare and not a big deal, but it messes up the history graph.

Yes you can, the above works and doesn’t send a value, so nothing is recorded/reported.

Your original reply didn’t contain a signal word. In addition how would one setup the sensor, if they didn’t read the instruction on how to setup the sensor or converting temperature? So yes you are correct that is the document I originally used to set up my sensor prior to asking for additional help, but there is not an example there on how to filter out a range of readings.
I’m positive you know much more about HA and coding than I do, so a little of your knowledge here would have been appreciated is all, just like every other poster here did.

1 Like