Issue with Variable Always True

What am I missing? I have two conditions as you can see pointing to the same device property and they are both reading as true.

I’m sure @RichardTSchaefer will chime in about this, but I think that your first one is incorrect. You have:

WeatherCondition == “X” or “Y”

I think what you want is:

WeatherCondition == “X” or WeatherCondition == “Y”

Some languages take all strings as True. so your first condition might always be true because “Y” is considered true.

P.S. I couldn’t remember the name of your strings so I just used X and Y

I could see that however right now the device property is mostly cloudy and the condition set to clear is reading true right now. So confused

you should post your entire status report; easier to help with all the information.

Ok here it is. No laughing at my lack of coding skills :slight_smile:

You are using the == operator instead of the eq operator.
Any non zero length string has a value of 1 numerically. == is a numeric comparison.
Use eq to compare string values.

[quote=“RichardTSchaefer, post:6, topic:181072”]You are using the == operator instead of the eq operator.
Any non zero length string has a value of 1 numerically. == is a numeric comparison.
Use eq to compare string values.[/quote]

@RichardTSchaefer, for clarity sake, and my own edification, would the following work:

(WeatherCondition eq “Overcast” or “Mostly Cloudy”)

or would it need to be:

(WeatherCondition eq “Overcast” or WeatherCondition eq “Mostly Cloudy”)

I have to say that this still has to be off. I tried to reproduce and though the status says “Partly Cloudy”, both of my conditions are still True when none of them contain “Partly Cloudy” (I was trying to reproduce @waynehead99’s problem)

I have attached my PLEG status report to add to this strange issue (this is my first attempt at using a device property like this in a condition).

The statement:

(WeatherCondition eq “Overcast” or “Mostly Cloudy”)

eq has a higher prcedence than or

So this would be equivalent to:

((WeatherCondition eq “Overcast”) or “Mostly Cloudy”)

The first part may or may not be true … but it does not matter, a non zero length string will look like a true.

Even if you use parenthesis and tried to do:
(WeatherCondition eq (“Overcast” or “Mostly Cloudy”))
This would reduce to:
(WeatherCondition eq true)

This should be false.

The only correct expression is:
WeatherCondition eq “Overcast” or WeatherCondition eq “Mostly Cloudy”

Richard I thought the same thing and changed it to eq and had the same results.

It’s hard to say why the value is the way it is without knowing the history of edits … Note: you can change the expression … but the value will not change until a new event (WeatherCondition) s delivered.

Would that explain why two conditions pointing to the same variable be true? Would I need to wait until it updates? What confuses me is the device is currently showing mostly cloudy but the condition for clear is reading true. So I can’t see how an update would change that but again this is my ignorance when it comes to this stuff.

The value was true because you use:

WeatherCondition  == "Clear"

Instead of:
WeatherCondition eq “Clear”

After changing it you need to wait for the next update.

Ok thanks I will try that again and be patient.

Would you and Richard like me to make it rain? ahahaha

Following along for update.

Can you make it Rain in Texas … we need it!

I’m in Socal and I think we need it more, but sadly I’m unable to use my powers anywhere it’s currently not already raining. LOL

Well I’ll be damned… one thing I don’t have is patience, but its what was needed. The variable changed to Overcast and my condition for “Clear” went to false. So for clarification on the other condition, it’s true still, but should be since it’s looking for overcast as well, can I leave it as is, or should it be changed as discussed earlier?

[quote=“RichardTSchaefer, post:9, topic:181072”]The only correct expression is:
WeatherCondition eq “Overcast” or WeatherCondition eq “Mostly Cloudy”[/quote]

Nevermind, need to read :). I see the light now. Thanks everyone.

Just to update, I appear to have this working properly now, thanks again team. Here is my setup

Using the weather plugin, I am looking at the Condition variable:

WeatherCondition World Weather Condition Mostly Cloudy 2014-05-09 06:06:34.709 2014-05-09 05:06:34.717

Conditions:

KitchenDayOn No !IsNight and (WeatherCondition ne “Clear” or WeatherCondition ne “Partly Cloudy” or WeatherCondition ne “Scattered Clouds”) true 2014-05-09 06:20:32.407 2014-05-08 20:26:39.415

KitchenDayOff No !IsNight and (WeatherCondition eq “Clear” or WeatherCondition eq “Partly Cloudy” or WeatherCondition eq “Scattered Clouds”) false 2014-05-08 12:17:12.636 2014-05-08 15:59:10.692

For those that are following, this is my use case (to give ideas or possible hear better ideas from others already doing something similar). I have under cabinet lighting that during the day when it is sunny out is not needed at all, but on days that it appears to be cloudy or stormy, the kitchen gets dark and I like to have a little light in the there. I just started using this and still need some burn in time to see the actual results. I looked into using my light sensors on the 4 in 1 I have installed, but that thing in my opinion doesn’t do the light sensing properly at all indoors. Time will tell if this truly works, but in theory to me it seemed to be a good idea.

Thanks again everyone for helping me with the coding.