Smart Home Analytics - Use History Stats in Home Assistant for insights and visualizations.

preview_player
Показать описание
In this video, I just scratch the surface of historical stats using the history stats platform in Home Assistant. I visualize the data using Grafana and show a use case for how I use this data. This is just a starting point so let me know in the comments if you want to see more of this type of video.
#homeassistant #integrations #historystats
Links:

Code:

Join this channel to get access to perks:

If you would like to support me:

Products I reference in my videos (Contains affiliate links)

00:00 Intro
01:25 Use Case - Fridge Power
02:18 YAML is Not Hard!
03:00 History Stats Overview
04:40 File Information
05:09 Build the Sensors. Code Ahead!
08:12 Build history_stats Code
10:35 Check Config. Restart. Check for Entities
11:32 Visualize the Data
13:04 Build Grafana Visualization
16:06 Roku App Watch Time Template
19:56 Roku App history_stats Code
21:57 Grafana Watch Time Display
22:18 Wrap Up

DISCLAIMER: Some of the links above take you to affiliate sites that may or may not pay a small commission to me. It doesn't increase the cost to you, but it does help support me in making these videos.

Want to send me something? Send it here!
Mostlychris
24165 IH-10 West
STE 217 #164
San Antonio, TX 78257
Рекомендации по теме
Комментарии
Автор

I think stats are very interesting, so, yes please, do more like this.

RonnyRusten
Автор

Super helpful video Chris. Thanks! Helps me with defining sensors, and then displaying the data. Keep up the great videos.

bill_automated
Автор

Thank you Chris, simply awesome. My yaml coding certainly isn't great, but I welcome graphs and statistics. I was a bit cautious about approaching 'watching stats'. However after sorting out my silly errors, I can now see how much I have watched on my satellite box, in additionally I will be adding my TV information for YouTube etc.

I would like to see how I can use my smart plugs to calculate my power usage, I have used attributes to see watts, ma, voltage on the plugs, but I do not know how to use the data to view KWh and to correctly use it for Historical data.

Thank you again.

davidlangley
Автор

Amazing! and yes if you can make more videos about stats it can be great !

pol-henri
Автор

Great videos as always. Appreciate you, Chris! Any chance you could share your Json file for power dashboard highlighted in this video?

TismoGaming
Автор

another informative video so yes please keep it coming. Also you touched on bringing Grafana data into lovelace dashboard, any headway on that. I stay away from Grafana because I dont want to manage multiple dashboards or have to flip back and forth between them. Same thing with Node Red it also has a dashboard piece. Anyway great job and thank you

garysteo
Автор

Thanks Chris love the video and yes I would like to see how to do more complex stats. That switches are you using on your frig and freezer?

ramdisk
Автор

I've been using this approach but issue I find with it is that 1. It consumes unnecessary storage in the database. 2. It doesn't have the data from before you added the template. Theoretically, it should be possible to store only raw sensor data and use Grafana to do all the calculations. This solves both issues because the calculation is never stored but obtained on the fly. Sadly this is quite hard to do and you need to know about Grafana's query language. For example, if you have a on/off (1/0) sensor for the TV, you can calculate how many minutes it was on each day by doing an integral over it. Then sum the integral in intervals of 24h. This requires subqueries in Grafana, but it's something like this:
SELECT SUM(timeon) FROM (
SELECT integral("value")/60 AS timeon FROM "state" WHERE ("entity_id" = 'tv_smart_plug') AND $timeFilter GROUP BY time($__interval) fill(null)
)
GROUP BY time(24h)

Unless Grafana messed up, it should be possible to implement any calculation achievable via templates... at what price though!

Автор

Statistics on motion sensors would be cool to have. And see stats on busy time in different rooms

prebenborg
Автор

very good explanation! can i put history stats in lovelace instead of grafana?

RT-eryl
Автор

Would you be able to retrieve that data and store it somewhere else in your computer or send it to an API?

lordnoiado
Автор

What’s the difference between defining a sensor under binary sensor with a template (as I do) and under platform: template as you have (8:04), just that one will return true/false and the other as on/off? I’m not being pedantic, just wondering what are the benefits of one vs the other.

MichaelBennett
Автор

Have you tested power consumption when the freezer (motor) is not running, but somebody opens the door (light is on)? Your template is firing when consumption goes over zero.

jjussi
Автор

Have you tried InfluxDB 2.0? I just built a new system and manually installed InfluxDB 2.0. The Flux query language is very different. They say it is more powerful. It appears to be modeled around streams and you can keep add stream processors.

wstrater
Автор

Please make a "time clock" how to, same concept as here with but when i walk into work and turn lights on, it clocks me in. Knowing how long ive worked with each visit, and each day I have figured out. Stacking it into weeks and last month, ive only made it as far as 'this week' and a over engineered amount of automations & inputnumbers and spun myself dizzy.

tempbmx
Автор

Many thanks for this "delicious" video!
How to calculate time of actual playing YouTube or Netflix? It has to work when state is "playing".
It is easy to leave app paused and it should not calculate to the watch time.

astronomos
Автор

Hello Chris, Do you know if I can check the state of temperature value? I want to show the amount of time a temperature sensor is above a specific value? Thanks

edwinvanwyk
Автор

Nice video, but how to access configuration.yaml in visual code through samba? I cannot install the visual code on my raspberry pi.

JoseBerruezo
Автор

Your refrigerator's spike is the defrost cycle where it heats up the freezer to evaporate frost.

JimfromIndy