kirkhansen / hubitat-weatherstack

Hubitat Device Driver for the Weatherstack API
1 stars 1 forks source link

estimateLux() Fails On Line 326 #1

Closed rlconkl closed 4 years ago

rlconkl commented 4 years ago

Hi Kirk,

Not sure if you're actively monitoring this project, but I tried to add your code as a virtual device in my Hubitat, and encountered this error while polling. (If I exit the estimateLux() function with return 0 as soon as it begins, everything else appears to work normally.)

Presently, the error is encountered on this line: lux = (l < 50f ? 50L : l.trunc(0) as long)

If it helps, here is the (redacted) output from my log:

dev:2662020-06-30 14:26:05.965 errorgroovy.lang.MissingMethodException: No signature of method: java.lang.Long.trunc() is applicable for argument types: (java.lang.Integer) values: [0]
Possible solutions: print(java.lang.Object), print(java.io.PrintWriter), toLong(), dump(), find(), any() on line 326 (poll)
dev:2662020-06-30 14:26:05.741 debugLocal Weather: between noon and sunset
dev:2662020-06-30 14:26:05.736 debugLocal Weather: localTime: Tue Jun 30 14:26:05 CDT 2020 | sunriseTime: Tue Jun 30 05:21:52 CDT 2020 | noonTime: Tue Jun 30 12:55:47 CDT 2020 | sunsetTime: Tue Jun 30 20:29:41 CDT 2020
dev:2662020-06-30 14:26:05.732 debugLocal Weather: twilight_begin: Tue Jun 30 04:48:07 CDT 2020 | twilight_end: Tue Jun 30 21:03:27 CDT 2020 | tz_id: America/Chicago
dev:2662020-06-30 14:26:05.729 debugLocal Weather: weather_code: 113 | cloudcover: 0
dev:2662020-06-30 14:26:05.695 debugLocal Weather: [results:[sunrise:2020-06-30T10:21:52+00:00, sunset:2020-07-01T01:29:41+00:00, solar_noon:2020-06-30T17:55:47+00:00, day_length:54469, civil_twilight_begin:2020-06-30T09:48:07+00:00, civil_twilight_end:2020-07-01T02:03:27+00:00, nautical_twilight_begin:2020-06-30T09:04:48+00:00, nautical_twilight_end:2020-07-01T02:46:46+00:00, astronomical_twilight_begin:2020-06-30T08:13:14+00:00, astronomical_twilight_end:2020-07-01T03:38:20+00:00], status:OK]
dev:2662020-06-30 14:26:05.134 debugLocal Weather: [request:[type:Zipcode, query:60606, language:en, unit:f], location:[name:Local, country:USA, region:Illinois, lat:42.511, lon:-80.964, timezone_id:America/Chicago, localtime:2020-06-30 14:20, localtime_epoch:1593526800, utc_offset:-5.0], current:[observation_time:07:20 PM, temperature:86, weather_code:113, weather_icons:[https://assets.weatherstack.com/images/wsymbols01_png_64/wsymbol_0001_sunny.png], weather_descriptions:[Sunny], wind_speed:12, wind_degree:110, wind_dir:ESE, pressure:1013, precip:0, humidity:67, cloudcover:0, feelslike:91, uv_index:6, visibility:10, is_day:yes]]
dev:2662020-06-30 14:26:05.130 debugLocal Weather: getObservation returned data
dev:2662020-06-30 14:26:04.429 debugLocal Weather: Executing 'poll', location: 60606

I'm just getting my feet wet with Hubitat, but if there's anything I can do to help debug/test, I'm happy to participate!

kirkhansen commented 4 years ago

Thanks for the issue!

Not sure if you're actively monitoring this project,

Active would be strong, but I do use this device myself still. I haven't made use of the lux, and the other stuff was working, so I stopped looking :upside_down_face: I'll try and take a look at this later tonight.

rlconkl commented 4 years ago

The lux estimates weren't a critical feature for me, either, so I'm not overly concerned. That being said, if there's something unique to my weather location or network environment, I'm happy to help test/troubleshoot. Thanks for your effort on this project!

kirkhansen commented 4 years ago

@rlconkl mind testing out the code in the pr i just opened? (Fix is in the dev branch)

rlconkl commented 4 years ago

I grabbed the code from the dev branch and updated my driver code. A refresh of the virtual device estimated lux correctly and without error.