Hey @triggertact,
I have gotten the hub setup, but I have not gotten around to installing my light switches/dimmers. The circuit breaker unfortunately is not labeled, so that is a project in itself.
Hey @triggertact,
I have gotten the hub setup, but I have not gotten around to installing my light switches/dimmers. The circuit breaker unfortunately is not labeled, so that is a project in itself.
Yuck⌠Older house I presume?
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.info evt.value
switch2.off()
theSwitch.off()
}
def initialize() {
subscribe(theSwitch, "switch.On", onHandler)
subscribe(theSwitch, "switch.Off", offHandler)
}
Should turn off the lights you select when the master switch turns off now. Let me know if this doensât work for you.
Basically Switch ON will setup the âsceneâ and switch OFF will turn off the sleected lights to turn off in the app. Hope this helps
(Leave the âTurn ON these lightsâŚâ value empty if you just want it to work as on âoffâ switch.
Also you cna group lights together on the dashboard to create and âoffâ switch for any groupings of lights you want.
Hey @tslagle13, thanks for the help! It does allow me to have certain lights turn OFF now without requiring that I also specify other lights to turn ON, so that is good news.
However, in certain cases I would actually like to use this app to turn off some lights AND turn some on simultaneously. I tried selecting a few for it to turn ON along with the ones I want turned OFF, but when I execute the app (or turn the virtual switch on/off) it isnât triggering the lights I have specified to turn ON. It just triggers the lights that I specified to be turned OFF.
Ultimately, my goal for this app is for the virtual switch to trigger ANY of the preferences selected simultaneously. In some cases I may only have it trigger some lights to turn OFF. In some cases I may only have it turn some lights ON or dim to a specified %. In other cases I may have it turn some on AND turn some off simultaneously. As it currently is Iâm not sure itâs able to accomplish all of these scenarios. Hopefully that makes sense.
Thanks again for any help you can provide!
QuestionâŚ
Can you use Hello Home to do this? Is there a reason you need a Virtual Switch to do this? I have an app that will use a virtual switch to run Hello Home functions⌠Will this work? It will be more future proof i think.
I have been using the virtual switch idea in combination with Endpoints/Tasker/AutoVoice to trigger light with my voice. Does your app integrate with Tasker/AutoVoice or have any voice controls baked in?
Negative, but it will use virtual switches to run hello home actions. github.com/tslagle13 is where you can find my code for it
Big switch for hello home actions is the name.
I think this will get what you need Let me know if this isnât what you want and i can edit the app to include the changes you need
Cool, just tried it out. Looks like it works well! This will definitely work with some of my scenarios. One that it wonât work with, though, is where I want certain lights to turn off, certain lights to turn on to 35% and others to turn on at 100%. This is why youâll notice two specific dimmer level preferences in the app nelemansc and I have been working on. Looks like Hello, Home only allows you to specify one dimmer % for ALL lights that you want turned on.
That said, I will definitely use your app for certain scenarios; however, it would still be great if I could get this app going, too.
[quote=âtriggertact, post:50, topic:1906â]That said, I will definitely use your app for certain scenarios; however, it would still be great if I could get this app going, too.
[/quote]
Sure thing. I am currently working on another app. Iâll take a look a tthis one after that
Hey @tslagle13, just thought Iâd check back if youâve had a chance to work on the app yet. Thanks again for the help!
Working on it Have the basic app wirtten
I want to make this production level quality so we can share it with the community.
@triggertact just wanted to remind you, because @tslagle13 is just too nice a guy to remind you (SMILE) that he isnât a full time developer here on the board. He. like most of us enjoy helping others. I am probably being out of line here. But. I just want to be sure you understand he is working on this out of the kindness of his heart. That is all.
When you figure things out, remember to follow his lead and give back to the community as he does.
Ok, give this a try. I hope i understood you correctly but basically you can turn on a virtual switch and have it turn on a âsceneâ then turn off that same virtual switch and have it turn on another âsceneâ all customizable by you
Let me know if this works for your needs.
definition(
name: "Multi Level Dimmer Scene Controller via Virtual Switch",
namespace: "tslagle13",
author: "Tim Slagle",
description: "Use a virtual switch to control a 'scene' with multiple dim levels.",
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 {
page( name:"masterSwitch", title:"Master Switch", nextPage:"sceneOn", uninstall:true, install:false ) {
section("Which siwtch will control the scene(s)?"){
input "theSwitch", "capability.switch"
}
}
page( name:"sceneOn", title:"Scene On", nextPage:"sceneOff", uninstall:true, install:false ) {
section("Dim these to Level 1...") {
input "switches1", "capability.switchLevel", multiple: true, required: false
}
section("Level 1"){
input "lvl1", "number", required: false
}
section("Dim these 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
}
}
page( name:"sceneOff", title:"Scene Off", uninstall:true, install:true ) {
section("Dim these to Level 1...") {
input "switches3", "capability.switchLevel", multiple: true, required: false
}
section("Level 1"){
input "lvl3", "number", required: false
}
section("Dim these to Level 2...") {
input "switches4", "capability.switchLevel", multiple: true, required: false
}
section("Level 2"){
input "lvl4", "number", required: false
}
section("Turn ON these lights..."){
input "switch3", "capability.switch", multiple: true, required: false
}
section("Turn OFF these lights..."){
input "switch4", "capability.switch", multiple: true, required: false
}
}
}
def installed(){
subscribe(theSwitch, "switch.On", onHandler)
subscribe(theSwitch, "switch.Off", offHandler)
}
def updated() {
subscribe(theSwitch, "switch.On", onHandler)
subscribe(theSwitch, "switch.Off", offHandler)
}
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()
}
def offHandler(evt) {
log.info evt.value
log.info "lvl3: $lvl1.value"
log.info "lvl4: $lvl2.value"
switches3.setLevel(lvl3.value)
switches4.setLevel(lvl4.value)
switch3.on()
switch4.off()
}
Hi @theedpope, I appreciate the reminder. No worries on feeling out of line as I completely understand where youâre coming from. @tslagle13 is definitely very gracious to help me out and Iâve made sure to express my thanks. Thanks again @tslagle13 ! I will continue to help others in the forum with any knowledge I gain as a result.
@tslagle13, regarding the new code, I must apologize as I accidentally sent you down a path I wasnât intending. Hopefully the changes made didnât take up too much of your time! I think itâs tough to explain the specifics of what Iâm looking for via text, versus over the phone or in person, if you know what I mean.
Anyways, essentially what Iâm looking for is something closer to the way the last iteration of the code was setup. In the last version, I believe only the Virtual Switch being turned ON triggered the preferences in the scene to occur. And then at the end of the scene it reset the Virtual Switch back to the OFF position. I think this was all working fine before; however, it didnât seem to be executing the preferences specified in the scene properly. In other words, if I had set one light to turn ON to 90%, another to 35%, and another to turn OFF all simultaneously when the Virtual Switch was turned ON, then what would happen is both the lights set to turn ON did as specified but the one light specified to turn OFF would not. I think that was really the only problem I was having.
Again, itâs sort of a tough scenario to explain clearly through text, so hopefully Iâm making sense. Maybe giving some context might help. The main situation I envision this being used is when I plan to watch a movie in my great room. I will have AutoVoice on my phone come up and I will say a specified command, which will trigger an HTTP Get action in Tasker, which will turn the Virtual Switch for this scene ON, which will turn certain lights ON to specified levels in and around my great room and certain lights OFF. Lastly, the scene will turn the Virtual Switch back to the OFF position so it can trigger again in the future.
I really do appreciate all your help so I hope this is not much of a burden!
Got it now⌠Iâll get back to you
Sorry for the wait. Got super busy at work.
Here you go. This should work as expected now To be clear it can turn on two sets of lights to two different dim levels, turn off a set of lights and turn on a set of lights. If you only want to use some of those cases then you can pick and choose. it no longer requires all the variables to be set. It also turns the Virtual Switch you are monitoring back off when it is done.
I think thats what we talked about
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
if (lvl1){
switches1.setLevel(lvl1.value)
}
if (lvl2){
switches2.setLevel(lvl2.value)
}
if(switch1){
switch1.on()
}
if(switch2){
switch2.off()
}
theSwitch.off()
}
def onHandler(evt) {
log.info evt.value
if (lvl1){
switches1.setLevel(lvl1.value)
}
if (lvl2){
switches2.setLevel(lvl2.value)
}
if(switch1){
switch1.on()
}
if(switch2){
switch2.off()
}
theSwitch.off()
}
def offHandler(evt) {
log.debug "Received off from ${theSwitch}"
}
def initialize() {
subscribe(theSwitch, "switch.On", onHandler)
}
@triggertact Did this work?
Hey @tslagle13, so far it looks perfect! However, Iâm away from home right now so I canât check for sure. Iâll do that as soon as I get home tonight and report back tomorrow. Again, really appreciate your help!
Hey @tslagle13, I am happy to report that the app is working wonderfully! I think people will be very pleased with it if they want to control their lights using voice commands on their Android phone through tasker. Canât thank you enough for the help as I would never have been able to figure it out on my own!