Make device not available unless something is true

Hi, I am new in home assistant and i have a question. So here is my problem: i have ikea smart curtain, the curtain is connected to home assistant with zha. my curtain can only be opened when my window is closed since my window opens inside like a door. I have contact sensor on my window. Is there any why to make some kind of setting that if i am trying to open the curtain with the home assistant app instead of instantly do it, to first check if the window is closed and only if it is closed the curtain.

Create a script that lowers the curtain.
When you directly send the command to the device then it will do as you say, but creating a script that has a condition to check the window sensor means you can have logic to the curtain

Also be careful on the terminology you are using … you do not want the device to be “not available” … I believe you want a “condition” on an automation or a script that checks the status of window sensor status.

Making something “not available” has a whole different meaning. It really means “turn it off until I say turn it back on again”.

Thanks, but i have another question, if i will create a script that mean i will lose my ability to control how much I want my curtains to be open and i will lose the up and down buttons in my dashboard, is there a way to do this without lose it?.

You could have an input number slider to set the percentage and then have the script set the curtains to the input number percentage.

Thank you. It is working prefect now