app:26492021-11-17 08:26:58.945 am errorgroovy.lang.MissingMethodException: No signature of method: static java.lang.Float.parseFloat() is applicable for argument types: ([C) values: [83.22233] Possible solutions: parseFloat(java.lang.String) on line 62 (method updated)
Thinking it might be a number rather than a string, I did a direct comparision, ie an IF statement, and it errored. So that kinda tells me it is a string value.
That was what I thought, it was a string. But it was my understanding, being a limited programmer, that the toInteger would convert a string number to a integer.
For testing purposes I put this code in but it doesn't work. So for some reason the toInteger() is not converting a string to integer.
def something = "93.45"
def Battery = something.toInteger()
If I leave the quotes off which makes something a number it works fine.
I sat back and thought this through and realized maybe I misspoke and made an error on my own.
What I am doing is nothing more than turning an outlet on/off based on battery level. When I said it had been working, I was correct as the battery was getting charged. However, I hadn't really looked at the logs. What I believe was going on was the battery level, and thus evt.value, was coming in at integer values often enough to make it work. When it came in with a decimal it caused the error. But since it worked often enough I never caught the error.
Next thing I did, was when I was trying all those suggestions you guys gave me I was forcing an evt. Just dawned on me that that was not necessarily evt.value. So my bad. Sorry for all the trouble.
Net result, apparently the toInteger will work only if the string is an integer without decimals. Not sure I understand that, but it is what it is. I'm gonna stick with the toFloat as that seems to work no matter what.
Thanks again for all the help, and again sorry for the trouble.