I am trying to add a statistics sensor to normalize a sensor that gets updated about every minute. I would like to get a mean, as well as 24h min/max values.
It’s sensor that shows the current price of Dogecoin.
Seems pretty straightforward, however it’s not working. What am I doing wrong here?
I’m not sure what is. Looks like you have the correct configuration for the statistics sensor. Correct sampling size as well. It’s just not getting any samples. When was the last time sensor.dogecoin updated?
I really don’t think so, but I’ll try to rule it out.
This is my configuration.yaml. I added the sensor on the bottom. I haven’t used any other style of configuration in a while. This should work, shouldn’t it?
#
# The configuration.yaml is only used to bootstrap the system.
#
homeassistant:
# Load packages
packages: !include_dir_named integrations
# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:
# Uncomment this if you are using SSL/TLS, running in Docker container, etc.
# http:
# base_url: example.duckdns.org:8123
# Text to speech
tts:
- platform: google_translate
group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
sensor:
- platform: statistics
name: Dogecoin Statistics neu
entity_id: sensor.dogecoin
sampling_size: 1500
max_age:
hours: 24
Alrighty. I removed both sensors from my main config and added them here:
#
# The configuration.yaml is only used to bootstrap the system.
#
homeassistant:
# Load packages
packages: !include_dir_named integrations
# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:
# Uncomment this if you are using SSL/TLS, running in Docker container, etc.
# http:
# base_url: example.duckdns.org:8123
# Text to speech
tts:
- platform: google_translate
group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
sensor:
- platform: cryptostate
resources:
#Example of the first formula
- compare: doge-eur
name: dogecoin
- platform: statistics
name: Dogecoin Statistics
entity_id: sensor.dogecoin
sampling_size: 1500
max_age:
hours: 24
I’ll wait a bit, if any updates show up in the statistics sensor.
Well, that was unexpected. It worked, the sensor has data now.
I really do not understand why, though. I have about 100 sensors with varying platforms set up this way. Have never had an issue. Maybe there was still a typo somewhere? I’m confused now.
I did not restart Home Assistant after adding the statistics sensor to my configuration. I only clicked the reload button in the Server settings. There was no error and the sensor appeared afterwards.
But when I changed my configuration.yaml earlier, I did a full restart (just to be sure) and the sensor appeared.
I just returned to my original configuration and did a full restart. The statistics sensor works now.
This is probably a bug in Home Assistant, isn’t it?
Anyway, thanks for debugging this with me @DavidFW1960@Hellis81 and @tom_l ! I wouldn’t have found the issue otherwise!