How do I fix my unavailable Change sensor?

I set up a change sensor to use with my rain gauge years ago. The rain gauge is cumulative until it randomly resets so the change sensor was the best thing I could come up with.

Recently I broke it by trying to figure out a way to filter out the resets to 0 which caused big negative swings in the change sensor. I couldn’t figure it out myself, I used a LLM to help, still couldn’t get it to work so I reverted to my original config, but the change sensor never started working again.

Can someone help be figure out what I broke?

mqtt.yaml

sensor:
      - name: "Percipertation"  
        state_topic: "rtl_433/Acurite-Rain899/5218"
        unique_id: "percipertation"
        unit_of_measurement: "in"
        state_class: total_increasing
        device_class: precipitation
        force_update: true
        value_template: " {{ value_json.humidity | is_defined  }} "

Sensor.yaml

  - platform: statistics
    name: "precipitation change"
    entity_id: sensor.percipitation
    state_characteristic: change
    max_age:
        minutes: 2
    sampling_size: 4
    precision: 2
    unique_id: "precip1_change"

What do you want?

Rain per day?

Feed the 433MHz rain sensor to a utility meter with a daily cycle. It will ignore the resets and and only count the increases.

If you want a cumulative sensor that never resets then don’t define the cycle option.

I have that for hourly, daily, weekly, monthly etc, but I am also feeding into Influx/Grafana dashboard with a bunch of other stuff which just sums the results of the change sensor.

You could use another utility meter with cron: "*/2 * * * *" that will give you the same as your stats change every 2 minutes sensor.

But if you really want to keep the change sensor then you need to explain what you mean by this:

Does the entity not get created or is it just that the state is unavailable?

Search for “sensor.precipitation_change” in Developer Tools → States. What do you see?

Apologies for not including the correct information sooner. Here is the source sensor:

This is the change sensor:

Make sure there is no sensor.precipitation_change_2 sensor.

If there isn’t, then has the source sensor changed?

The change sensor will only change when the source sensor does.

There is no change_2.

I thought the force_update: true in the sensor would grab the value reported from mqtt every time and the change sensor would just report a 0 if there was no change.

I swear that is the behavior of the past.

Looking at grafana, the change used to report zero or at least something grafana could sum. Then once the change sensor went unavailable, the data source was no longer valid.

From your sensor.yaml:

According to your source sensor screenshot, the entity ID is
sensor.percipertation

Yep, I am not sure what that has to do with this? I misspelled precipitation back in 2022 and never caught it haha

precipitation, percipitation, percipertation. Three different spellings. Your statistics sensor won’t work unless it refers to the correct one.

1 Like

Ah! I only noticed two different spellings. Good catch.

1 Like

:person_facepalming: :person_facepalming: :person_facepalming:
:person_facepalming: :person_facepalming: :person_facepalming:
:person_facepalming: :person_facepalming: :person_facepalming:
:person_facepalming: :person_facepalming: :person_facepalming:

I cannot believe this. Well I totally can believe I did this, but I am immeasurably embarrassed!

Its working now…Wow I feel like an idiot! Thank you @mekaneck and @tom_l for the help!

Edit: and @holdestmade made an edit to the post title because I misspelled available. I quit!

1 Like