Jump to content
View in the app

A better way to browse. Learn more.

Universal Devices Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Creating a Toggle out of a button

Featured Replies

Posted

I wrote this little program thinking it would tun off the lights in the kitchen (the scene) if any of the lights were on.  And if the lights were all off it would turn on the typical light selection. But it will turn all the lights off and immediately turn the two lights on that are mentioned in the "Else".  I tried putting a "stop program" command under the "Then" commands but that didn't seem to do anything.  Has anyone had luck creating a toggle like function into a single press of a button?

IR06 - [ID 0012][Parent 000B]

If
        IR 'IR_006' is Pressed
    And (
             Status  'Kitchen Cans' is not Off
          Or Status  'Kitchen Pendant' is not Off
          Or Status  'Kitchen Sink' is On
          Or Status  'Kitchen flouresc living' is not Off
          Or Status  'Kitchen flouresc living' is not Off
        )
 
Then
        Set Scene 'Kitchen Lights' Off
 
Else
        Set 'Kitchen Pendant' On
        Set 'Kitchen Sink' On
 

David

What's happening is that the act of turning all of the lights off triggers the program to be re-evaluated, comes up false and then follow the else path.  Since the lights act like state variables and cause the program to be immediately re-evaluated, what I'd usually fix this by creating as second program with more fine-grained conditions and put the Else into the Then statement of it.

I'd probably use an integer variable, so the then becomes:

$Variable = 0
Set Scene Off
Wait 5 seconds
$Variable = 1

Then use that 1/0 variable as a condition on the second program, so that the If reads:

$Variable is 1
And Status of all lights
And IR_006 is pressed

And then make the Then part your current Else statement.

I believe there's a flag that only allows a program to run if it hasn't been run in a certain period of time that's now built into the 5.x firmware, but I've never used it so can't speak to it. :)

I think jec6613 correctly diagnosed the problem.  I don’t know that variables are the simple solution, however.

What about modifying your original program:

- disable it

- remove the first condition (if ir006 is pressed)

Then, add a second program such as:

if

if ir006 is pressed

then

run modified IR 06 program (if path)

 

 

  • Author

hmm.  I have a state variable set up for my leak sensors and it is a bit complicated but doable.  I might try the disabling solution first when I have time.  For now, my wife and I had a good laugh as to why she couldn't tun off the lights. :)  Yeah, that's me - left the bad program enabled and went to bed. 

David

Guest
This topic is now closed to further replies.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.