Default daily process with manually override feature


#1

1) Give a description of the problem
I want to have a turn on start time set to 2 hours before sunset and turn it off after 8 hours. However, it also allows to manually turn on and it will still be turned off after 8 hours.

2) What is the expected behavior?
I have tried different ways, but none of them work. The current one I was trying with the timer. However, the timer never triggered the turn on. According to my code, I manually turn on first then a start time set to $now. After that, I turn off it then the start time set to sunset -2 hours. When the time is sunset -2 hours, the timer does not trigger any action. I manually turn on, after 8 hours, the timer does not turn off it also.

3) What is happening/not happening?
Nothing happen. No trigger action has been performed.![download|647x500

**4) Post a Green Snapshot of the piston


#2

I would suggest two pistons: one to turn on at 2 hours before sunset (but with a test to check if it is already on) and the second looking for the switch to turn on and then just waiting 8 hours and turning off. with these two, the on piston will just skip if already on or turn on automatically if off. Then wheterh automatic or manual on, the second will trigger and turn off in 8 hours.


#3

After looking at your piston, the two I suggested would look something like this:

Piston 1

Every day at 2 hours before sunset             <-- trigger (use preset time sunset with offset)
    if switch 1 is off                                         <-- condition
      with switch 1
          turn on
      end with
   end if
end every

Piston 2:

if switch 1 changes to on                   <-- trigger
        or
   switch 1 is on                                  <-- condition for when returning from wait
 then
    with switch 1
         wait 8 hours
         turn off
    end with
end if

Hope this helps.


#4

Thank you so much. I think that will do it.

One question, can make these 2 pistons into one piston? It looks like they can be in the same piston or a “changes to trigger” doesn’t work if they are in the same piston? Thank you.


#5

I think it woulda in the same The every loop will only execute at the specified time so if the other trigger is separate, it should be fine.


#6

Thank you.