20 things I wished I knew when I started with Home Assistant

I realised very late the power of calling scripts from automation (and, since 2023.4, macros).

  1. Code refactoring
    Use macros for repetitve templates (introduced in 2023.4.x)

And

For repetitive set of action, like TTS on a speaker, use a script with parameters and call from the automation (synchronous or asynchronous)

I have a script to do TTS

  1. create scene
  2. unmute speaker
  3. set volume
  4. say something (where the parameters are used)
  5. wait for TTS to end (speaker back to idle)
  6. restore scene

This script is called from multiple automations.

2 Likes

What is the add on “check home assistant config” ?

1 Like

I think it’s default now, it’s the button that allows you in the dev tool tab to check the configuration before reloading. It tells you if there are syntax problems.

Not quite. The check config add-on checks against the breaking changes of the next HA version.

So after HA 2023.5 comes out you can scan your config (still on 2023.5.x) and the add-on should tell you if there are issues you need to fix to remain compatible

1 Like

+1 for Packages. I use them for everything.

eg:
image

Where for example, the front_house_lights.yaml file has everything for that ‘device’ all in one place.

2 Likes

Some people contributing to this thread are promoting the use of packages. I can see the advantages in terms of organisation but I have a question:

An I right in thinking that having automations in packages prevents the use of the automation editor UI?

Yes. It’s why there have been so many requests to have the UI improved so that things can be grouped in the same way we do in Packages. If we could group all the relevant input_booleans, scripts, automations etc. where the UI shows the related bits in one place I would migrate to full UI, but until then I’ll stick with neatly organised YAML.

2 Likes

Plus, if I’m not mistaken, you can also not reload them from the UI.

Great post @kameo4242.

This is a great point. I spend a fair bit of time on the forum and very often I see the convoluted and unmantainable use of devices when a simple entity and state trigger or condition would suffice.

Actually you can. The reload buttons in the dev panel will reload files within Packages. That was fixed years ago.

But only if the file in your package is also (for example) automations.yaml and not if you mix things up differently, right?

Nope, not true. See my snapshot above. I have all domains in the same file and these reload from the UI fine.

So if you’re reloading only one domain, will it then reload only that domain’s section in a file, or all domains in that file?

My apologies if I’m being slow here (and slightly off topic). It’s been a long time since I’ve used it, because it wasn’t working as expected and I must’ve missed the updates.

Yes, just that domain in the file.

1 Like

I’m afraid I would also need comments to be retained :wink:

It is the exact opposite of good practice to not ‘allow’ comments.

I know that the UI generates JSON directly (not YAML) which doesn’t have a way to comment but I think the HA UI implementation should have had an underlying ‘database’ which allowed (retained) them when (migrating).

Also the reordering of the YAML is a huge barrier to migrating. We all have our ingrained preferences which are very hard to change.

None of which is to say the UI is not ‘a good thing’, just that it does have some, IMO, severe limitations.

(Also, I’m still not convinced that for anything even slightly complex the UI is the best way to ‘write’ an automation/script)


But I do strongly agree about packages. So good are they that it is is almost impossible for me to understand why they are, if not the recommended default, then at least strongly encouraged and promoted.

One thing about them no one has yet mentioned is the ability to rename a package folder with a leading ‘.’ (fullstop) to have not be loaded by HA.

For example, If you’re making big changes, copy the folder folder, rename the original and you can always quickly revert if things go wrong.

1 Like

Yep, same here. I tried to develop kind of a system for a move from yaml to UI, but this is not really a choice at the moment. It simply doesn’t give me that freedom to do all the things I want in the UI…

Btw thank you very much, you are the reason why I started looking (and than using) packages. You made a neat little post years ago, where you explained the use of packages, and that was my starting point! :+1: :+1:

1 Like

Coming back to this…probably fits into #6…put your hardware on an UPS. A mini UPS for a single device can be had for relatively cheap.

1 Like

Yep, I definitely agree on this one. I have quite a few comments in my code too.

That’s a good start for an Amazon book on HA. You should seriously consider it.

1 Like

HA for Dummies type book!!!

1 Like