Advices on how to set up scalabe, flexible, yet easy to main Automations,Scenes,Variables

Hello Community! I’m rather new to Home Assistant. I just got beyond the really basic Setups, like setting Triggers, Actions, Scenes, Basic Automation - via the Gui…
Now i think the Fun with smarter Automation can begin :smile:

But, before i start with my first ‘Project’, i wanted to ask you for the best approach, to avoid spending hours for the wrong (laborious, not proper scalable,…) way.
For skipping the description and bla, i tried to sum up the Questions down below :wink:

I’m used to the Basic concept of Programming in General (IfThenElse, Setting Variables,…), but definitly am no Programmer
Yet, i haven’t really understood/learned the Syntax of Yaml/Variables, even don’t know wether Graphic or Yaml editing would be better for me – but thats fine, gonna learn it by walking (and maybe later assistance if I get stuck :-)).

So, what is in my Mind:
I do have 6 Lights in the Hallway, Motion Sensors and Remotes (Tablet later)

  • Brightness and ColorTemp should be set according to the Daylight-Sensor

  • Remotes can be used to adjust Brightness, ColorTemp or switch to a different Scene.
    Those Settings will be kept for a certain amount of Time, before the Standard-Automations kick in again.

  • The Motion-Sensors kick in for 2 Minutes

  • If the Remotes / WebGui was used to turn on or alter Values, the Timeout for the Motion-Sensor should be set to 15 Minutes. The Timeout should be reset to 2 Mins after a given period of Time.

  • There are Priority-Conditions, that can always (partially) overrule the Settings from above (E.g. keep one Light Red while Bathroom occupied, while the others keep following the Automation.

Now, where and how should i setup which part?
Obviously, there are a lot of If-Then-Elses. Where should i collect them to keep it as logic, maintainable and scalable as possible?
Im struggeling with the “Collisions” of the different Conditions and Priorities (The needing to ignore the General Automation when Remote Used, and to (partially) ignore both when there is a Priority-Event, and to Fall back).
How should i approach my first Project without ending with tons of Scenes, Automations, each with tons of If-Then-Else?

What would you advice, where would you collect and update the Variables, when would you set device Settings via automations, when call a Scene?
How would you manage the different Levels of “Priority Settings”, which should sometimes only should affect single Devices, while the others keep following the “lower Prio” Automations?

Hope thats fine not to ask a specific ‘how’, but more a general experience-proven-approach. Those “why doesn’t that work” questions i’m willing, hopefully successfully, to google… :wink:
Would love to hear your advices!

Not an expert at all, but I think the best things about HA are the flexibility and challenge of finding the right approach for your specific requirements.

A couple of things that spring to mind:

  • if there are actions or groups of actions you may want triggered in various situations, create a script instead of putting into an automation. You can then call the script from mutiple automations and if you need to tweak, only needs to be done once.
  • helpers are great. Input booleans and input selects are particularly useful as conditions in automations and can be used to streamline things by creating a specific entity for your particular use case. E.g. a helper for bathroom light override which gets switched on by a trigger and turns off again once it no longer needs that override priority.

Happy building!

Seems i still struggle with Basic Concepts/Layouts. Though it might be really newbie-Stuff, could you help me out with clarifing a couple of concrete Questions?

  • I can’t set States for Devices (Lights) while beeing off/offline, read those States and manipulate them while beeing off. Can I?
    So i would need to introduce variables (called Helper) for every particular Setting for every Device (if existing helpers can’t be reused). True?

  • I can’t update an existing, non-active scene with a couple of devices, for only one particular Device of that scene, Can I?
    So i would need to set up a big automation to re-create a whole scene with options, where every option (re)creates the whole scene with slightly different settings. True?

Thank you so much, hope my learning curve will grow soon :slight_smile:

PS: To me it looks like here are rather Pros around. I hope it is okay to pop up with rather basic questions. I couldnt find a Newbie-Area, OneQuestionOneAnswer-Thread,… Is there a better Place for Ppl like me?

I think you would benefit from reading the docs in detail. Probably several times to get your head around the tools at your disposal. In particular, templating is really powerful, but more advanced:

I get the impression you are aiming to do things which are quite complex so you need a bit of time to assess the best approach. Don’t be afraid to try things out and see what happens - it’s a great way of learning!

To answer your questions, controlling devices ‘offline’ depends on whether your devices rely on the cloud or not. If they do and you have no internet connection, then no you can’t manipulate them and helpers aren’t going to help. If you just mean changing attributes when they are off, there’s not really a need to do this as you just call the required attributes with the turn on command when required.

The ‘choose’ action can be very useful for creating consolidated automations by defining trigger ids (i.e. if this thing triggered the automation, do these actions). But I’d suggest you perhaps start with separate automations. There’s nothing wrong with having many separate automations, scripts and scenes to handle one set of devices. For example, I have four for my pet feeding reminder, four for my daily light changes at different times of the day etc.

Hope that helps. Get stuck in experimenting and good luck!

1 Like

Thank you so much for your encouraging Words, really appreciate it! Well, i guess you’re right - i maybe shouldn’t start with the most complex goals :wink:

You know, its just that i sometimes come across “the solution”, but (with my basic programming knowledge) its like “that can’t be it, i bet its the most unlogical approach im taking”.
But enough of whining. I will get over it :smiley:

[quote=“fenty17, post:4, topic:391895”]
I think you would benefit from reading the docs in detail
[/quote] Definitly! And really, i already did & do it. But i think i need both, more general philosophy and step-by-step tutorial on (my ‘big’ Project) how to e.g. set up dynamic scenes presets. I learnt best when looking at Project-Tutorials. I was hoping i just missed “the” great ressource, like Stackoverflow…

[quote=“fenty17, post:4, topic:391895”]
If you just mean changing attributes when they are off, there’s not really a need to do this
[/quote] Good example of me thinking i think the wrong way :wink: Still not sure what the most “scalable, flexible, yet easy to maintain” way is. One idea was “why cant i just update default values for lights”. i wont need helpers, scenes or scripts, i just let them turn on.
So, i think i will need to try it with either helpers or scripts creating scenes.

That was not really a follow-up question :wink: Its more a Thank you so much for your kind words! It really made me less frustrated, and excited to get stuck in experimenting :smiley:

No problem. Home assistant provides an amazing set of tools for achieving your home automation goals. Part of the fun for me is working out how to achieve it and seeing how others do things. If it works, that’s all that really matters. I’m sure many of my automations could be more efficient and use less lines of code, but they work so I’m fine with that.

Sure it takes a while to get your head around the architecture. Start off with some basic stuff. What do you want your lights to do at certain times of day, for example. I have them come on triggered by motion in the morning at a certain setting (good morning script). They can be overridden manually or by other automations during the day, then come sunset they change to another setting.

Good luck!