Motion and door switch controlling light


#21

When something is this “intuitive” and dealing with “seconds” it maybe just slightly precarious but I’ll do my best. (not a coder so hang tight:))))))
I’m busy next few hours but I’ll draft something today and we’ll see where it goes.


#22

Haha slightly is probably fine! It’s a convenience thing, as most everything I have is, so no rush - I greatly appreciate anything!!


#23

OK, you talked me into it… LOL

Normally, I do not recommend disabling a motion sensor, but it really sounds like you want it disabled whenever the door is closed. Here is my three piston’s setup that should do everything you asked for in your…


Motion Sensor Piston

IF Sensor's motion changes to active         <-- Trigger
Then 
    Turn on Light  (do not add any extra commands here)
END IF

IF Sensor's motion stays inactive for 1 min  <-- Trigger
Then 
    Turn off Light  (safety net... will usually be turned off by the other pistons)
END IF

Light Switch Piston

IF Light's switch changes to on  <-- Trigger
Then 
    WAIT 2 min  (grabbing a tissue?)
    IF Door's contact is open    <-- Condition (indented)
    Then
        Turn off Light
    ELSE  (bathroom in use)
        WAIT 28 min  (2+28=30 min safety net. See notes below)
        Resume "Motion Sensor Piston"
    END IF
END IF

IF Light's switch changes to off  <-- Trigger
Then 
    WAIT 10 sec  (while they leave the room)
    Resume "Motion Sensor Piston"
END IF

Door Contact Piston

IF Door's contact changes to open    <-- Trigger
Then
    WAIT 10 sec  (while they leave the room)
    Turn off Light
    Resume "Motion Sensor Piston"
END IF

IF Door's contact changes to closed  <-- Trigger
Then
    Pause "Motion Sensor Piston"
    Turn on Light  (safety net - Light should already be on)
END IF

This method uses no variables, and no messing around with Task Cancellation Policy.

The only thing not specifically covered in this method is:

WebCoRE has no way of knowing if your hand pressed the switch, or a piston changed the switch. But, with the current wording above, if the light is on, and the door is shut, the Motion Sensor will not be touched until either:

  • The door opens… or
  • The light is turned off manually… or
  • 30 minutes has passed… This safety net will only be executed on LONG sessions.
    (so make this last number longer than your longest bathroom session)

For the observant ones, you may notice that there are three RESUME commands, but the only PAUSE command issued is when the door is closed. This is intentional. We want that motion sensor piston to be active whenever possible.


At the risk of stating the obvious, please make sure that you pause your current piston(s) (that are connected to those three devices) before testing these pistons.


#24

Updated: Sorry if you were already looking at this while I was editing.

Ok, here are my Garage light pistons. There are actually 6, not 5 as I mentioned earlier.

I used the RED instead of Green, so that the names of things make more sense. Also, my naming of the pistons might not be the best, but they make sense for me.

Also, keep in mind that I am a heavy user of ActionTiles, and some of the coding is for this.

  1. Garage Door Opens.

a. Depending on the time, half or all of the lights will turn on.
b. “Garage Auto Off” and “Garage Auto Half Off” are On/Off Button Tiles that tie into the later pistons. These buttons are also on my ActionTiles, and can be used to turn on/off half or all of the lights.

  1. Back Hall Door Opens.

a. Basically the same setup as “Garage Door Opens”, but triggered by the Back Hall Door which leads into the garage from the house.

  1. Garage Motion Lights.

a. Basically the same setup as the previous two, but triggered by motion in the garage.

  1. Garage Lights Automation.

a. This piston controls the OFF of the garage lights.
b. This piston uses the buttons instead of the actual lights.
c. This piston uses the “Cancel all pending tasks” to interrupt the timing of other doors/motion.
d. These three separate IF statements use to be part of each piston above. I moved them into one because I use to be left in the dark in the garage at night. That’s because one of the timers would always run out, even if another “ON” event happened.

  1. Garage Lights Alexa On/Off.

a. “Garage Lights Alexa” is an On/Off Button Tile. In the Alexa App, I changed the Type to “Light”. The reason for this is, when I tell Alexa to turn on the lights in the garage, this fake “Light” also turns on. This turns the On/Off Button Tiles on ActionTiles to represent the lights being on or off. I keep this fake light in sync with the real lights. There are future plans for this.
b. This piston is used when Alexa turns on/off the lights in the garage. It uses the fake “Light” mention above.

  1. Garage Lights Control.

a. This piston brings the buttons, fake light and variables together from the other pistons.

Adding my Garage Panel from ActionTiles, to tie it all together:


#25

I only have 2 Light Sockets in the garage, so I use this “4 in 1 Light Socket” on both. I have them spread out horizontally like fan blades.


#26

Wow that’s really kind of genius. I’m trying to “devil’s advocate” it, but not coming up with anything! LOL and if someone’s in there for 28 minutes… I need another piston having Google recommend more fiber! :slight_smile:

I’m still interested in what ike2018 is going to come up with as well.

All this assistance is really great - love this community!


#27

Whew! That’s a lot to parse. I need some time to absorb this!


#28

Haha I just bought one of these for my studio - it was too dark. Now it’s as resplendent as the noonday sun!


#29

oh man… @Wcmore is the pro I hired for my house. Since he stepped in I was only watching LOL


#30

The “safety nets” are a integral part of these pistons… (Even though they will not be used often)


You could add that command to that same piston… right after the 28 minute WAIT.
(If the door is opened before 28 min ends, it will not run the bonus command)


#32

Haha if only! Can you imagine? Someone’s in the bathroom a really long time, all of a sudden a voice is heard “Pardon me, but you should really consider more fiber in your diet!”

I’d LOVE a way to make Google announce things I type. Well, yes, I know there’s that Google Assistant Relay V 3.3 or whatever it’s up to now, but I tried it. A few times. WAAAAY too technical for me - can’t get it to work. But that’s another thread!


#33

One of my clients was worried about his elderly mother falling in the shower… So I created a couple of pistons to monitor certain events… If she was in the bathroom or shower for too long, a SMS is automatically sent to the client so he can make sure that Mom is OK…

Thankfully, that alert has not gone off yet, but it could theoretically save her life.