Motion sensor overriding manual switch

At my house, it’s getting dark at about 1800. I have a smartapp (Smart Lighting) that runs from 1800 to 0600 that will turn on the living room lights if there is motion and turn them off after 5 minutes of no motion. This is so if I’m elsewhere in the house or get up at night the living room lights come on via motion so I don’t stub my toes.

The issue is if I sit in the living room and manually turn on the light switch and watch tv at say 2100, and get up (causing motion) and sit back down the lights turn off after 5 minutes. Anybody have any ideas on how to override the Smartapp? I’d like to be able to manually turn on the lights and have them stay on until I manually turn them off again.

Thanks,
Jon

Add a virtual switch (e.g., “On/Off Button Tile”), and then configure Smart Lighting to turn on the physical switch using the virtual switch as a trigger.

Thanks for the reply @Mr_Lucky. Smart Lighting is using the physical switch now. How would putting a virtual switch in the mix help?

Here’s my logic now in Smart Lighting:

If motion in living room AND time is between 1800 and 0600 AND mode = Home OR Home evening OR Night, turn on living room light (zwave GE switch). Turn off after 5 minutes of no motion.

Wouldn’t a virtual switch or physical switch have the same properties in functionality in this case?

It will require two Smart Lighting automations. One to tie the virtual switch to the physical:
Which lights do you want to control? Living Room Light
What do you want to do? Turn On
Select trigger: Switch
Which switch? Virtual Switch
Turn on lights when Turned On
Turn off as well (probably)

And one to trigger the virtual switch based on your existing criteria (i.e., just change your existing rule to turn on the virtual switch instead of the GE switch). The virtual switch’s only function will be to toggle the state of the physical switch. Anything done on the physical side will override and act independently. Alternatively, you could use the purpose-built smartapp below to replace the extra Smart Lighting automation:

[code]definition(
name: “A Proxy Switch”, namespace: “HDFLucky”, author: “Bruce Ravenel”,
description: “Links a virtual switch to a real one, so that if physical switch is already on, will only be turned off manually.”,
category: “My Apps”,
iconUrl: “http://cdn.device-icons.smartthings.com/Lighting/light13-icn.png”,
iconX2Url: “http://cdn.device-icons.smartthings.com/Lighting/light13-icn@2x.png”,
iconX3Url: “http://cdn.device-icons.smartthings.com/Lighting/light13-icn@2x.png”)

preferences {
section(“Physical Switch”) {
input “physical”, “capability.switch”,
title: "Real switch… ",
required: true
}
section(“Virtual Switch”) {
input “virtual”, “capability.switch”,
title: "Proxy switch… ",
required: true
}
}

def installed() {
subscribe(virtual, “switch.on”, switchOnHandler)
subscribe(virtual, “switch.off”, switchOffHandler)
}

def updated() {
unsubscribe()
subscribe(virtual, “switch.on”, switchOnHandler)
subscribe(virtual, “switch.off”, switchOffHandler)
}

def switchOnHandler(evt) {
state.wasOff = physical.currentValue(“switch”) == "off"
if(state.wasOff)physical.on()
}

def switchOffHandler(evt) {
if(state.wasOff)physical.off()
}
[/code]
This is my modification of a smartapp written by @bravenel. I would have linked to the original, but can’t find it. To add either the virtual device or smartapp, you’ll need IDE access. There are several instructions/tutorials online here in the community. Post up if you have any questions.

1 Like

Thanks a ton for that @Mr_Lucky !!! I “think” I may have found a solution in between my last question and your reply. Rule Machine by @bravenel seems to have covered it!

Conditions:
Living Room Motion Sensor Active
Living Room Light off
Time between 6:00 pm and 6:25 am

Rule:
Living Room Motions Sensor active AND Live Room Lights off AND Time between 6:00pm and 6:25 am MST

Action for True:
On: Living Room Lights

Action for False:
Nothing

Evaluate one when mode is:
Home
Home Evening
Night

Yes, Rule Machine is definitely the way to go. I only went in this direction since you were already using Smart Lighting.
:beers:

i wish i could have experienced the Rule machine!!! it makes me so sad it sounds like it would resolve all of my frustrations with ST . I use ladder logic daily in my work so the set up of ST is frustrating to ,me and i would kill to have been able to have that Smart App.m Ive read of the developer Bruces Posts and it sure seems like the community has suffered for the loss substantially!!!

CoRe is better than Rule Machine. It is the next evolution.

Hi, I am having same problem. Can you please provide me what i should set for virtual switch and what for physical switch please.