Thanks, I was able to build my Kitchen and Living Room to use Light/Dark logic vs Day/Night logic only…based off your questions/answers:
Light/Day = LR_Motion and (LR_Arm == 1) and InsideMotionArmed and Day and (WeatherCondition eq “Clear” or WeatherCondition eq “Partly Cloudy” or WeatherCondition eq “Scattered Clouds”)
Dark/Night = LR_Motion and (LR_Arm == 1) and InsideMotionArmed and (Night or (Day and (WeatherCondition ne “Clear” and WeatherCondition ne “Partly Cloudy” and WeatherCondition ne “Scattered Clouds”)))
So I am noticing that this isn’t working as reliable as it should be and I am confused as to what is happening. Currently, both my conditions show true and on the KitchenDayOff should be true right now:
DayTime No !IsNight true 2014-05-19 05:46:29.189 2014-05-18 18:40:53.765
KitchenDayOn No !IsNight and (WeatherCondition ne “Clear” or WeatherCondition ne “Partly Cloudy” or WeatherCondition ne “Scattered Clouds”) true 2014-05-19 05:46:29.196 2014-05-18 18:40:53.769
KitchenDayOff No !IsNight and (WeatherCondition eq “Clear” or WeatherCondition eq “Partly Cloudy” or WeatherCondition eq “Scattered Clouds”) true 2014-05-19 05:46:29.204 2014-05-17 23:14:26.329
You can see they both went true when my DayTime condition went true, even though you can see from below that the variable for the WeatherCondition changed 30 minutes afterwards from Mostly Cloudy to Partly Cloudy. Why is this happening? This event should’ve caused the KitchenDayOn to become false.
WeatherCondition World Weather Condition Partly Cloudy 2014-05-19 06:16:10.567 2014-05-19 03:14:52.491
Basically, the "WeatherCondition ne “Partly Cloudy” is the only one of the or statements not true in ‘KitchenDayOn’. The "WeatherCondition ne “Clear” and "WeatherCondition ne “Scattered Clouds” are technically both true, and the “or” means only one of the conditions needs to be true. Replace bolded “or” with “and” and that should do the trick to require all conditions to be excluded.
KitchenDayOn No !IsNight and (WeatherCondition ne “Clear” or WeatherCondition ne “Partly Cloudy” or WeatherCondition ne “Scattered Clouds”) true 2014-05-19 05:46:29.196 2014-05-18 18:40:53.769
It should not have because you have 3 'or’s. It only takes 1 of them to be true to cause that whole sub statement (in the parenthesis) to be true…
So, to break it down…
You have: A and B
A is “!isNight”
B is " (WeatherCondition ne “Clear” or WeatherCondition ne “Partly Cloudy” or WeatherCondition ne “Scattered Clouds”)"
The statement will be false if A or B is false. The statement will be true if both are true. A is easy. It’s 1 variable. If !isNight <> true, then the whole statement if false. B is a bit more tricky so lets rewrite b as:
C or D or E
So if any of C, D, or E are true, the whole statement is true. The only way for B to be false is if C, D and E are all FALSE.
WeatherCondition = “Partly Cloudy”
C = WeatherCondition ne “Clear” = True
D = WeatherCondition ne “Partly Cloudy” = False
E = WeatherCondition ne “Scattered Clouds” = true
You can see that C and E are both true. It only takes one of them to make B true, so your statement is:
A AND B
or
A AND ( C OR D OR E )
or
True AND ( True OR False OR True ) = True AND True = True
In your equation, the only way for KitchenDayOn to be false is for !isNight to be false.
I think what you ultimately want is:
KitchenDayOn No !IsNight and (WeatherCondition ne “Clear” AND WeatherCondition ne “Partly Cloudy” AND WeatherCondition ne “Scattered Clouds”)
Which is to say that as long as weather condition is not one of those 3 and it is day time, to set kitchenDAyOn to true.
Makes since. I will update it. So simple yet so blind!
Thanks guys
[quote=“waynehead99, post:25, topic:181072”]Makes since. I will update it. So simple yet so blind!
Thanks guys[/quote]
ORs and “NE” (or note equals) used like this don’t normally go together because they almost always ( can’t think of a situation where it woudln’t) return true when the first part of the comparison is the same. For instance:
A <> B or A <> C
Even if A = b, then the statement is true because A still doesn’t equal C. I’ve been caught by it and I’ve been programming for years (15+).
If I were you, I would set a condition to:
WEatherForKitchenLights = WeatherCondition eq “Clear” or WeatherCondition eq “Partly Cloudy” or WeatherCondition eq “Scattered Clouds”
Then just do:
KitchenLightsOn = !isNight AND WeatherForKitchenLights
KitchenLightsOff = !isNight AND !WeatherForKitchenLights
@SirMeili
Your answer is correct but a little confusing.
The scenario comes about because folks start with
(State eq "Option1" or State eq "Option2" or State eq "OptionN")
They think they can negate my changing to eq to ne.
But mathematically they need to use demorgan’s theorem:
From Wikipedia:
The rules can be expressed in English as:
The negation of a conjunction is the disjunction of the negations.
The negation of a disjunction is the conjunction of the negations.
or informally as:
“not (A and B)” is the same as “(not A) or (not B)”
and also,
“not (A or B)” is the same as “(not A) and (not B)”
So to negate the above expression, negate the terms and replace ors with ands:
(State ne "Option1" and State ne "Option2" and State ne "OptionN")
Wow that is some great info guys. Didn’t expect any of that. I made the changes and will monitor tomorrow. Thanks again everyone.