Possible to record daily sensor data and display in a graph in HA?

Is it possible to record daily sensor data and display in a graph in HA? I have added Fitbit sleep sensors (sensor.sleep_minutes_asleep, sensor.sleep_time_in_bed, sensor.sleep_efficiency, and sensor.sleep_start_time) to HA but it only provides data from the previous nights sleep period. Is there a way to record data from each sleep period provided by Fitbit and keep that in the sqlite database and then use that data as an entity in order to provide a history graph? I’m looking to get an output of a week at a time with the amount of sleep and quality of sleep I am getting each day like what can be found at https://www.fitbit.com/sleep but have it in HA as well so that I don’t have to open up a different app for that data.

I didn’t put this into the third party integration since I figured data from other sensors could also be used in a similar way and the solution would be similar so not entirely specific to Fitbit

This might work for you, with a daily cycle and offset to reset during the day rather than overnight. You can then graph the utility meter.

1 Like

You need to include the sensors in your history integration, then the data should be stored for as long as you defined in the history integration. You could also use a DB such as influxDB to later use the data for graphs in Grafana or similar.

1 Like

If I add the Fitbit sensors to History in my configuration.yaml will it affect the other sensors already tracked by History? In other words, do I have to include all sensors I want tracked in History if I add History to my configuration.yaml?

When you just add history, it will track all entities. You can then either blacklist (all entities tracked except the ones on blacklist) or whitelist (no entities tracked except the one on whitelist) entities.

The Fitbit sensor data was available to use in a history graph on Feb 24 which was the day after my initial post. I didn’t know it couldn’t get historical data from Fitbit until it was recorded by HA.

Now, what I would like to do is get the data to show up in a bar graph with a daily count like the one in the bottom right here. He used the Utility Meter to get that data into HA. Do you think that I should be able to get a daily bar graph like that using the Fitbit sensor data without having to use the Utility Meter? I am trying to avoid unnecessary steps. I setup InfluxDB yesterday and Grafana today but I don’t know if the reason I am not getting daily data is just because I barely setup InfluxDB. All other sensors that I have provide multiple points of data within a day while the Fitbit sleep sensors are a total of the day. The other sensors that I am using for graphs only have data since InfluxDB was setup.

Did you configure the InfluxDB integration to report the sensor? InfluxDB will not read historical data as far as I know, it will start once you install InfluxDB.

I installed InfluxDB on Feb 28 and I now have Fitbit sensor data since then in both InfluxDB and Grafana without having to use the Utility Meter and without having to tell InfluxDB to report the sensor. The sensor data was already in InfluxDB and Grafana without me having to tell InfluxDB to report the sensor.

When I added a panel with the Fitbit sensor data to Grafana I had to set GROUP BY time(24h) fill(0) in order to get the graph to show a per day amount.

BTW, before I started this thread, I had already set up templates in my sensors.yaml for sensor.sleep_minutes_asleep and sensor.sleep_time_in_bed so that they show up as hours instead of minutes. Just mentioning that in case someone else wants to use the same setup.