Home Assistant 101: How to Create Virtual Switches

Поделиться
HTML-код
  • Опубликовано: 29 сен 2024

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

  • @ResinChemTech
    @ResinChemTech  Год назад +2

    Please note: In the section on creating the light brightness switches, I made a typo in the initial YAML code. It shows an entity_id of basement.light. Obviously, this is backwards and the correct value should be light.basement. The full example also shows entity_light.basement and this should read: entity_id: light.basement. Sorry about that! Please refer to the linked Gist code in the video description for full copies of the correct YAML code.

  • @Dorff_Meister
    @Dorff_Meister Год назад

    Thanks! All super helpful suggestions!

    • @ResinChemTech
      @ResinChemTech  Год назад

      Thanks... and thanks for finding the error in the YAML code I showed as an example! I've posted a pinned comment noting the error... and how the YAML should appear.

  • @RND-USA
    @RND-USA 5 месяцев назад +3

    Dude this is definitely one of the best home automation videos I’ve seen … and I’ve seen hundreds! I was expecting to just learn how to make a switch but you also answered like 20 other questions on my list to research … including that I need to build my mom a streaming tv remote controller system and now I know how to do it! Thanks so much!

    • @ResinChemTech
      @ResinChemTech  5 месяцев назад

      You are welcome. Glad you found the video helpful and hopefully I saved you a bit of additional research time.
      Thanks for watching and leaving a comment.

  • @christophe_de_pauw
    @christophe_de_pauw 14 дней назад

    Thanks for this very clear video! I’d like the idea of using virtual switches for scheduled tasks, but our schedule changes a lot 😊 is it possible to a appointment in a Google calendar,with a certain word in the subject, to trigger an automation?

    • @ResinChemTech
      @ResinChemTech  13 дней назад

      Take a look at the Google calendar integration. I think that you can do what you want by adding that. www.home-assistant.io/integrations/google/

  • @steffie.morris
    @steffie.morris 3 месяца назад

    Tnx for the video.
    I just tried this in the latest Home Assistant in Docker, and my error is: This entity ('switch.namexxx_testroom_switch1') does not have a unique ID, therefore its settings cannot be managed from the UI.
    From the manual i can't really see what i need to do to overcome this. I did try creating different virtual switches with much longer names but that didn't make a difference.

    • @ResinChemTech
      @ResinChemTech  3 месяца назад

      Entities created without a unique_id cannot be edited or managed using the UI and only through YAML. You can add a unique_id when originally creating certain types of entities (template, MQTT, etc.). I include unique ID for automations and scripts so that I can use the debug tools, but since I do nearly everything in YAML and don't use the UI, I generally don't include unique_ids for my manually created entities.
      See this for more info: www.home-assistant.io/faq/unique_id/

  • @BELSERVICEMAN
    @BELSERVICEMAN Год назад +1

    I will end up coming back to this video again and again I am sure. I don’t make use of dashboards as much as others so some of this will come if and when I add kiosks but the Roku one might get used sooner here.
    Nicely done and good job with the dual screen action, so clear and the code in bright fluorescent made it really easy to read!

    • @ResinChemTech
      @ResinChemTech  Год назад

      Thanks! Unfortunately, as noted in my pinned comment, I made a couple of typos in the process of creating the YAML in a slide presentation so that I could show it in a more readable format, instead of showing the actual YAML from Home Assistant.
      But thanks for the feedback!

  • @ngoctaiquach3144
    @ngoctaiquach3144 3 месяца назад

    I created the switch.yaml file; Add the code and change the entity name according to your instructions; Restart home assistant. But no entity of the form "switch.sw_...." like yours was found. Please help. Thank!

    • @ResinChemTech
      @ResinChemTech  3 месяца назад

      It's a bit difficult to know exactly what is wrong from the information you provided, but it appears you have an issue with trying to use an entity name in your YAML that doesn't exist or isn't defined elsewhere. Note that the YAML that I show is just an example... it isn't meant to be used 'exactly' as shown because your Home Assistant (and entities) will be different from mine.
      I'd recommend that you review your YAML and check all the entity names. All entity names must already exist or be defined elsewhere if you are referencing them somewhere else, like in a templated sensor or automation.

    • @ngoctaiquach3144
      @ngoctaiquach3144 3 месяца назад

      @@ResinChemTech I understand what you say. I changed my entity in but it still doesn't work. Thank you very much for your positive feedback.

    • @ngoctaiquach3144
      @ngoctaiquach3144 3 месяца назад

      My configuration in YAML failed.
      switch:
      platform: template
      switches:
      lights_sonoff_100:
      value_template: "{{ is_state_attr('light.sonoff', 'brightnees', 225) }}"
      turn_on:
      service: light.turn_on
      target:
      entity_id: light.sonoff
      data:
      brightnees: 255
      turn_off:
      service: light.turn_off
      target:
      entity_id: light.sonoff
      Then I added to Template section in developer tools
      "{{ is_state_attr('light.sonoff', 'brightnees', 255) }}" to test. I get the following response:
      "Result type: boolean
      false
      This template listens for the following state changed events:
      Entity: light.magic"
      I don't know where I went wrong. Please help. Thanks!

    • @ResinChemTech
      @ResinChemTech  3 месяца назад

      I cannot tell if something is wrong with the formatting, but one thing is that you have the word 'brightness' misspelled. Correct and replace every instance of 'brightnees' above with 'brightness' and see if that resolves the problem.

  • @eugsmiley
    @eugsmiley Год назад

    6:40 "You see from my lights_100..." The service light.turn_on has a data attribute "brightness_pct" which would allow you to also change the 'data: brightness 255' to 'data: brightness_pct: 100'. Now I need to figure out is that works as an attribute that can be tested in a template.
    One question. How does your "Show Standard Switches' switch change the switch for the cards?
    I love the hexagon light. Thanks for linking to the build video.

    • @ResinChemTech
      @ResinChemTech  Год назад +1

      I don't think that brightness_pct is an attribute for a light entity (at least it doesn't show up for my basement lights... only the brightness attribute with a value of 0-255). But you can always use the states page of the developer tools. Turn on the light in question and you'll see the available attributes listed. I think the brightness_pct service data really just converts to an actually brightness value and is a convenience... so setting brightness_pct in a service call to 50% actually sends a brightness of 128 (but I can't say 100% for sure that is the case).
      The "Show Standard Switches" is just something I did for the video to show that you can use standard switches instead of the custom button card. The two different card types (custom button vs. standard) are each in a series of conditional cards. Flipping that switch just causes one set of conditional cards to be hidden and the other set to show. I actually covered the use of conditional cards in my most recent video ( ruclips.net/video/rPPWcENqCNo/видео.html ).
      Thanks for the compliments on the hexagon lights. As I mention in that video, there are a few things I'd do differently if I were to do it again, but they turned out pretty well. They look better in person than they do in the video, as it is always difficult to film LEDs since they tend to overwhelm the camera... I have to turn the brightness down to like 5% which makes them tend to wash out a bit.
      Thanks for watching. Don't hesitate to reach back out if you have any additional questions.

  • @cowfeet1
    @cowfeet1 Год назад

    Great video. I'm using a boolean switch as a medicine reminder. If i haven't pressed the "medicine" button in the bathroom or on the dashboard before 7 a.m. / p.m. I'm getting a telegram reminder and some flashing lights.

    • @ResinChemTech
      @ResinChemTech  Год назад +1

      Another great use case! I use input_booleans a lot (for a lot of other things than I showed in the video). I like them use them to disable or enable things like voice notifications, auto-lighting situations, etc. While I could enable/disable the automations themselves, I often have situations where multiple automations might be involved (like voice notifications, where I probably have at least a dozen different automations). By using the input_boolean in a condition for these automations, I just have a single button/toggle to switch to disable or enable all the related automations.
      But thanks for sharing another good idea!

  • @maksymborodin6219
    @maksymborodin6219 Год назад

    Thank you for your new video. What branch of wall switch do you use at 8:35 and how did you integrate it with HA?

    • @ResinChemTech
      @ResinChemTech  Год назад

      It is a Teckin smart dimmer switch, but I don't believe they are made anymore... and even if they are, many of these light switches and dimmers are no longer flashable with custom firmware. I stocked up on a whole crate of dimmers, switches and plugs before the change to the new chip occurred so that I would have them for future needs.
      It is flashed with custom Tasmota firmware, which has both a native local integration in Home Assistant or can be integrated manually using MQTT (which is the way I did it). There are still some switches, plugs and dimmers that are flashable with custom firmware like Tasmota or ESPHome or there are a few companies (Athom is one) that sell these devices pre-flashed with Tasmota.
      Hope that info helps.

  • @Shaq2k
    @Shaq2k Год назад

    Excellent! A video on how to create a custom card with a drop down list for all the effects in WLED would be much appreciated

    • @ResinChemTech
      @ResinChemTech  Год назад

      Well, I don't think you can do a drop down list with the particular custom card I'm using in this video. However, the new standard light entity card in Home Assistant has a button that can be clicked to get a drop down list of WLED effects. In addition, there is a custom light entity card available in HACS that also provides a drop down list of WLED effects. You can find info on that here: github.com/ljmerza/light-entity-card

  • @rodneysmith1750
    @rodneysmith1750 Год назад

    Great new video, your videos are very entertaining, well-presented, and thoughtful!

  • @Leconcasseur
    @Leconcasseur Год назад

    Hey cool vid and i have a question , on what hardware do you run your HA server and what do you think is the most efficient way to have a little HA server

    • @ResinChemTech
      @ResinChemTech  Год назад +1

      Thanks! Like most, I started on a Raspberry Pi. But after about a year, I upgraded.. then upgraded again! I'm currently hosting Home Assistant in a Proxmox virtual machine, running on a standalone mini-PC (similar to a NUC). I've be running on Proxmox for about 3 1/2 years now and have been very happy with it.
      If interested, I do have a video (and related blog article) on moving Home Assistant from a Raspberry Pi to Proxmox and this video also discusses the hardware I use: ruclips.net/video/w6uCJlhXf60/видео.html
      Thanks for watching. Let me know if you have any follow up questions.

  • @mankvlpwnz
    @mankvlpwnz 7 месяцев назад

    What could be the problem that after 2 secs toggle goes from on to off and leaves the task is set to on, but if I do on/off fast it works :( All day and can't find the way to fix it :(

    • @ResinChemTech
      @ResinChemTech  7 месяцев назад

      It would appear that the 'state' of the switch is either not updating or the switch you are using isn't properly getting or reading the state. You flip the switch to turn the device 'on', but yet the switch in Home Assistant immediately goes back to off (or vice versa) because it doesn't receive the state updating saying that the device is on. Double check what you have configured for the state of the switch... which could be different from the 'command' to turn it on.
      If you are using MQTT, then also check the retained flag on both the command and state topics to assure they are set to what you expect them to be.

    • @mankvlpwnz
      @mankvlpwnz 7 месяцев назад

      @@ResinChemTech just did it with toggle helper and automation, I was trying to switch beetwin TV sound source one had value bt_speaker other tv_speacker as it's not on or off switch maybe that's why it never worked with template? I'm rly new to HA but it looks promising combined android tv box and LG tv remotes to 1 dashboard, even better setup that I managed to do with NodeRED, thanks for the video rly helped to understand if state and attributes ☺

    • @ResinChemTech
      @ResinChemTech  7 месяцев назад

      Yeah... if I understand what you were doing, the toggle switch changes and launches the automation, but if the toggle switch is tied to an entity and that entity doesn't return a state (saying that it changed to either off or on), then the toggle switch will just revert back as its 'state' didn't change after you flipped it.
      The one thing you could do, is just have a toggle helper (not tied to an entity). Then in your automations, whenever the attribute changes to 'bt_speaker', you set the state of the toggle switch to 'on'. If the attribute changes to 'tv_speaker', you set the toggle switch to 'off' (or vice versa.. whichever way you want it). You need some way or automation that sets the toggle to off/on based on the state of the attribute. The only issue here is that if the attribute can be something other than 'bt' or 'tv', then your toggle is going to be left in an unspecified or incorrect state. That's why in the video, I created a number of switches/buttons each set to a different attribute value and only one can be true at a time. So, if the attribute could have 5 different values, then I'd have five different buttons. If the attribute became unknown (for example, when the device was turned off) or to something other than the 5 values I created buttons for, all the buttons would be turned off.
      I don't know if that helped... or caused more confusion. I guess the gist is that you need something in an automation or templated entity to set the state of the toggle switch to off/on based on the sound source selected.

  • @SBinVancouver
    @SBinVancouver Год назад

    I'd love to hear what others have done to sense that their trash is in or out. The most practical ones I've looked at are overhead ultrasonic sensor, ESPresence with a BLE transmitter on the side.

    • @ResinChemTech
      @ResinChemTech  Год назад +1

      I actually don't use that automation... it was just an example I created based on some example of what others have done. But I think you are on the right track. For me, I'd probably use the ultrasonic sensor on the ceiling, as that is what I use for vehicle presence in the garage for our two cars and it works very well. I could simply add a third sensor connected to the existing ESP and update ESPHome. But I too would be interested in hearing what others have done.

    • @SBinVancouver
      @SBinVancouver Год назад

      @@ResinChemTech our homeowner's association have been d*cks (wait, this is a family channel, no?) about the times we're allowed to put out and take back the cans. We haven't actually gotten fined yet, but we've had to grovel a couple of times...

  • @user-mfsc-2024
    @user-mfsc-2024 Год назад

    where should i put the yaml file?

    • @ResinChemTech
      @ResinChemTech  Год назад +1

      Please note that my YAML file very likely will not work in your Home Assistant without substantial modification. That being said, different parts of the YAML go in different locations.. and that depends on how you have Home Assistant configured. Dashboard YAML is added via the dashboard interface... automations may go in a automattions.yaml file, switches may go into the default configuration.yaml or in a switches.yaml (depending on whether you have a split config or not).
      My YAML file was not meant to be used directly, but to only serve as an example for creating your own. Where the different parts of that YAML go is entirely depending on how you have configured you installation, so I cannot give you a definite answer.

  • @TheUnofficialMaker
    @TheUnofficialMaker Год назад

    how do you turn tv on or off, IR?

    • @ResinChemTech
      @ResinChemTech  Год назад

      I have a Harmony Hub that is integrated into Home Assistant, so I can send various commands to Harmony for control of the different home theater components. However, I also have a network-connected Samsung TV that could be integrated into Home Assistant and the command to turn on the TV could also be handled in that manner over the network.
      But in essence, yes, the Harmony Hub is sending the IR command to the TV to turn it on/off. Home Assistant just sends the commands to Harmony.

  • @dkickelbick
    @dkickelbick 8 месяцев назад

    Very cool.

    • @ResinChemTech
      @ResinChemTech  8 месяцев назад +1

      Thanks! I use this technique quite a bit when I want a 'switch' on a dashboard to enable/disable something that isn't truly a switch. Of course like with most Home Assistant things, this is just one way to accomplish it.
      Thanks for taking a moment to leave a comment.