Page 1 of 1

Conditions use alphanumeric comparison?

PostPosted: Tue Jul 03, 2018 11:05 am
by Argelix
Hi,

I tried to use SuperConditions, reading the azimuth device state from Cynical Weather. Thought I was going crazy when I couldn't get it to work, until I turned on debugging:

EPS - Super Conditions Debug Checking if device state 'azimuth' value of '79.03' is greater than '110.00'
EPS - Super Conditions Debug Condition 3 returned [1, 0]

Obviously this is a very unexpected result, once I changed my comparison value to 99.0 it did work. I assume this is because the comparison is comparing these as strings; is there a way I can make the comparison as numbers? Or is there something else I am missing?

I did read the "known issue" about this in Changes.MD, but I did put "110.00" as a comparison value (also tried "110.0"), so for some reason this doesn't work for me. If I read conditions.py correctly (I know very little python) it looks like it does just a (lowercase) string comparison, which would not work if the number of digits is different...

Re: Conditions use alphanumeric comparison?

PostPosted: Tue Jul 03, 2018 11:58 am
by Colorado4Wheeler
Hmm, interesting. Can you do a screenshot so I can try to exactly replicate what you are doing? I'm sure I can find what the issue is and fix it.

Re: Conditions use alphanumeric comparison?

PostPosted: Tue Jul 03, 2018 12:38 pm
by Argelix
Not that easy, sun has moved on, other conditions fail by now :-) I do have another failed condition now; it gets to the right conclusion, but one condition is wrong, the log gives this result:

Checking if device state 'height' value of '8.81' is greater than '15.0'
EPS - Super Conditions Debug Condition 3 returned [1, 0]

It supports my theory that its just a string comparison, starting at the first char, "8" is greater that "1"...

Re: Conditions use alphanumeric comparison?

PostPosted: Tue Jul 03, 2018 1:24 pm
by Colorado4Wheeler
Ok, I just posted an update on the Plugin Store that should resolve this issue. I tested against your identical scenario and it now works fine (and my testing results started out the same as yours). I modified all operators to use the new formula but haven't tested every iteration of it. This is one of the plugins on my very long list of plugins to overhaul into my new plugin systems.

Try it and let me know!

Re: Conditions use alphanumeric comparison?

PostPosted: Tue Jul 03, 2018 1:35 pm
by Argelix
Whoa, that was fast! Ofc, sun has moved on even more, so the last failure didn't fail anymore... Got a new one though:

EPS - Super Conditions Debug Checking if device state 'azimuth' value of '113.37' is greater than '99.00'
EPS - Super Conditions Debug Condition 3 returned [1, 0]

That would have failed earlier, I believe...

Thanks for the quick fix!

Re: Conditions use alphanumeric comparison?

PostPosted: Tue Jul 03, 2018 1:41 pm
by Colorado4Wheeler
That's on the new version? While my test is using a variable value the computation is identical.

Code: Select all
   EPS - Super Conditions Debug    Checking conditions on 'Non Indigo Device Object'
   EPS - Super Conditions Debug       Condition is set to alltrue, testing condition(s)
   EPS - Super Conditions Debug       Checking if variable 'testFloatVar' value of '113.37' is greater than '99'
   EPS - Super Conditions Debug       Condition 1 returned [1, 0]
   EPS - Super Conditions Debug       Conditions returning true: 1, returning false: 0


Screen Shot 2018-07-03 at 1.39.57 PM.png
Screen Shot 2018-07-03 at 1.39.57 PM.png (84.14 KiB) Viewed 3679 times

Re: Conditions use alphanumeric comparison?

PostPosted: Tue Jul 03, 2018 1:47 pm
by Argelix
Oops sorry, that gave the wrong impression; it would have failed on the earlier version, the new version does it correctly.

Re: Conditions use alphanumeric comparison?

PostPosted: Tue Jul 03, 2018 1:48 pm
by Colorado4Wheeler
Whew, I was wondering how that could have been possible! Glad it's working. Hopefully a big update will be in the next couple of months as I slowly get all my plugins revamped.

Re: Conditions use alphanumeric comparison?

PostPosted: Fri May 03, 2019 4:54 pm
by joshh385
Sorry to resurrect an old thread but I am running into something similar here with the latest version from the plugin store.
I have some Sensibo AC controllers and setup some basic conditions to change the mode across fan/heat/cool based on some temperature ranges.
I'm attaching a screenshot of the log showing this - but I have a condition setup to switch the unit to fan only mode if the temp is between 20.5 and 21.6 C. Similarly, it will switch to cool if the temp is above 21.9 and heat if it is less than 20. The temp value changed to 21.4 and the conditions were evaluated, and they all returned false.