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
  • ХоббиХобби

Комментарии • 37

  • @SmartHomeJunkie
    @SmartHomeJunkie  Месяц назад

    Let me know how many lights you have in your house!

    • @PosiCat
      @PosiCat Месяц назад

      Only 15 lights (a lot are dumb bulbs controlled by switches ... 61 switches) but I do have 622 sensors

    • @desertaip9137
      @desertaip9137 23 дня назад +1

      Took some time to add the labels, I have 87 legitimate lights :-)

  • @daveforrester61
    @daveforrester61 День назад

    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.

  • @emms-place
    @emms-place Месяц назад +2

    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

  • @edwaaij4752
    @edwaaij4752 Месяц назад

    Another educational video. However, there is so much more to tell about Jinja. Please continue this series.

  • @jfs43
    @jfs43 Месяц назад +3

    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?

  • @robertdon-duncan7954
    @robertdon-duncan7954 Месяц назад +1

    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

  • @sevagjb
    @sevagjb Месяц назад +2

    as always brilliant ❤
    I advise everyone to go immediately to ko-fi👌

  • @desertaip9137
    @desertaip9137 24 дня назад +1

    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

    • @SmartHomeJunkie
      @SmartHomeJunkie  24 дня назад +1

      Awesome! I will try to add some extra functionality in the next episode.

    • @desertaip9137
      @desertaip9137 23 дня назад +1

      @@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!

    • @SmartHomeJunkie
      @SmartHomeJunkie  23 дня назад

      @@desertaip9137 Yes, it is. I must say that TheFes helped me with the idea!

  • @major_west
    @major_west Месяц назад

    64 is a boat load of smart lights! We have only have 34, with maybe 10 more that could be made smart.

  • @grahamshaw5531
    @grahamshaw5531 Месяц назад

    I have about 24 lights a mix of smart bulbs & Smart switches. According to Mushroom overview 12 are on.

  • @birddroppings32
    @birddroppings32 Месяц назад

    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.

    • @SmartHomeJunkie
      @SmartHomeJunkie  Месяц назад

      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.

  • @joncentel4932
    @joncentel4932 Месяц назад +1

    👍

  • @wwolfram33
    @wwolfram33 Месяц назад

    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?

    • @SmartHomeJunkie
      @SmartHomeJunkie  Месяц назад +1

      I'll try to add that request to the next video.

  • @danielshiloah1485
    @danielshiloah1485 Месяц назад

    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?

    • @SmartHomeJunkie
      @SmartHomeJunkie  Месяц назад +1

      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.

    • @danielshiloah1485
      @danielshiloah1485 Месяц назад +1

      @@SmartHomeJunkie omg that's perfect, thanks! ❤️

  • @squalazzo
    @squalazzo 20 дней назад

    please add this episode to your jinjia2 playlist, which seems to have only till 5th episode

    • @SmartHomeJunkie
      @SmartHomeJunkie  20 дней назад +1

      Hey, thanks for pointing that out! I'll get the missing episode added to the jinjia2 playlist pronto.

  • @Niels-e3z
    @Niels-e3z Месяц назад

    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?

    • @SmartHomeJunkie
      @SmartHomeJunkie  Месяц назад +1

      Yes, you can. Use the "Convert device type of a switch" helper to convert your switches to lights.

    • @Niels-e3z
      @Niels-e3z Месяц назад +1

      @@SmartHomeJunkie Never knew that, thanks!! :D

    • @SmartHomeJunkie
      @SmartHomeJunkie  Месяц назад

      @@Niels-e3z No problem

  • @cedricdelecole3964
    @cedricdelecole3964 Месяц назад +1

    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 !

  • @adamfritzsche
    @adamfritzsche 26 дней назад

    How do I take this one step further and count only the lights on in a specific area?

    • @desertaip9137
      @desertaip9137 16 дней назад

      {{ states.light | selectattr('entity_id', 'in', area_entities('Kitchen')) | list | count }}

  • @bennopuetz206
    @bennopuetz206 Месяц назад

    I got stuck trying to count the lights on for a selected room - what to you select there?

    • @desertaip9137
      @desertaip9137 23 дня назад

      {{ states.light | selectattr('entity_id', 'in', area_entities('Kitchen')) | list | count }}