Sample Rule to Turn on and off Lights when Motion is Detected and its Between Sunset and Sunrise

Just finished this rule and thought I would share.

The motion detector is a Ring Doorbell and the lights are on a GE Z-Wave switch.

Additionally, I delay the lights from coming on for 10 seconds so it doesn’t appear to be activated by the motion detector. I may change this to be longer. The lights then stay on for 5 minutes and are then turned off.

I hope this helps someone.

{
“name”: “Lights on when motion is detected and its between Sunset and Sunrise.”,
“actions”: [
{
“if”: {
“and”: [
{
“equals”: {
“left”: {
“device”: {
“devices”: [
“Ring Doorbell Id”
],
“component”: “main”,
“capability”: “motionSensor”,
“attribute”: “motion”
}
},
“right”: {
“string”: “active”
}
}
},
{
“between”: {
“value”: {
“time”: {
“reference”: “Now”
}
},
“start”: {
“time”: {
“reference”: “Sunset”
}
},
“end”: {
“time”: {
“reference”: “Sunrise”
}
}
}
}
],
“then”: [
{
“sleep”: {
“duration”: {
“value”: {
“integer”: 10
},
“unit”: “Second”
}
}
},
{
“command”: {
“devices”: [
“Porch Light Id”
],
“commands”: [
{
“component”: “main”,
“capability”: “switch”,
“command”: “on”
}
]
}
},
{
“sleep”: {
“duration”: {
“value”: {
“integer”: 5
},
“unit”: “Minute”
}
}
},
{
“command”: {
“devices”: [
“Porch Light Id”
],
“commands”: [
{
“component”: “main”,
“capability”: “switch”,
“command”: “off”
}
]
}
}
]
}
}
],
“timeZoneId”: “America/Los_Angeles”
}

Thanks!..

Great sharing @cabrioartie! Awesome use of Sunset and Sunrise values!

© 2019 SmartThings, Inc. All Rights Reserved. Terms of Use | Privacy Policy

SmartThings; SmartApps®; Physical Graph; Hello, Home; and Hello, Smart Home are all trademarks of the SmartThings, Inc.