This is a general concept using templating with the basic on/off climate services. The details of the action section really depends on what type of thermostat/climate device you are using. If you need more specific actions such as setting temperature and mode you will probably need to use a Choose action to save and restore the settings.
These ad hoc scenes do not survive restart, so you may need to create additional options within the Choose action to handle those situations.
In rooms with more than one window and/or door entity being monitored it would be best to create a binary sensor group of those entities and put that in the trigger instead of the individual sensors. If you use the individual sensors you will need to filter out triggers caused by a second window being opened when one is already open. Otherwise, you will overwrite the scene that saved your original settings.
Okay; I was hoping this could be done without YAML, but I guess not. I’ve already had to use it a bit, though I’m not yet confident using it. I’ve never used YAML before, and some of it seems way more complicated than just markup. So I googled “selectattr” which you wrote above and found out that that’s not even YAML, that’s “Jinja” - am I correct?
This is something else I’ve never even heard of before - so I guess I have a learning curve ahead before I can feel like I know what I’m doing But thank you very much for your kind answer!
The last thing you list is something I’ve actually implemented successfully now. I have two windows in my living room, so I have four automations:
If Window 1 is opened AND Window 2 is closed, create a scene and turn down the thermostat,
If Window 2 is opened AND Window 1 is closed, create a scene and turn down the thermostat,
If Window 1 is closed AND Window 2 is closed, activate the saved scene,
If Window 2 is closed AND Window 1 is closed, activate the saved scene,
Somewhat lengthy, but at least it is transparent to me what’s going on
I’m pretty sure you could accomplish the task in one (very long) automation using just the UI Automation editor. However, it will be worthwhile to learn the basics of how yaml is used in HA. You will find that most users on this forum and other places will give examples and answers in yaml. There really isn’t a good way to share an example from the automation editor for anything complex.
Screenshots take too much work to create and share, and then you would have to manually recreate the automation on your end.
Blueprints are great, but they are more difficult to write than an automation and, once created, are relatively rigid.
In contrast, the yaml example can be copied and pasted, and you just need to swap in your entity ids for the example ones I made up. Some of the most helpful users on here have helped 100’s and even 1000’s of people by writing up a quick automation to answer a question, but few of them have made more than a couple blueprints.
Yes, templating in HA is done using Jinja. It is a very powerful tool that lets you extract and modify data in HA to create sensors, scripts, automations, and even dashboard cards.
In the second example above, using templates makes it so I only had to set up 2 options in the Choose action. Without templates, you would need to set up at least 2 options (on/off) for each room.
This is a great example of how Groups can save you from having to do extra work setting up or designing automations. If you create a binary sensor group that contains both Window 1 and Window 2 (making no other changes to the structure of your automations) you would only need 2 automations. And, the automations themselves would be more transparent because the group behavior handles the fact that you don’t need to retrigger if/when the second window opens, you don’t need to add those conditions yourself.