YAML and Jinja Templating Course Episode 6: Counting your lights
HTML-код
- Опубликовано: 2 авг 2024
- Here's episode six of this YAML and Jinja programming course! In this episode of our Jinja and YAML course, we'll cover how you can filter data in Home Assistant and count the lights that are on in your house. Learn how Jinja works and how to use it in Home Assistant with this tutorial!
⭐ You can download all the code that I created for the course at: ko-fi.com/s/84ab3c5875 ⭐
Links referred to in this video:
* The YAML and Jinja Course Playlist: • YAML & JINJA Templatin...
Blog version: www.smarthomejunkie.net/yaml-...
⭐⭐⭐
* Join this channel to get access to perks: 📺 / smarthomejunkie
* Please consider becoming my patron 🏅 at / smarthomejunkie
* Or please support me by buying me a ☕ at ko-fi.com/smarthomejunkie/
* Or sponsor me through PayPal at paypal.me/smarthomejunkie
⭐⭐⭐
⭐ If you want me to create a review of your product, please visit this page for information and rates: www.smarthomejunkie.net/revie... ⭐
My Devices: github.com/smarthomejunkie/My...
Instagram: / smarthomejunkie
X: www.x.com/smarth0mejunkie
Mastodon: mastodon.world/@smarthomejunkie
Facebook: / smarthomejunkie
TikTok: / smarthomejunkie
Discord: / discord
00:00:00 Introduction
00:01:28 Counting all the lights in your house
00:05:03 How many lights are on in the house?
00:06:27 Bloopers
#homeassistant #jinja #yaml #templates #templating #programming #filterdata #countlights #tutorial Хобби
Let me know how many lights you have in your house!
Only 15 lights (a lot are dumb bulbs controlled by switches ... 61 switches) but I do have 622 sensors
Took some time to add the labels, I have 87 legitimate lights :-)
So it turns out I have 210 light entities 😂. Rather than reject those that I didn't want, I created a Label 'Light Group', assigned that to all the lights I wanted to count and selected those that are on. This gives me 27 total lights. Some of those are light fittings with multiple luminaires, but I don't want to count all the individual luminaires. Another really good walk through thanks. Labels are proving to be really useful.
Another awesome video in the series. These videos have been really help full to me. Keep up the good work. I have 47 lights in my setup
Another educational video. However, there is so much more to tell about Jinja. Please continue this series.
That's a very useful video, I really like the approach of using labels.
Could you give any examples of using 'browser mod' to click on a dashboard icon that shows your 'Lights On' count that then brings up a sub-view listing the light names?
Another great video!
Thanks again, it really does open up endless possibilities.
One thing I've recently been doing is wrapping this up in a script and passing the label as a variable, so I can ask the same question but for various devices (again all mainly learned from your videos)!
I really think you've found your niche in these videos, nothing really out there that helps explain the art of the possible in a simple way! Thanks so much
as always brilliant ❤
I advise everyone to go immediately to ko-fi👌
Thank you for your support 🙏🏻
Fantastic tutorial. I changed my kludgy method of counting numbers of doors and windows opened and closed in my security system into two elegant code lines! Thank you!
My device battery monitor sensor is now 6 lines of code instead of 64
My leak sensor code is 4 lines I stead of 32
Awesome! I will try to add some extra functionality in the next episode.
@@SmartHomeJunkie using the label is really brilliant. If I add a new device I just have to add the label to it and it's automatically included. No code change to the sensor or automations!
@@desertaip9137 Yes, it is. I must say that TheFes helped me with the idea!
64 is a boat load of smart lights! We have only have 34, with maybe 10 more that could be made smart.
I have about 24 lights a mix of smart bulbs & Smart switches. According to Mushroom overview 12 are on.
I definitely appreciate these territorials and look forward to more, thanks.
But, the example case seem very silly. If I'm leaving the house and wanted to know if any lights were on, I would rather see where/what light not just a number of lights that are on anywhere in my house... Then have to go find where/what light/s are on because it only tells me "x6 lights are on in the house somewhere".
Seems way more logical to have all lights grouped by rooms they are in then check and report what group is still on when leaving.
eg, lounge group on means that a light/s is on in the lounge then, hit the 'turn off lounge lights button' - knowing how many lights are on is pointless.
That being said, you can set up automation to check when house goes to unoccupied state and turn off lights automatically, making it a truly smart home.
If there are specific lights you like to stay on when away, then create a boolean input 'away lights stay on' and configure the automation to turn off all lights except these specific lights if 'away lights stay on' is on.
So. Just add a filter for your area and only the lights in that area are taken into account. I think you can do it yourself based on the tutorials in this series.
👍
Perfect timing - I was looking how to show how many lights are on within a dashboard. Is it possible to show the names of which ones have the state = ON in a dashboard?
I'll try to add that request to the next video.
Great video as usual! Thanks for all the work you do!
My lights in the house are a mix of light and switches domains. The use of labels is genius and was able to label all entities that are actually lights (either bulbs, switches (L/R), led strips).
But i cant figure out how to add the switch domain list with the light domain list before i start filtering for labels and then state.... can you show us how to?
You can use the "change device type of a switch " helper to turn a switch into a light so that it will be recognized as being part of a light domain.
@@SmartHomeJunkie omg that's perfect, thanks! ❤️
please add this episode to your jinjia2 playlist, which seems to have only till 5th episode
Hey, thanks for pointing that out! I'll get the missing episode added to the jinjia2 playlist pronto.
Great video, Thanks!
I've some relays in my home wich are not indicated with "light." but with "switch." is it possible to add those?
Yes, you can. Use the "Convert device type of a switch" helper to convert your switches to lights.
@@SmartHomeJunkie Never knew that, thanks!! :D
@@Niels-e3z No problem
Hi there, Nothing to do with this, but was looking for a way to bui build / store a LIST of items (like the last 5 phone numbers + timestamp) - using an helper ?? Then HOW to display that list on a dashboard ? This would be for a project to display missed calls on my dashboard ... many thanks !
I'll try to add this to a future episode.
How do I take this one step further and count only the lights on in a specific area?
{{ states.light | selectattr('entity_id', 'in', area_entities('Kitchen')) | list | count }}
I got stuck trying to count the lights on for a selected room - what to you select there?
{{ states.light | selectattr('entity_id', 'in', area_entities('Kitchen')) | list | count }}