Cover that only opens if there's nothing in it's way in Home Assistant
I have a screen that goes above my balcony door. If the door has been left open and I accidentally said "Alexa, turn on cinema mode" from downstairs, my screen probably wouldn't be as smooth anymore. I control my screen via Home Assistant, you can read more in another article here. It's a cover, which can be opened, closed or stopped.
The plan is to create a template_cover that only opens the real cover if the balcony door is closed.
The Template Cover
In the configuration.yaml file, I first of all created a template cover:
The value_template
is needed to show the state of the cover, which we can just copy from our real cover.
When we open the cover, a script is called, which I will go into more detail in the next step. If we close or stop the cover, I simply want the real cover to do exactly the same (the door can't be open if the screen is already down).
Preventing Screen Damage
As you've seen above, when we open the cover, a script is called:
The script actions are called one by one. The first action is a condition, and the script stops if a condition isn't true. In my example, the script should stop if the balcony door is open, and otherwise open the cover.
Wrapping Up
Now the cover is finished! Make sure to only use cover.my_screen_save
in your frontend, automations and cloud/emulated_hue components. That way, the cover really only opens if the door is closed.
Maybe your cover should only close when there is nothing in it's way, like the garage door and a light barrier checks the space? That's exactly the same, just put the script call to the close_cover action.
Are there any other covers you can think of that could take use of this? Share your ideas in the comment section below.
TL;DR
- Create a template_cover that mirrors all actions and the state from the original cover
- Replace the open_cover action with a script that only opens the cover if the door is closed