Conditions and actions and lights

Ok - bear in mind I have a extensive background in I.T. scripting and automation - wrapping my head around this product (and really enjoying the challenge I might add…). But I have a question…

So in normal IT scripting languages, you can do if/then/else statements…but I’m wondering if the automation in HA supports this logic.

The reason I ask is the following…

I got a minimote working and pressing 1 turns the light on and pressing 2 on the remote turns it off. But is there an option turn script in button 1 to say “button 1 pressed - if light off, turn on else if light on, turn light off” - so I could use 1 button for 1 light?

I’m assuming conditions are somewhat of the answer, but I wasn’t sure how to get 2 actions to tie to automation. I get the impression this is probably not an option, at least in the automation, based on how the conditions page says this “Conditions are an optional part of an automation rule and be used to prevent an action from happening when triggered.”

So it sounds like conditions are meant to stop actions - but can you have mutliple conditions/actions in one automation rule?

If scripts are the answer, that’s fine - I could have the remote button 1 fire off a script, but I didn’t see if/then/else in the scripting language.

Thoughts and ideas would be much appreciated. If I’ve missed something core to the product, happy to re-read and learn, just couldn’t find it on my own.

Thanks for all the help!

Both automations and scripts support conditions. In addition for some problems you can use templates which have a more intuitive IF THEN ELSE flow than automations or scripts.

If you want something closer to programming, I would suggest you take a look at AppDaemon

2 Likes

aimc - thanks for the suggestion - I will most certainly take a look at appdaemon - appreciate the input much!

For the button situation, you could easily trigger 2 automations and then have conditions knock one down based on state. On or off. That would accomplish what you want to happen. Even if they fired sequentially, you could add a FOR condition to make sure the state was at least 2 minutes old.

1 Like

Thanks for the input @CCOSTAN! I will have to look at this - I’ve been quite busy and haven’t gotten back to this, but will soon as I’m planning on a lot more automation with an upcoming home purchase. This gives me another angle to look into. Thanks for dropping by and commenting!