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.

Program "If any two devices are on"

Featured Replies

Posted

Is it possible to create a program what would look at a list of several devices in my house and if the state of ANY two of the devices are ON, then it would execute the program? (Any two or more of the devices must be ON for the program to execute)

 

Thanks,

Chris

I think you would need at least two programs for this:

 

1. a program that responds to any of the devices turning on and adds '1' to a state variable ... if it turns off then it subtracts '1'

2. a programs that responds to the state variable changing ... if it is greater than or equal to 2 then execute your intended code

I suspect this can be done with a single program through brute force, but it would get ugly quick if the number of devices gets much beyond three or four. 

 

if

(A and B is on)

or

(A or C is on)

or

(B or C is on)

or

.....

then

do something

 

As the number of devices grow, the approach proposed by bleepborp may become relatively more efficient.

  • Author

Thanks guys. Both great suggestions!

If you have more than a few devices that you would like, it may work better to use state variables.

If Device_A is On then
     $State_Device_A = 1
Else
     $State_Device_A = 0
If Device_B is On then
     $State_Device_B = 1
Else
     $State_Device_B = 0
If (List all Devices here, we just want them in the IF block to trigger this whenever any of them change) Then
     $State_Device_Count = $State_Device_A
     $State_Device_Count =+ $State_Device_B
Else (Same as Then so it works no matter what the IF conditions are)
     $State_Device_Count = $State_Device_A
     $State_Device_Count =+ $State_Device_B

At this point, $State_Device_Count will reflect how many devices are on and you can run programs from that.

It would also be a good idea to sync Integer versions of the variables to give you program flexibility along with the Init To values for reliability. 

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.