Change location if virtual switch is already on between sunrise and sunset


#1

1) Give a description of the problem
I have set up virtual switches (VS) for STHM and want to change the location mode based on sunrise and sunset. The piston will change the location if the VS changes to on between sunrise and sunset. The piston is not changing the location mode if it is already on (no change in state).

2) What is the expected behaviour?
If the VS changes to or is on between sunrise to sunset it will change the location mode. And the same for sunset to sunrise.

3) What is happening/not happening?
No change is happening is the VS is already on and the time changes to sunset or sunrise

4)


#2

Notice the lightning bolts in the left margin… These are your triggers, and are the only things that will “kick off” this piston.

This means that the piston will only run when Switch 23 changes to either on or off, and will run thru the entire code, top to bottom.

If you want another trigger to fire at sunrise & sunset, then you will need to add another block (trigger).


Pro Tip:

I have a Sunrise piston, and a Sunset piston. If your house is similar, I would add those extra commands to those pistons, to reduce unneeded clutter.

IE: There’s no need for multiple pistons to run at every event.


#3

I understand somewhat about the triggers but I am new to this and have only made simple pistons. I mostly use others examples to figure things out. I can’t figure out how to make a switch that is already on a trigger.


#4

Well, let me ask you…

Do you like the idea of having a piston running every day at Sunset?
(to adjust lights, set location mode etc)


If your answer is yes, then I would make a new piston called Sunset, with this basic code:

Every day at Sunset
do
    IF Switch 23 is on
    Then
        Set location mode to Night
    END IF
END EVERY

You can also add other elements to this, like turn on porch light, dim internal lights, etc.


#5

Kind of, once I got this piston up and running I was going to automate other devices such as lights based on location mode.


#6

Personally, I believe every house needs a piston dedicated to Sunrise, and another one for Sunset.
As time goes on, you will think of more and more things to add to those pistons.
(and it helps to have them all in one central location)


#7

Now that I am thinking more about it I may go that way. I have different location modes based on if I am home or not. For example vacation, night, night away… I could add the sunset piston to have a location condition and this may work as an “all in one” piston.

My limited knowledge results in me having pistons that usually only have one function happening at a time.


#8

There is nothing wrong with this… but keep in mind that multiple pistons (or triggers) can do a singular function as well.

For example, One piston for Sunrise… One piston for Sunset… One piston for when you arrive at home… All three of these can adjust your location mode, based on other criteria.


#9

Just about everyone here knows that I prefer TASK SPECIFIC pistons. Much easier to debug and maintain.

Many of us here have over 100 pistons running.