Hi all. I decided to dip my toe in Home Assistant last month and this thing has sucked me in. I am trying to figure out how to do some thing in Yaml but I can’t find a single source that gives me a clear tutorial. I don’t mind working through it but I am just not getting how to do this.
Here are the two things that I am trying to do:
X=Blind position
close blinds for a bit.
once end for purpose for closing blinds is triggered…
reopen open blinds to X position
And. Stop automation A if Automation B is trigerred.
There is no built in way to store global variables. Any state that needs to be maintained in the system lives in entities and the attributes of entities.
The easiest entities with a settable state that persist are input_xxx entities from the helper section. For instance:
As for the yaml - is there a reason you would not use the UI? As far as automations and scripts go, you can always see with yaml the UI produces if you want to learn. And as you can see with the input number mentioned above, you can create it from the GUI but the corresponding yaml is documented too.
Thanks for the insight. The problem is how to set an attribute to the state of the blind so I can reset the blind back to the same position after the temporary close. I am surprised that the system does not provide a simple way to hold a value for reuse in the same automation. I also wish that there was a simple step by step tutorial but I guess chasing around for bits and pieces is what it is. Thanks again for responding.
If you didn’t know, there is an add-on called Node Red that allows you to write automations as flow diagrams. In Node Red, one can set local or global variables using a “change node.”
For me, it’s easier to write complex automations in Node Red. For simpler automations I use the UI.
Scenes are a way to store state of entities to restore them later. So that is indeed the best solution to this particular problem. I’m a bit ashamed I did not think of that
You can set variables within an automation and use them later. However, it depends on how long the automation would need to run if that is a good automation design. Home Assistant unfortunately needs to restart more often than you’d like if you tinker a lot. Long running automations get aborted when you restart, breaking the intended behaviour.
Home Assistant is designed to be event driven, which would imply the restore trigger should have a separate automation. I know many people do not design their system that way, but I think it is poor design.
And last but not least, entities are used for many things. Storing state is their purpose, so it would not make sense to have another thing (variables) do exactly the same thing. So using an entity to store a value for later use is a common design pattern that is not difficult to implement.
I thought of using a vibration sensor but I hear they are unreliable. I also thought of using a heat sensor but could not find that that was not ambient. I use a motion sensor in the shower to trigger that the shower was opened and the handle turned during daylight hours when the blinds are open. I then wait 20 min and then test for 2 minutes of no motion. Since the blinds change during the day I would like to return the blinds to the prior position.