"Switchy" SmartApps - Control lights via motion sensors and set custom lighting scenes

smartapp_lighting

(Josh Luker) #1

Hello everyone. I’ve been using SmartThings for a few months and finally got into developing some SmartApps for my own use. After using those apps for a few weeks, i decided to post them up for anyone else that might can benefit from them or modify to suit your own needs.

I have 2 apps - “Switchy Motions” and “Switchy Scenes”

Switchy Motions

The purpose of this app is 2-fold:

  1. Turn on one or more lights when a motion sensor detects motion, and then turn the lights off when motion stops, either immediately or after a set time period. You can also set a schedule to only turn the lights on during a certain time period
  2. Set a switch, or light, as an override so if that switch (light) is already on when motion starts, the lights will NOT be turned off when motion stops. This allows to you override the motion sensor if you want to manually turn your lights on and back off.

Switchy Scenes

The purpose of this app to automatically set a lighting scene when a switch (light) is turned on. You can control the brightness and/or color temp of a group of lights so that when the switch is first turned on, the scene will be set right after the lights come on. You can also setup schedules so that certain scenes are only activated during certain times of the day or night.

Note that the Use same lights as Level option as shown below will set the Temperature for the same list of lights you selected to control Level for. Otherwise you can set each list of lights independently.

Both of these apps are Parent SmartApps that each have their own Child SmartApps that have to be installed in order to work. So you will need to install both the Parent and Child app and then publish the Parent app so you can add it to your mobile app.

The source is in github if you want to setup your GitHub Repository Integration:
Owner: jlukerdev
Name: Switchy
Branch: master

Or grab the code directly from here: https://github.com/jlukerdev/Switchy/tree/master/smartapps/jlukerdev


(Albertus de Wet) #2

Hi

Thanks for sharing. I am copying your code into Smarthings MyApps, but I get this message:
Metadata Error: Parent SmartApp ‘jlukerdev:Switchy.Motions’ not found

Why are there four different codes and which should I use? Can you help please?
Thanks


(Josh Luker) #3

These are parent and child apps. You’ll need to create the Parent App first and then you’ll need to create the Child app. One both are created, go back into the Parent app and use the “Publish” button to publish it so you can access it through your mobile device SmartThings app.

The 2 Apps are:

Switchy.Motions (Parent) and Switchy.Motion (Child)

Switchy.Scenes (Parent) and Switchy.Scene (Child)


(Dtm) #4

Hey this sounds like exactly what I need. maybe I just suck at searching but I’m surprised how hard it’s been to find any apps that offer this overide ability.

I’m still trying to come up with a solution for my setup where I want Motion to turn on my lights in a room except when I’ve specifically turned them off to watch a movie or something…seems hard to automate, obviously I could dedicate a switch or command to set a mode to prevent motion in this instance…but something less involved would be nice


(Josh Luker) #5

I agree, i couldn’t find the functionality i needed so i just wrote my own lol.

This app doesn’t currently provide a way to set an override to keep the lights from turningON with motion. It will let you set a schedule for when to turn on certain lights based on time of day, but that doesn’t solve your problem fully. The only way i can think of to do it is to have a virtual switch or set a Mode to control the action. This app could be extended to honor that switch or mode when set, and ignore any motion in that case. Or WebCore could be used to control it as well.