kzboray Posted May 20, 2023 Posted May 20, 2023 I have this program that I want to create a UD Mobile favorite for. I want the first tap to activate the THEN portion of the program and the second tap to activate the ELSE. I tried a few times to find a way to accomplish this and I haven't found the secrete sauce. Anyone here done anything similar? Living Room KPS8 Lights Scene 1 - [ID 002C][Parent 0034] If 'Living Room / LivingRm KPD8.c DinRm Scene 1' is switched On And 'Living Room / LivingRm KPD8.c DinRm Scene 1' is not switched Off Then Set 'Dining Room / Dining Room Lights / LIFX Dinning Room Light 1' Hue 15400 Saturation 65535 Brightness 65535 Color Temp 3500° K in 0 ms Set 'Dining Room / Dining Room Lights / LIFX Dinning Room Light 2' Hue 45800 Saturation 65535 Brightness 65535 Color Temp 9000° K in 0 ms Set 'Living Room / Living Room Chandelier / LIFX Chand-1 Mini 519C71' Hue 15400 Saturation 65535 Brightness 65535 Color Temp 3500° K in 0 ms Set 'Living Room / Living Room Chandelier / LIFX Chand-2 Mini 3F2BB9' Hue 45800 Saturation 65535 Brightness 65535 Color Temp 9000° K in 0 ms Set 'Living Room / Living Room Chandelier / LIFX Chand-3 Mini 383074' Hue 15400 Saturation 65535 Brightness 65535 Color Temp 3500° K in 0 ms Set 'Living Room / Living Room Chandelier / LIFX Chand-4 Mini 3D8961' Hue 45800 Saturation 65535 Brightness 65535 Color Temp 9000° K in 0 ms Set 'Living Room / Living Room Chandelier / LIFX Chand-5 Mini 3D90ED' Hue 15400 Saturation 65535 Brightness 65535 Color Temp 3500° K in 0 ms Set 'Dining Room / Dining Room Lights / Dining Room Lights' On Set 'Living Room / Living Room Chandelier / LivingRm Chandelier' On Else Set 'Dining Room / Dining Room Lights / Dining Room Lights' Off Set 'Living Room / Living Room Chandelier / LivingRm Chandelier' Off Thank you!
Javi Posted May 20, 2023 Posted May 20, 2023 I think you need Status not Control as the If conditions. In the currently condition both switches would need to be physically controlled at the same time to be true. https://wiki.universal-devices.com/index.php?title=UD_Mobile#Favorite_Custom_Toggle 1 1
kzboray Posted May 20, 2023 Author Posted May 20, 2023 (edited) @Javi No rush on the response, I'll play with it a bit more but here's the initial results of changing from CONTROL to STATUS monitoring. With this programming pressing the 8-button key ON does not trigger the THEN portion of the program. The OFF check in line two prevents it from triggering. So I can turn the lights off, but not on with this. Living Room KPS8 Lights Scene 1 - [ID 002C][Parent 0034] If 'Living Room / LivingRm KPD8.c DinRm Scene 1' Status is On And 'Living Room / LivingRm KPD8.c DinRm Scene 1' Status is not Off Then Set 'Dining Room / Dining Room Lights / LIFX Dinning Room Light 1' Hue 15400 Saturation 65535 Brightness 65535 Color Temp 3500° K in 0 ms Set 'Dining Room / Dining Room Lights / LIFX Dinning Room Light 2' Hue 45800 Saturation 65535 Brightness 65535 Color Temp 9000° K in 0 ms Set 'Living Room / Living Room Chandelier / LIFX Chand-1 Mini 519C71' Hue 15400 Saturation 65535 Brightness 65535 Color Temp 3500° K in 0 ms Set 'Living Room / Living Room Chandelier / LIFX Chand-2 Mini 3F2BB9' Hue 45800 Saturation 65535 Brightness 65535 Color Temp 9000° K in 0 ms Set 'Living Room / Living Room Chandelier / LIFX Chand-3 Mini 383074' Hue 15400 Saturation 65535 Brightness 65535 Color Temp 3500° K in 0 ms Set 'Living Room / Living Room Chandelier / LIFX Chand-4 Mini 3D8961' Hue 45800 Saturation 65535 Brightness 65535 Color Temp 9000° K in 0 ms Set 'Living Room / Living Room Chandelier / LIFX Chand-5 Mini 3D90ED' Hue 15400 Saturation 65535 Brightness 65535 Color Temp 3500° K in 0 ms Set 'Dining Room / Dining Room Lights / Dining Room Lights' On Set 'Living Room / Living Room Chandelier / LivingRm Chandelier' On Else Set 'Dining Room / Dining Room Lights / Dining Room Lights' Off Set 'Living Room / Living Room Chandelier / LivingRm Chandelier' Off Changing the program to this. Allows a button push to activate the THEN portion, but breaks the ELSE. Meaning I can turn the lights on, but not off. Living Room KPS8 Lights Scene 1 - [ID 002C][Parent 0034] If 'Living Room / LivingRm KPD8.c DinRm Scene 1' Status is On Then Set 'Dining Room / Dining Room Lights / LIFX Dinning Room Light 1' Hue 15400 Saturation 65535 Brightness 65535 Color Temp 3500° K in 0 ms Set 'Dining Room / Dining Room Lights / LIFX Dinning Room Light 2' Hue 45800 Saturation 65535 Brightness 65535 Color Temp 9000° K in 0 ms Set 'Living Room / Living Room Chandelier / LIFX Chand-1 Mini 519C71' Hue 15400 Saturation 65535 Brightness 65535 Color Temp 3500° K in 0 ms Set 'Living Room / Living Room Chandelier / LIFX Chand-2 Mini 3F2BB9' Hue 45800 Saturation 65535 Brightness 65535 Color Temp 9000° K in 0 ms Set 'Living Room / Living Room Chandelier / LIFX Chand-3 Mini 383074' Hue 15400 Saturation 65535 Brightness 65535 Color Temp 3500° K in 0 ms Set 'Living Room / Living Room Chandelier / LIFX Chand-4 Mini 3D8961' Hue 45800 Saturation 65535 Brightness 65535 Color Temp 9000° K in 0 ms Set 'Living Room / Living Room Chandelier / LIFX Chand-5 Mini 3D90ED' Hue 15400 Saturation 65535 Brightness 65535 Color Temp 3500° K in 0 ms Set 'Dining Room / Dining Room Lights / Dining Room Lights' On Set 'Living Room / Living Room Chandelier / LivingRm Chandelier' On Else Set 'Dining Room / Dining Room Lights / Dining Room Lights' Off Set 'Living Room / Living Room Chandelier / LivingRm Chandelier' Off So I need to leave the statements as CONTROL for it to work in the home. Is there a way to create a toggle in UD Mobile with it set as CONTROL? If not can I create a toggle that calls one program with the first tap of a UD Mobile favorites and then a second program with the second tap? If so I can split this into two programs one for ON and another for OFF both using STATUS. Thank you! Edited May 20, 2023 by kzboray
larryllix Posted May 20, 2023 Posted May 20, 2023 Try. ths one. It used to work based on the order that ISY checks status vs triggers from devices. However if you are playing with a KPL they send out a toggled status regardless of which format you have them set at, or actual last real status position. A little known bug in Insteon's logic at the time. I can't remember the exact problem but Michel discussed this with me a few years ago on KPLs Living Room KPS8 Lights Scene 1 - [ID 002C][Parent 0034] If 'Living Room / LivingRm KPD8.c DinRm Scene 1' Control is Switched On <-------- And 'Living Room / LivingRm KPD8.c DinRm Scene 1' Status is Off <---------- Then Set 'Dining Room / Dining Room Lights / LIFX Dinning Room Light 1' Hue 15400 Saturation 65535 Brightness 65535 Color Temp 3500° K in 0 ms Set 'Dining Room / Dining Room Lights / LIFX Dinning Room Light 2' Hue 45800 Saturation 65535 Brightness 65535 Color Temp 9000° K in 0 ms Set 'Living Room / Living Room Chandelier / LIFX Chand-1 Mini 519C71' Hue 15400 Saturation 65535 Brightness 65535 Color Temp 3500° K in 0 ms Set 'Living Room / Living Room Chandelier / LIFX Chand-2 Mini 3F2BB9' Hue 45800 Saturation 65535 Brightness 65535 Color Temp 9000° K in 0 ms Set 'Living Room / Living Room Chandelier / LIFX Chand-3 Mini 383074' Hue 15400 Saturation 65535 Brightness 65535 Color Temp 3500° K in 0 ms Set 'Living Room / Living Room Chandelier / LIFX Chand-4 Mini 3D8961' Hue 45800 Saturation 65535 Brightness 65535 Color Temp 9000° K in 0 ms Set 'Living Room / Living Room Chandelier / LIFX Chand-5 Mini 3D90ED' Hue 15400 Saturation 65535 Brightness 65535 Color Temp 3500° K in 0 ms Set 'Dining Room / Dining Room Lights / Dining Room Lights' On Set 'Living Room / Living Room Chandelier / LivingRm Chandelier' On Else Set 'Dining Room / Dining Room Lights / Dining Room Lights' Off Set 'Living Room / Living Room Chandelier / LivingRm Chandelier' Off
DennisC Posted May 20, 2023 Posted May 20, 2023 Are you opposed to using two UD Mobile favorites? If not, you could create two command type favorites, one to run then (on) and one to run else (off).
kzboray Posted May 20, 2023 Author Posted May 20, 2023 @DennisC I thought about it, but it's not intuitive and would break the wife model of happiness. It's the last resort, but workable. 1
DennisC Posted May 20, 2023 Posted May 20, 2023 Just now, kzboray said: @DennisC I thought about it, but it's not intuitive and would break the wife model of happiness. It's the last resort, but workable. Understood, in my case, my wife is most happy with things clearly labeled on/off. That way she doesn't have to remember is it one press or two presses. As I was writing this, I had a thought that I haven't fully explored but will mention it in case you want to look in to it. Would it be possible to write an intermediate program that monitors your existing program for on/off and triggers the opposite? Then have UD Mobile favorite control the new program. That way you are only using one press of the favorite and the second program triggers the first program opposite of the current state. Hope that makes sense. 1
kzboray Posted May 20, 2023 Author Posted May 20, 2023 @larryllix I went ahead and tried a few variations on what you had discussed. The best case was with the code you listed. Unfortunately it results in the scene triggering with a button press, Ya! and then immediately shuts off without any intervention. I also tried And 'Living Room / LivingRm KPD8.c DinRm Scene 1' Status is not Off But then the lights wouldn't turn on or off. The right way to do this is using CONTROL, I'm trying to fix a limitation of UD mobile by working around it with STATUS in AC. This isn't the right solution. I'm going to create some intermediate programs as suggested by @DennisC and see if I can't do it that way. Maybe just setup a STATE variable and toggle that.
Javi Posted May 20, 2023 Posted May 20, 2023 For a UDM Custom Toggle the condition needs to be Status. Control implies physical touch of a button. The program also needs to be disabled so it does not run in a loop. The next issue is how the condition (toggle) is evaluated. In your program you are using a physical button as condition. So this button needs to be switched on/off in the actions (then/else) or it will always be evaluated the same. In your program this will need to be a scene as keypad buttons do not have direct control. To simplify this lets remove all the lighting controls and only focus on the status and condition evaluation. Because this is an insteon keypad we need a scene (again as keypad buttons can not be controlled directly) So our standard keypad scene (without modifications to controls) Our DISABLED Program Our UDM Command Button. Notes: This uses Display Node of the Keypad Button Scene and Display Status of Estimated Status to show user if the toggle is on or off. But this could be changed to the Keypad Button itself. The program is set to command "Run IF" Now that the toggle is working you can add other actions. 1
kzboray Posted May 20, 2023 Author Posted May 20, 2023 (edited) @Javi Thank you for the details! I understand how it is all is supposed to work. Unfortunately the lines of code that actually change the individual bulb settings (see below) when added to a scene do not retain their values and instead inherit the last used values. So, I have had to hard code them to each button. I do use a scene to active the currently selected settings, but that's as close to a scene as I can get for this purpose. Set 'Dining Room / Dining Room Lights / LIFX Dinning Room Light 1' Hue 15400 Saturation 65535 Brightness 65535 Color Temp 3500° K in 0 ms Set 'Dining Room / Dining Room Lights / LIFX Dinning Room Light 2' Hue 45800 Saturation 65535 Brightness 65535 Color Temp 9000° K in 0 ms Set 'Living Room / Living Room Chandelier / LIFX Chand-1 Mini 519C71' Hue 15400 Saturation 65535 Brightness 65535 Color Temp 3500° K in 0 ms Set 'Living Room / Living Room Chandelier / LIFX Chand-2 Mini 3F2BB9' Hue 45800 Saturation 65535 Brightness 65535 Color Temp 9000° K in 0 ms Set 'Living Room / Living Room Chandelier / LIFX Chand-3 Mini 383074' Hue 15400 Saturation 65535 Brightness 65535 Color Temp 3500° K in 0 ms Set 'Living Room / Living Room Chandelier / LIFX Chand-4 Mini 3D8961' Hue 45800 Saturation 65535 Brightness 65535 Color Temp 9000° K in 0 ms Set 'Living Room / Living Room Chandelier / LIFX Chand-5 Mini 3D90ED' Hue 15400 Saturation 65535 Brightness 65535 Color Temp 3500° K in 0 ms So I'm limited by design. When I get a chance I'll play with intermediate programs to set variables and maybe find a solution that way. The example program I used is one of eight pre-programmed party lights scenes that get used quite often. It would of been nice to add them all to UD Mobile, but sixteen icons ON/OFF X8 for a single purpose is too many, so I was hoping I had missed some function in UD that would allow me to duplicate the 8-button keypads function more closely. Cest a la vie. My last working 8-button remote will have to continue to serve as the portable mood setting device. But I really do appreciate everyone's interest and help! I am never disappointed by the truly amazing people here in UD land. People like @Geddy, @MrBill, @DennisC, and so many other regulars on the forums and of course the UD team starting with @Michel Kohanim, @Javi, @bmercier, and @bpwwer Edited May 20, 2023 by kzboray 1
kzboray Posted May 20, 2023 Author Posted May 20, 2023 @larryllix A personal thank you for all you do! 1 1
MrBill Posted May 20, 2023 Posted May 20, 2023 @kzboray Use Javi's program to manage the button with a scene and coordinate UD mobile, but add a second line Run Program SetWhatever (then) or Run Program Setwhatever (else) 3 1
Javi Posted May 20, 2023 Posted May 20, 2023 As @MrBillsuggested. No need to add the other devices to the scene. A separate program is needed if the current program is being used to to trigger physical button presses. Most important part is that it is disabled as it would cause a vicious loop if it is automatically evaluated. 3
larryllix Posted May 21, 2023 Posted May 21, 2023 15 hours ago, kzboray said: @larryllix I went ahead and tried a few variations on what you had discussed. The best case was with the code you listed. Unfortunately it results in the scene triggering with a button press, Ya! and then immediately shuts off without any intervention. I also tried And 'Living Room / LivingRm KPD8.c DinRm Scene 1' Status is not Off But then the lights wouldn't turn on or off. The right way to do this is using CONTROL, I'm trying to fix a limitation of UD mobile by working around it with STATUS in AC. This isn't the right solution. I'm going to create some intermediate programs as suggested by @DennisC and see if I can't do it that way. Maybe just setup a STATE variable and toggle that. Then split it into two programs. One to sense the trigger and one to decide which way to go (and disabled so it cannot retrigger) Living Room KPS8 Lights Scene 1 - [ID 002C][Parent 0034] If 'Living Room / LivingRm KPD8.c DinRm Scene 1' Control is Switched On <-------- Then run Program2 (if) Else ---- Living Room KPS8 Program 2 * * *[DISABLED]* * * If And 'Living Room / LivingRm KPD8.c DinRm Scene 1' Status is Off Then Set 'Dining Room / Dining Room Lights / LIFX Dinning Room Light 1' Hue 15400 Saturation 65535 Brightness 65535 Color Temp 3500° K in 0 ms Set 'Dining Room / Dining Room Lights / LIFX Dinning Room Light 2' Hue 45800 Saturation 65535 Brightness 65535 Color Temp 9000° K in 0 ms Set 'Living Room / Living Room Chandelier / LIFX Chand-1 Mini 519C71' Hue 15400 Saturation 65535 Brightness 65535 Color Temp 3500° K in 0 ms Set 'Living Room / Living Room Chandelier / LIFX Chand-2 Mini 3F2BB9' Hue 45800 Saturation 65535 Brightness 65535 Color Temp 9000° K in 0 ms Set 'Living Room / Living Room Chandelier / LIFX Chand-3 Mini 383074' Hue 15400 Saturation 65535 Brightness 65535 Color Temp 3500° K in 0 ms Set 'Living Room / Living Room Chandelier / LIFX Chand-4 Mini 3D8961' Hue 45800 Saturation 65535 Brightness 65535 Color Temp 9000° K in 0 ms Set 'Living Room / Living Room Chandelier / LIFX Chand-5 Mini 3D90ED' Hue 15400 Saturation 65535 Brightness 65535 Color Temp 3500° K in 0 ms Set 'Dining Room / Dining Room Lights / Dining Room Lights' On Set 'Living Room / Living Room Chandelier / LivingRm Chandelier' On Else Set 'Dining Room / Dining Room Lights / Dining Room Lights' Off Set 'Living Room / Living Room Chandelier / LivingRm Chandelier' Off 2
GRYBD1 Posted June 28, 2023 Posted June 28, 2023 Maybe too late to help but I think the goal can be achieved by using two programs and a variable. One program that runs when the status of the keypad button changes. It uses "status" and has the "Set" commands. In addition is updates the value of a variable. Like this. (sorry devices are names in my system) Program Test2 if 'Devices / 1st Floor / 1st Floor GR FP Lights / 1st Floor GR FP Lights SC' Status is On then $Integer_test1 = 1 Set ... Else $Integer_test1 = 0 Set ... With this program the keypad button should turn everything on and off. An important point is to make sure the then/else conditions DO NOT turn on/off any scene for which the keypad button is a controller/responder, otherwise you will repeatedly retrigger the "if" and get a loop. Having said that the keypad button does need to be a controller/responder for a scene, just not one that is set by the program. In the original example maybe leave "LivingRm Chandelier" out of the program and just let the scene turn it on and off. Add a UD Mobile favorite, a command button should work. Display Node: should be the integer "Integer_test1" Display Status: "Value" Commands: program Test1 SET Run if Using the "Configure" option for the for the UD Mobile favorite the color can be changed, and value displayed as "On"/"Off". Program Test1 if $Integer_test1 is 0 then Set 'Devices / 1st Floor / 1st Floor GR Lamp' On else Set 'Devices / 1st Floor / 1st Floor GR Lamp' Off Here the scene that is turned on/off must be the scene that includes the keypad button as the controller/responder. By doing that a status event will be created for the keypad button and the Test2 program triggered. In my example "1st Floor GR FP Lights SC" is the keypad button that is the controller/responder for the "1st Floor GR Lamp" scene. Turn the lights on with UD Mobile and off with the keypad or vice versa. Both will show the current status.
MrBill Posted June 28, 2023 Posted June 28, 2023 29 minutes ago, GRYBD1 said: Maybe too late to help but I think the goal can be achieved by using two programs and a variable. One program that runs when the status of the keypad button changes. It uses "status" and has the "Set" commands. In addition is updates the value of a variable. Like this. (sorry devices are names in my system) Program Test2 if 'Devices / 1st Floor / 1st Floor GR FP Lights / 1st Floor GR FP Lights SC' Status is On then $Integer_test1 = 1 Set ... Else $Integer_test1 = 0 Set ... With this program the keypad button should turn everything on and off. An important point is to make sure the then/else conditions DO NOT turn on/off any scene for which the keypad button is a controller/responder, otherwise you will repeatedly retrigger the "if" and get a loop. Having said that the keypad button does need to be a controller/responder for a scene, just not one that is set by the program. In the original example maybe leave "LivingRm Chandelier" out of the program and just let the scene turn it on and off. Add a UD Mobile favorite, a command button should work. Display Node: should be the integer "Integer_test1" Display Status: "Value" Commands: program Test1 SET Run if Using the "Configure" option for the for the UD Mobile favorite the color can be changed, and value displayed as "On"/"Off". Program Test1 if $Integer_test1 is 0 then Set 'Devices / 1st Floor / 1st Floor GR Lamp' On else Set 'Devices / 1st Floor / 1st Floor GR Lamp' Off Here the scene that is turned on/off must be the scene that includes the keypad button as the controller/responder. By doing that a status event will be created for the keypad button and the Test2 program triggered. In my example "1st Floor GR FP Lights SC" is the keypad button that is the controller/responder for the "1st Floor GR Lamp" scene. Turn the lights on with UD Mobile and off with the keypad or vice versa. Both will show the current status. A state variable, not integer variable, must be used in this case.
GRYBD1 Posted June 28, 2023 Posted June 28, 2023 9 hours ago, MrBill said: A state variable, not integer variable, must be used in this case. Changes to the value of a state variable cause an event to be triggered. Program Test1 should only be run when the UD Mobile shortcut is pressed, it should not run when the value of the variable changes. Therefore, I believe an integer variable is the correct choice for this. Testing with an integer variable works fine, I have not tested using a state variable but suspect doing so would probably cause a loop.
hart2hart Posted June 28, 2023 Posted June 28, 2023 It may not be relevant but just more information… you might use a state variable if you Disable the program as first step Set the state variableEnable the program
MrBill Posted June 28, 2023 Posted June 28, 2023 13 hours ago, GRYBD1 said: if $Integer_test1 is 0 will never trigger Program Test1 to run at all. the only way the THEN and ELSE in that program will every run is if they are run by another program or manually run.
brians Posted June 28, 2023 Posted June 28, 2023 (edited) You need a variable (not state) to keep track of the status of the light - update your existing program to set that variable. eg. kps8stat=1 or kps8stat=0. Then make a new toggle program like Javi linked to and run-if this new program, when press the button in UD Mobile... the if will test the variable status eg. kps8stat to run either if/then of your actual program that turns lights on/off and that program will also update this variable status. The variable status will update if toggled manually. You many have to make another scene to set the KPL LED status if toggled from UD Mobile. You can also use that variable to set the button status in UD Mobile - eg. change color etc. Edited June 28, 2023 by brians 1
GRYBD1 Posted June 29, 2023 Posted June 29, 2023 On 6/28/2023 at 10:56 AM, MrBill said: On 6/27/2023 at 9:17 PM, GRYBD1 said: if $Integer_test1 is 0 will never trigger Program Test1 to run at all. the only way the THEN and ELSE in that program will every run is if they are run by another program or manually run. Agreed. On 6/28/2023 at 6:56 AM, GRYBD1 said: Program Test1 should only be run when the UD Mobile shortcut is pressed, it should not run when the value of the variable changes.
dbwarner5 Posted August 24, 2023 Posted August 24, 2023 @kzboray per Javi post, I think its pretty simple in that you can have your "toggle" program be as the following, and wehre it is DISABLED, and in THEN adn ELSe, just call your other program's Then, Else and eliminate the if there. This is an example of what I use for a Toggle. works perfectly. Set UD mobile to run the If. Replaced THEN and ELSE with Run Then Living Room KPS8 Lights Scene 1 And Run ELSE Living Room KPS8 Lights Scene 1 If you still need the other buttons as a trigger use control in that if statement. Rus Bedroom LD - [ID 0378][Parent 0377][Not Enabled] If 'RussoundCtl_1 / Bedroom Sound' Power is Off Then Set 'RussoundCtl_1 / Bedroom Sound' Zone On Else Set 'RussoundCtl_1 / Bedroom Sound' Zone Off 1
Recommended Posts