s1r
(Alex Panzetta)
March 13, 2017, 7:17pm
1
I’m n00b, I know…I am trying to do an IF statement that checks multiple items like:
[ITEMS]
//Phones
Switch Phone1 "Phone 1" { channel="network:device:10_1_10_234:online" }
Switch Phone2 "Phone 2" { channel="network:device:10_1_10_98:online" }
Switch Phone3 "Phone 3" { channel="network:device:10_1_10_234:online" }
[RULE]
if (Phone1.state == OFF && Phone1.state == OFF && Phone1.state == OFF)
{
logInfo("PRESENCE","No phone is connected")
}
I just tried it with Phone1 connected and the other 2 offline and it executes the loginfo…what is wrong with this? Is it ok to use && as an AND operator?
hamwong
(Ham Wong)
March 13, 2017, 7:21pm
2
I see no difference on 3 items in rules, all is if Phone1 is off
s1r
(Alex Panzetta)
March 13, 2017, 7:22pm
3
Phone1 is now ON while Phone2/3 are off so i would expect no loginfo to happen and yet it is happening and I am not sure why
rossko57
(Rossko57)
March 13, 2017, 7:34pm
4
As hamwong says, look again at what you showed us
if (Phone1.state == OFF && Phone1.state == OFF && Phone1.state == OFF)
All the terms are Phone1
There is no mention of Phone2 and Phone3
s1r
(Alex Panzetta)
March 13, 2017, 7:35pm
5
Ahhh now I see what you mean, that was a typo sorry, the correct statement is:
if (Phone1.state == OFF && Phone2.state == OFF && Phone3.state == OFF)
hamwong
(Ham Wong)
March 13, 2017, 8:52pm
6
if you sure the rules is right as your last statement, than you have to make sure OH phone1 state is same as your phone,
what I mean is you set
Switch Phone1 "Phone 1" { channel="network:device:10_1_10_234:online" }
but may be status is not yet updated to OH, also, you didn’t show us full rules,
did you write in rules what should OH do when phone 1 is on?
rossko57
(Rossko57)
March 13, 2017, 11:55pm
7
Perhaps
if (Phone1.state != ON && Phone2.state != ON && Phone3.state != ON)