Open/close curtain on condtions

Hi all,

I have a curtain that I can open manually with pushing a button. Now I want to automate this action. I tried something, but well the curtains don’t open nor do they close…

On Weekdays I want to open the curtain at a random time between 6:30AM and 7:00 AM (you know burglars, never use the same exact time :-)) and I want to close the curtain between 9PM and 10PM (same reason).

On Weekends, it should be opened between 8AM and 9AM, and closed between 9PM and 10PM.

When closing the curtains, two lamp bulbs should go on for a random time between 30 and 60 minutes when I am not at home. When I am at home, they should be on till I shut them off.

Could somebody help me out with this?


  • device_id: 69637f82f8e32e2096a56fb6c894e0ca
    domain: cover
    entity_id: f7cacef0375f0a24c662621be95d9da0
    type: open

service: light.turn_on
- light.living_tv_links
- light.living_tv_rechts

Am I at home or not : device_tracker.xiaomi_13

Post what you tried. Please read and following the Community guide regarding asking questions. Specifically items 1, 2, 9, and 11:

What is your plan for getting a randomized time?

Hi @Didgeridrew

You are absolutely right. But I am just some guy trying to do some things with HA. I know exactly what I want, but don’t know how to do it with HA.

The only thing I tried until today is open/close it at a fixed time (that worked out well). Then I tried what i’ve described here. I screwed up. Forget about it, and tried it again after some weeks. So what I exactly tried? Not even a clue anymore.

And to answer your question “what is your plan for getting a randomized time?” : I don’t know. I don’t even know if that is possible. So there isn’t a plan (yet), just some toughts how the result should be.

I come from a situation that (almost) everything in my house was working with Tuya, this is my third try to use HA in stead of Tuya, because I want some more flexibility.

I was not trying to denigrate or belittle you in any way. The community question guidelines I linked have been created and are pinned for a reason. There are more than 2000 integrations and likely 100,000 devices that work with HA. Seeing what is working and what you have tried that isn’t working with your particular setup and equipment can be very useful when we try to provide help. Some of us also use it to gauge which methods are appropriate to suggest as answers for questions.

A search of this forum will return many results for automations using random time. Here are 3 options, choose one or tell us why those will not work for your needs…

Random time using random Delay after trigger
Random time using template sensor
Random time using Input datetime helper