What is wrong with my statistics sensor?

I’m trying to configure a statistics sensor to calculate the mean rainfall over the last 11 hours. But my sensor does not show up as an entity at all. No mention of it in the logs either. Configuration check is fine too.

- platform: statistics
  name: mean_rain
  entity_id: sensor.hilversum_precipitation
  state_characteristic: mean
  max_age:
    hours: 11
  sampling_size: 9999
  unique_id: rain_mean

Is it currently raining?
I believe the sensor appears when it gets data, and it can’t go back in time.

I have the configuration in place for a couple of days now. I has been raining during that time. Though atm it’s dry. Does the entity dissapear by itself after it’s empty or something?

No it shouldn’t do that.

Any related errors in your log?

No nothing there. I wish there was something.

You need to have sensor.hilversum_precipitation history & recorder.

You mean it is visible in the history tab in HA? Because sensor.hilversum_precipitation is visible there.

it just needs to be recorded, it doesn’t need to be in the history tab, however if it shows a graph in the history tab, that means it’s being recorded.

Is the sensor’s state a number or string? Easiest way to tell is if it shows up as a graph in the history tab.

It shows up as a graph.

then it should be working. Are you not seeing the entity at all or are you seeing it as unavailable?

Do you have 2 sensor sections? Do you have 2 sensors using the same unique_id?

It’s not showing up at all. I don’t know what you mean by ‘having 2 sensor sections’. All sensors I have created have unique id’s. Though I have tried the sensors without specifying the whole unique ID at all. They didn’t work then either.

And are you looking for sensor.mean_rain or sensor.rain_mean? The name and the unique id do not match.

I look for anything with mean in the name. nothing comes up.

2 sensor sections…

sensor:
- stufff

...

sensor:
- stuff

Aha. No only one sensor section:

sensor: !include_dir_merge_list ../entities/sensors

then in sensor folder two yaml files:

platform: statistics
name: median_rain
entity_id: sensor.hilversum_precipitation
state_characteristic: median
max_age:
  hours: 11
sampling_size: 9999
unique_id: rain_median
platform: statistics
name: mean_rain
entity_id: sensor.hilversum_precipitation
state_characteristic: mean
max_age:
  hours: 11
sampling_size: 9999
unique_id: rain_mean

do you have other items in config/entities/sensors that show up?

Not in that particular folder no. In other folders like ‘switches’ I do and they work perfectly.

And you’re using the same, …merge_dir_list?

to me, that path seems suspect. .. means go 1 path backwards in everything i’ve used.

Thank you! This was it. The switches was using !include_dir_list and my sensors was configured as !include_dir_merged_list So that didn’t work. Too bad configuration check did not see that one.

1 Like