Hey @nelemansc, unfortunately, as I began to use this new SmartApp/Virtual Switch/Endpoint setup regularly it started giving me issues. The first issue I noticed was that the SmartApp automatically triggered when my systemâs Mode changed from Home Night to Home Day (which I have setup to occur at sunrise each day). This is really weird because I didnât select any modes as criteria within the SmartApp when I installed it. Nor do I have any Modes setup to turn on the virtual switch that controls the SmartApp.
The second issue was that after I noticed this issue occur, I tried manually activating the SmartApp by pressing the play button on it and it just stopped working. However, after each time I try this I go into the Activity Feed and surprisingly it actually shows âMovie Lights [my SmartAppâs name] was touchedâ. So it seems like itâs registering that I pressed the SmartAppâs button, but it doesnât then trigger the actions I have it set to do.
@nelemansc - I played around with it a bit more tonight and figured out whatâs going on. When I installed the SmartApp it registered not only the levels that I had all my selected light switches at, but the Mode my system was in as well. Even though I didnât specify at the bottom of the App configuration to only work within certain Modes.
This explains why when I tried running the App at another time (when my system was in a different Mode) that it registered me pressing the play button in the Activity screen but wouldnât actually run it.
As I was messing around with it I also noticed that when I switched away from the Mode the App was configured to work within and then back again it ran the App automatically. This explains the other issue I had in my previous post. However, I have no idea why it would do that.
Either way, if you could adjust the code so that it doesnât save the Mode my system is in at the time of install I think that would ultimately solve both problems.
@triggertact Iâm not 100% clear on how the âMake it soâ app is supposed to work, but I use something similar for âMovie Lightsâ thatâs a bit simpler.
definition(
name: "Movie Mode",
namespace: "",
author: "nelemansc@gmail.com",
description: "Movie Mode",
category: "My Apps",
iconUrl: "http://i39.tinypic.com/2i9lfep.png",
iconX2Url: "http://i39.tinypic.com/2i9lfep.png"
)
preferences {
section("Select Switch to monitor"){
input "theSwitch", "capability.switch"
}
section("Which light(s) to dim in the family room:") {
input "switches", "capability.switchLevel", multiple: true
}
section("Dim to this level..."){
input "lvl", "number"
}
section("Additionally dim these light(s) in the kitchen...") {
input "switches1", "capability.switchLevel", multiple: true, required: false
}
section("To this level..."){
input "lvl1", "number"
}
section("Turn off these lights altogether..."){
input "switch1", "capability.switch", multiple: true, required: false
}
}
def installed()
{
subscribe(app)
initialize()
}
def updated()
{
unsubscribe()
subscribe(app)
initialize()
}
def appTouch(evt) {
log.info evt.value
log.info "lvl: $lvl.value"
log.info "lvl: $lvl1.value"
switches.setLevel(lvl.value)
switches1.setLevel(lvl1.value)
switch1.off()
}
def onHandler(evt) {
//
log.info evt.value
log.info "lvl: $lvl.value"
log.info "lvl: $lvl1.value"
switches.setLevel(lvl.value)
switches1.setLevel(lvl1.value)
switch1.off()
theSwitch.off()
}
def offHandler(evt) {
log.debug "Received off from ${theSwitch}"
}
def initialize() {
subscribe(theSwitch, "switch.On", onHandler)
subscribe(theSwitch, "switch.Off", onHandler)
}
If youâre not locking doors/setting the thermostat, this one should work a bit better for you. Although it would be pretty easy to add those settings in if need be.
Hey @nelemansc, Iâve wanted to update this app we worked on a bit more to also include a function of turning on some on/off light switches in addition to the dimmer switches that we already had it controlling. I tried adjusting the code myself to add this functionality, but itâs not working. Can you take a look at my code below and see if you can figure out how to get it going? Thanks in advance!
definition(
name: "Virtual Switch Control Lights",
namespace: "Virtual Switch Control Lights",
author: "cbd@deyoungproperties.com",
description: "Set a group of your light switches to specific levels, or turn them off, with the press of a single 'virtual switch'.",
category: "My Apps",
iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png",
iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience%402x.png"
)
preferences {
section("Select Switch to monitor"){
input "theSwitch", "capability.switch"
}
section("Which light(s) to dim to Level 1:") {
input "switches1", "capability.switchLevel", multiple: true, required: false
}
section("Level 1"){
input "lvl1", "number", required: false
}
section("Which light(s) to dim to Level 2:") {
input "switches2", "capability.switchLevel", multiple: true, required: false
}
section("Level 2"){
input "lvl2", "number", required: false
}
section("Turn ON these lights..."){
input "switch1", "capability.switch", multiple: true, required: false
}
section("Turn OFF these lights..."){
input "switch2", "capability.switch", multiple: true, required: false
}
}
def installed()
{
subscribe(app)
initialize()
}
def updated()
{
unsubscribe()
subscribe(app)
initialize()
}
def appTouch(evt) {
log.info evt.value
log.info "lvl1: $lvl1.value"
log.info "lvl2: $lvl2.value"
switches1.setLevel(lvl1.value)
switches2.setLevel(lvl2.value)
switch1.on()
switch2.off()
}
def onHandler(evt) {
//
log.info evt.value
log.info "lvl1: $lvl1.value"
log.info "lvl2: $lvl2.value"
switches1.setLevel(lvl1.value)
switches2.setLevel(lvl2.value)
switch1.on()
switch2.off()
theSwitch.off()
}
def offHandler(evt) {
log.debug "Received off from ${theSwitch}"
}
def initialize() {
subscribe(theSwitch, "switch.On", onHandler)
subscribe(theSwitch, "switch.Off", onHandler)
}
@triggertact Hmm, the virtual switch works on my setup, but no luck with the app touch trigger. Not exactly sure why it isnât though, I can see you havenât really altered that portion of the code. Did you set yours so it could only trigger during certain modes?
Hey @nelemansc, I did not have it set to trigger only during certain modes. I just tried installing the app again to see if anything has changed, but unfortunately it still doesnât work. Neither pressing the app play button nor turning the virtual switch on work to trigger it. Should we tag anyone else that you think might be able to help?
definition(
name: "Virtual Switch Control Lights",
namespace: "Virtual Switch Control Lights",
author: "cbd@deyoungproperties.com",
description: "Set a group of your light switches to specific levels, or turn them off, with the press of a single 'virtual switch'.",
category: "My Apps",
iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png",
iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience%402x.png"
)
preferences {
section("Select Switch to monitor"){
input "theSwitch", "capability.switch"
}
section("Which light(s) to dim to Level 1:") {
input "switches1", "capability.switchLevel", multiple: true, required: false
}
section("Level 1"){
input "lvl1", "number", required: false
}
section("Which light(s) to dim to Level 2:") {
input "switches2", "capability.switchLevel", multiple: true, required: false
}
section("Level 2"){
input "lvl2", "number", required: false
}
section("Turn ON these lights..."){
input "switch1", "capability.switch", multiple: true, required: false
}
section("Turn OFF these lights..."){
input "switch2", "capability.switch", multiple: true, required: false
}
}
def installed()
{
subscribe(app, appTouch)
initialize()
}
def updated()
{
unsubscribe()
subscribe(app, appTouch)
initialize()
}
def appTouch(evt) {
log.info evt.value
log.info "lvl1: $lvl1.value"
log.info "lvl2: $lvl2.value"
switches1.setLevel(lvl1.value)
switches2.setLevel(lvl2.value)
switch1.on()
switch2.off()
}
def onHandler(evt) {
log.info evt.value
log.info "lvl1: $lvl1.value"
log.info "lvl2: $lvl2.value"
switches1.setLevel(lvl1.value)
switches2.setLevel(lvl2.value)
switch1.on()
switch2.off()
theSwitch.off()
}
def offHandler(evt) {
log.debug "Received off from ${theSwitch}"
}
def initialize() {
subscribe(theSwitch, "switch.On", onHandler)
subscribe(theSwitch, "switch.Off", onHandler)
}
We never subscribed to appTouch, that could have been part of the problem. Now it works for both the virtual switch and the app touch in my environment.
@nelemansc - Oops, I forgot to tag you in this reply⊠wasnât sure if you saw it come through.
Dang, unfortunately, it still doesnât want to work on my end. With either the virtual switch or pressing play on the app. Also, I notice that the virtual switch doesnât turn itself off after you turn it on. I think the other ones that we setup before did.
With it working right on your end, how should I troubleshoot this? Thanks again for the help!
UPDATE: just got it working⊠what I found out is that itâs requiring me to use the âdim light(s) to level 1â function. If I donât input a light and dim value for that first one then it wont allow any of the other functions to work. In other words, if I just wanted the app to âturn offâ a light by turning the virtual switch on it wont work. It will require that I add a light to dim to level one in addition to turning the other light off. Can you adjust it so that using the first function isnât required?
UPDATE 2: I uninstalled the app to try reinstalling and see if the same thing held true. However, this time it required lights and dim values input for both level 1 AND 2 in order to have the âturn onâ lights function to work. Lastly, it appears as though the virtual switch did not turn itself off.
Hey @nelemansc, just following up with my last post. Ultimately, it works, but it requires me to use the level 1 and level 2 actions in order for it to work. In other words, I canât just have the virtual switch turn OFF some lights. Any idea of how to fix this? Thanks
Hey @nelemansc, I really hate to bug but I thought Iâd just check back and see if youâve had a chance to review my last two posts. Thanks again for all the help!
Hey @triggertact, Iâve been moving into a new place and have not had time to hook my SmartThings back up yet. I hope to get around to it sometime this week, then I can look back at it