Local Variables comparing


#1

I understand that I can call a local variable in a piston to have the same value if there are two or more items.

But what if want both of the items in the variable to be different in a condition.

Ex. I can do device 1 and device 2 is present or not present in a local variable but what if I want to call that variable and have device 1 is present but device 2 is not present. How would that work?


#2

If I’m reading what you’re asking properly then you just AND them together, like this:

IF VariableA = 123
and
VaraibleB is not equal to 123
then

In order for that IF to be true, both parts must be true.


#3

If I define
device presenceFamily = person 1 and person 2
device presenceSndor = /*not variable */

I don’t think I can have WC look to see if both presence people are there. I didnt want to define two separate presenceFamily


#4

It might be best if you give an example of what you’re trying to accomplish with this. So rather than trying to solve your question we can instead help you accomplish your goal. There might be a way to get done what you want to do but it might be a different idea than what you have.

But if you’re talking about knowing the number of presence sensors that are present from a list, then you pretty much need to manage that yourself. Some people do it by making another integer variable and putting in the count of people who are present. When someone comes home you add 1 to the variable, and when someone leaves you subtract 1. That way the system always knows how many people are there.

If that’s not what you’re asking…then again, give us another example.


#5

Sorry. Here is the piston.

As you can see I made a variable to have both presence sensors in one. What i realize is doing this will never allow this piston to say when only one person is home. I assume I would have to break presenceFamily into two variables separately.


#6

You can do something like this though: This will substitute for your first two triggers. The third IF statement that you have can likely be left in tact as that more of a condition than a trigger, so it will work as is.


#7

Sure i get that. What i was going for though was if I had both variables in a defined device on page 18 can I set it later in the piston to look if one person is home but the other one isn’t? Instead of breaking them back I to individual presenses.


#8

Well, if you’re dead set on putting both presence sensors into a device variable, then I suppose you could always loop through the device variable and check for presence that way. Then they would indeed stay in the device variable. But the variable which contains the matching devices is only going to contain the one that just arrived or departed.


#9

That is what I thought. I was just trying to prevent having to call the individual presence sensors in case I had to change the sensors down the road.


#10

Yeah, but nothing prevents you from putting each sensor into its own variable…

define
MyPhone = Google Pixel
GFPhone = iPhone6

If any of MyPhone or GFPhone changes to present

Six of one…