How to set condition on ability to change entity state

I have a blind which covers an openable window.

I’d like to prevent the blind being shut when the window is open (as it blows the blind which knocks everything off the window sill).

Is it possible to add some sort of guard to prevent any command to change the device/entity’s state when the condition is not met?

Alternatively, what can I do? Presumably I need to make a fake abstract blind which encompasses this logic, would that be a template? New territory for me here, whats best?

Edit: The blind is a Cover in HA and the window has a contact sensor on it

Cheers

So, yeah, you could probably create a Template Cover that “wraps” the real cover entity for the blind. Then show the template cover in the UI and hide the real blind cover entity. I would assume if you set availability_template such that it returns true only when the window is closed, that would prevent someone from using it to close the blind when the window is open.

The following example might not apply perfectly for your situation but demonstrates one way to prevent the operation of a device under certain conditions.

A door with a powered lock should not allow anyone to lock it if the door is open. In the UI, I display the control to lock the door within a Conditional Card. If the door is closed, the control is displayed. If the door is open, the control is hidden.

Thanks both

I’d prefer to do it at an entity level rather than in the UI as I have various automations hooked up to it too.

I’ll pursue these avenues and return back

thanks