Turn on/off plugs when home and between times


#1

1) Give a description of the problem
Plugs always stay on

2) What is the expected behaviour?
They should turn off when not home or between times.

3) What is happening/not happening?
They always stay on

**4) Post a Green Snapshot of the piston![image|45x37]

5) Attach logs after turning logging level to Full
(PASTE YOUR LOGS HERE THEN HIGHLIGHT ALL OF THE LOGS AND CLICK ON THE </> ICON TO FORMAT THEM CORRECTLY)

REMOVE BELOW AFTER READING
If a solution is found for your question then please mark the post as the solution.


#2

could it be the OR you used in your IF section? If you are Home between 11pm and 5 am then I can see why they are on 24 hours. You may want to use “and” instead of “or”.


#3

How about this one?
2 IFs under single IF (trigger)

  IF time is between 5am and 11 am
            IF location mode is home
            Then 
            Do turn stuff on

           IF location mode is not home
           then
           Do turn off stuff

    Everyday at 11.01 
           Then
           Do turn off stuff

#4

As I understand it, your original piston will fire under three conditions: 5 AM, 11PM or when the location mode changes. Only way for the lights to go off using this piston is for the location mode to change lawny from Home between 11PM and 5AM which is not likely so the lights will stay on all the time as you are seeing.

@ike2018’s solution is good but I think will still only trigger at 5am and 11 PM (I think he had a typo there).

I would suggest:

if location mode changes
then
   if time is between 5am and 11 PM
        and location mode is any of away, home or babysitter
   then
       turn on
   else
       turn off
   end if
endif

if time happens daily at 5 am
    and location mode is any of away, home, or babysitter
then
    turn on
end if

if time happens daily at 11 PM
then
   turn off
end if

I’m sure there is some more elegant way to accomplish this but I think this covers all your cases.


#5

Yeap:)))


#6

It should fire whenever the location mode changes too.

Looking at the original piston, the plugs should turn on at 5am regardless (5am is considered as between the two times). Anything the location mode does between 5am and 11pm will not make any difference. At 11pm (which is not considered as being between 5am and 11pm), and whenever the location mode changes between 11pm and 5am, the plugs should turn on or off depending on the location mode at the time.

So if the lights are staying on all the time, that would suggest that the location mode is already set to home at 11pm and all night and @jkp may have correctly identified the intended behaviour and the solution.


#7

It was the “and” not “or” that was the issue thanks