Simple Home Assistant Automation

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

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

  • @DeliberateGeek
    @DeliberateGeek 5 месяцев назад +2

    Hey Sam. I love this little starter automation. Like you, I'm relatively new to Home Assistant and Home Automation in general. Also, like you, I code. I have a small suggestion to set you up for future success. It's something I came across based on watching other channels.
    I started to notice that there are often several ways to trigger an automation based on the same event. So, for example, with the Aqara contact sensor...One way is to do exactly what you did, trigger it based on a device trigger. Another way to trigger your automation on the same event is to trigger on an entity state change. In that same sensor device, there is a binary sensor entity that ends in {_opening}, so it would be something like {binary_sensor.your_device_name_opening}, which would be set to "on" when the contact sensor is open. So, you could trigger your automation on that entity state changing to "on".
    OK, so why would you choose to do that rather than choosing the device? Well, the device has a unique ID assigned to it when it gets added. Just view that automation in the YAML editor and you're see that it's a standard UUID. If you need to change that contact sensor for any reason, you'll have to modify all the corresponding automations to trigger off the new device ID. If you trigger off the state change and need to change the device later, you can change the new device name to match the old one (after removing the old one) and HA will rename the corresponding entities to match. Once you do that and verify the entity name matches, all your automations associated with that device will now just work without having to edit them.
    The same applies to your lights. When you setup the turn light on action, if you choose the entities associated with your lights instead of the device, when your bulb dies, and you have to replace it, the same principle applies.
    After having seen different channels use entities instead of devices without much explanation about why, I did a bit of Google searching and found a few recommendations like this and it became clear WHY. So, as a rule, if at all possible (and it sometimes isn't), I use strictly entities to refer to anything in an automation, script, etc. This sets me up to make the eventual need to change things out far less painful, especially when you have several automations associated with one or more devices.
    I hope this makes sense and helps you or one of the other folks watching your channel.
    Cheers,
    STeve

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

    This is a fun automation. My first one like this was to turn off the air conditioner when my dog opened the door.
    What you should take a look at is trigger ids so you can organise your a automations in a single script instead of one to turn it off and another to turn it on.
    Also expanding in this you could use trigger ids to show both indicators on a single light. You would only need to set 3 colours.

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

    Hey Sam, you can combine the on/off automation into one automation by using trigger IDs. This reduces your number of automations and brings everything pertaining to a single bulb into one automation.