Error calling comparison comp_is_between


#1

1) Give a description of the problem
When creating an, “is between,” comparision, I get a java error in the log.

2) What is the expected behavior?
I want to compare a variable to see if it is in between 2 values.

3) What is happening/not happening?
(PUT YOUR INFO HERE)

4) Post a Green Snapshot of the pistonimage

5) Attach any logs (From ST IDE and by turning logging level to Full)

12/28/2017, 10:07:06 AM +530ms
+5ms ╔Starting piston… (v0.2.101.20171227)
+365ms ║╔Subscribing to devices…
+406ms ║║Subscribing to Main Garage Door Sensor.contact…
+501ms ║╚Finished subscribing (149ms)
+529ms ║Comparison (string) Both Home is (string) Both Away = false (4ms)
+531ms ║Cancelling condition #8’s schedules…
+532ms ║Cancelling condition #null’s schedules…
+547ms ║Comparison (enum) closed stays (string) open = false (2ms)
+965ms ║Comparison (dynamic) 6.1 is_less_than_or_equal_to (integer) 0 = false (4ms)
+984ms ║Comparison (enum) closed stays (string) open = false (2ms)
+1000ms ║Error calling comparison comp_is_between: java.lang.ClassCastException
+1017ms ╚Piston successfully started (1017ms)
12/28/2017, 10:03:08 AM +161ms
+3ms ╔Starting piston… (v0.2.101.20171227)
+356ms ║╔Subscribing to devices…
+469ms ║║Subscribing to Main Garage Door Sensor.contact…
+607ms ║╚Finished subscribing (263ms)
+645ms ║Comparison (string) Both Away is (string) Both Away = true (6ms)
+890ms ║Comparison (dynamic) 6.3 is_less_than_or_equal_to (integer) 0 = false (4ms)
+908ms ║Comparison (enum) closed stays (string) open = false (6ms)
+927ms ║Error calling comparison comp_is_between: java.lang.ClassCastException
+935ms ║Comparison (enum) closed is (string) open = false (1ms)
+945ms ╚Piston successfully started (944ms)


#2

Dumb question but I’m going to ask anyway, have you tried is between 0 and 32?


#3

Try is inside of range instead; it looks like is between is intended for comparing dates. When you use an expression like that it shows comparisons for a variety of types, some of which may not actually apply.


Comparison (integer) 69 is_between (integer) 10 .. (integer) 75 = false (2ms)
#4

I have tried both ways (0 --> 32 and 32 --> 0)


#5

This seemed to have fixed it. Is there a specific way this should be compared?

i.e. lower value first, lower value first?


#6

Looks like the order doesn’t matter. I had a similar issue using the weather API with the min function. Data coming out of the API is typed as dynamic so sometimes it will show invalid options like in your case or will require explicit typecasting. I had to wrap the values in a casting function, decimal(), in order to get the correct answer:

min(
    decimal($weather.forecast.forecast.simpleforecast.forecastday.low.fahrenheit[0]),
    decimal($weather.forecast.forecast.simpleforecast.forecastday.low.fahrenheit[1]),
    decimal($weather.forecast.forecast.simpleforecast.forecastday.low.fahrenheit[2])
)

#7

So are you saying that the, “inside range,” will cause me issues?

Maybe this piston can be written different?

What I am trying to accomplish is that my roommate is leaving the garage door open when it is cold out :rage:

So I wanted to send him a text message if the temp is below 0F and the garage tilt sensor is open for more than 10 minutes. And if it is below freezing (32 F to 0 F) if it is open more than 15 minutes.


#8

Sorry, inside range is the correct one to use. I was just saying that expressions allow you to use conditions that normally wouldn’t apply. Another example that shows up in the list is the “arrives” trigger… it’s only there because the expression isn’t guaranteed to always be a number.

Another way to avoid having to guess which conditions are applicable is to set the expression to a variable of the correct type. You could add a decimal currentTemperature variable and use that in the if statements but it’s not necessary now that you have a condition that works.