Pretty new to HA and trying to get my way around the automation/scene/scripting stuff.
I am used to create lua scripts or write some python code, but yaml sequences is quite new to me.
For starters I would like to set a (global) variable to hold the state of my house.
Sleeping/Home/Away/Holiday/etc. Based on those states I used to fire or hold a lot of automations.
How can I create and set global variables?
Also how to create some simple IF_ELSE, AND_OR scripts? It seems the automations are quite limited to at least different to what I know, compared to lua and python.
Yep - input-select is the best way for storing list values between automations.
For non-list values people have used things like binary sensors (for boolean), sliders (integers) and for arbitrary strings I have used MQTT device trackers.
Serach the community for āvariablesā - there are lots of options
unless itās a specially designed sensor then yes. the thing is people use variables as both short- and long-term storage. for short-term storage HA restart is irrelevant. so it depends on use case.
@AhmadK - for the life of me I canāt rememberā¦ I started using them about version 0.6, input-text was around then so no idea why it was a better idea (if it was)
Iām just curious because it seems a bit overkill to use device_tracker for storing strings
Tried to use it a couple times as device_tracker (nmap tracker to be precise) and gave up as it gave me a lot of home -> not home fluctuations and caused my wall tablet to stop charging even if I explicitly excluded its IP. Maybe itās just me
Thanks for the reply all. I will have a look into all this.
Yet I do wonder why there is not a ānormalā code engine for languages like python or lua. Maybe something similar as the lua option in Fibaro hc2, where you can easily write your own code.
Well, itās a design approach. Here you think about data that is stored in state objects and automations that react to state changes and change states as well.
As pointed out previously, your goal is not difficult to achieve, there are many examples on this forum.
Agree fully in this example, but as automation will become more complex when I start combining sensors, states, etc. some custom coding can become very handy. It just feels like this approach is somewhat restricted, but maybe I just need to spent some more time with it.
I didnāt see a mention of it yet, but you could also take a look at hass-variables. Iāve transitioned to using more input_selects recently, but still have a few things utilizing the hass-variables component.
Yeah. You can perform complex actions using python_script (just keep in mind itās restricted Python so you wonāt get full freedom but then again, you can call a shell command or an external script (python or whatever) or use AppDaemon/NodeRed).
So itās not that bad