Device Last Modification


#1

Is there a method for checking how a device was last modified, without the use of variables, i.e. was it a motion sensor, button, or voice command that switched a light on?

I’m trying to make a light stay on if it was “manually” switched on (button or voice), but turn off automatically if it was motion that switched it on.


#2

When you say “modified” what do you mean?

Variables are the only way that I’ve found to do it completely. To prevent activating or brightening lights if the switch is already on when motion is detected can be accomplished by another condition in your piston of the switch being off for whatever device you’re controlling.

However, let me ask you this…why are you trying to keep the lights on if they were turned on by a switch? Are your lights shutting off on you while you’re sitting watching TV or something? I’ve implemented a couple different methods that seem to work for motion lights.

  1. Use your timeout of the sensor combined with the trigger “stay inactive for X minutes” to turn lights off.
  2. Some motion sensors turn the lights on to 100% and then only turn them off again if the level is over 95%. This works great in my bedroom. If i’m going to be watching TV, i dim the lights anyway and don’t want them turning off if I don’t move enough.
  3. The motion sensor turning the lights on at 100% only happens if the switch is currently off. This way, the lights don’t brighten to 100% if I’ve turned them on at say 40%.

#3

By “modified” I mean what changed the value last. Some activities are run through pistons and others through ST apps, I do intend to convert fully to pistons I’m just procrastinating on the best way to do it.

I already use some of the tricks you describe, I have a piston that syncs the light level throughout the house based on the time of day, but only if the current level matches this means if someone has modified it the piston doesn’t reset it. However, I wanted a simpler way to tell how a light was switched on, than multiple check to try to guess, or setting a variable for each light.

Having said that, I would be less against an individual variable per light, of there were a way to make it an attribute of that light. Like [bedroom light : lastmodby] which returned button, switch, motion, etc.


#4

You could modify the device handler by adding

attribute “lastmodby”, “string”

And

command “lastmodby”

in the device handler definition, and then

def lastModBy(modBy) {
sendEvent (“name” : “lastmodby”, “value” : modBy, isStateChange: true)
}

in the body.

Then use webCoRE to populate / read that lastModBy attribute.


#5

@infofiend How do I modify a device handler for a natively supported device, such as the Philips Hue bulbs?


#6

Philips hue bulbs DH are installed by the Hue Service Manager smartapp. You would need to install a custom version of that smartapp and the corresponding DHs in your IDE. There are several available on the ST forum (I wrote one called Hue B Smart), where you can find the instructions for its installation and use.

Once you have the code for the DH on your IDE, you can edit it as I’ve suggested above to include the desired new attribute.