# Formula to schedule a global switch if another switch is on

So I'm a noob to KLWP. Got that? I need help.

I want a global switch to turn ON automatically at 8pm and turn off at 5am. But ONLY if another global switch is on. If it's not on, it's manual.

So here it is explained simply:

IF Global Switch X=ON, automatically turn on global switch Y at 8pm, and turn off at 5am. IF Global Switch X=OFF, Global Switch Y will only turn on if manual.

I need the formula to be inputted into the "Manual and Formula" area when creating/editing an on/off switch.

Hope somebody can help me!

Hi! Ok, so you should be able to get that by doing the following:

• Create global switch "A" and "B"
• In global switch "B" add an "ON" formula and write
• \$gv(A) & (df(H) >= 20 | df(H) <= 5)\$
• This will make B turn on only if A is on and hours is at least 8PM or before 5 AM otherwise the "auto on" will not do anything leaving the switch as manual
• Then add the off formula as
• \$gv(A) & df(H) > 5 & df(H) < 20\$
• This will make B turn off only if its between 6AM and 7PM and A is turned on, it will not kick in if A if off

Hope it helps!

Thanks so much! I've been looking everywhere for a solution!

Oh my this is handy ;) you are amazing