Take Action Based On Status of a Percentage of Devices? (IF ANY 2 of 4 Switches are ON, then DO THIS)


(ocpd+adhd+alz+md+hfa+fms+lol=me :)) #1

I am working on Presence (i.e. is somebody present or not present?).

In that effort, I’m looking at all kinds of different ‘work-around’ options for getting accurate presence status. What I am thinking of doing right now is implementing more than one methodology (with the hope that more data-points will/could result in a more reliable Presence status).

For this, I’m thinking of using multiple virtual/simulated switches; one for each of the various alternate presence methods that I implement (that is, one each for each person), and a simulated Presence Device to act as a ‘Consolidated Presence Status Device’ for all of the other ones for each person…

So, if I have 4 virtual switches representing the different presence methods for a person, what do I need to do to have the system work like the following?..

If ANY TWO of the four virtual switches are ON, then the system will turn the Consolidated Presence State vSwitch for that person ON.


(Jody) #2

Create an array of presence devices that are present and one for devices that are away.

if (present.size() >= 2) {
 do stuff 
}

if (away.size() >= 2) {
 do stuff
}

(John) #3

This sounds similar to what you are trying to create:


(ocpd+adhd+alz+md+hfa+fms+lol=me :)) #4

Ooo, I get the logic. This is great! :slight_smile:

Now, any chance anybody would be willing to point me in the correct direction for figuring out what to do with this code…where to put it…are we talking about creating a SmartApp?