apwelsh / hubitat

MIT License
26 stars 12 forks source link

Advanced Light Integration Error After Upgrade #21

Closed z1ucas closed 1 year ago

z1ucas commented 1 year ago

I upgraded to the latest version and am receiving the following error when discovering lights or trying to use the other functions :

Error: No signature of method: static java.lang.Math.max() is applicable for argument types: (null, java.lang.Integer) values: [null, 1] Possible solutions: max(int, int), max(double, double), max(float, float), max(long, long), min(int, int), wait()

apwelsh commented 1 year ago

Thanks. I will look into it. I added some bounds checking to a couple attributes, but what is odd is that the value is being passed in as null. Should be an easy fix.

budjik-tech commented 1 year ago

We are also getting errors after recent updates. Error: Cannot cast object 'null' with class 'null' to class 'int'. Try 'java.lang.Integer' instead This error is from the attempted re-link. Tried UnLink and ReLink but now it cannot re-link.

apwelsh commented 1 year ago

I will look at it Sunday afternoon. Thanks for the feedback.

apwelsh commented 1 year ago

Can you please provide the full text of the error messages? I need to know where in the code it is erroring out. The error message include the line number

apwelsh commented 1 year ago

I upgraded to the latest version and am receiving the following error when discovering lights or trying to use the other functions :

Error: No signature of method: static java.lang.Math.max() is applicable for argument types: (null, java.lang.Integer) values: [null, 1] Possible solutions: max(int, int), max(double, double), max(float, float), max(long, long), min(int, int), wait()

It appears this may be because the device has not refreshed and has no value for either hue or saturation, as these are the two attributes that I added new code around that could be related to the error. I have added some additional checks, and am testing the code now.

apwelsh commented 1 year ago

We are also getting errors after recent updates. Error: Cannot cast object 'null' with class 'null' to class 'int'. Try 'java.lang.Integer' instead This error is from the attempted re-link. Tried UnLink and ReLink but now it cannot re-link.

Without the full error code, I cannot fix as I am unable to reproduce this on my hub. Please provide more log details.

apwelsh commented 1 year ago

I found the actual issue. I inadvertently added code to fix the level value so that if the light is on, the level must not be less than 1, that incorrectly assumed a level was being passed in an update packet. I have fixed this.

I am looking into the relinking next, but I will publish this fix and mark the issue resolved, as this is not related to the re-linking issue. Update is being pushed out now.

budjik-tech commented 1 year ago

Thank you for the wok, I downloaded the update via HPM. I'm getting a mixed lot of logging but I'll start with the UnLink and Link as per the open issue.

"Linking with your Hue Unexpected Error An unexpected error has occurred trying to load the app. Check Logs for more information. Error: Cannot cast object 'null' with class 'null' to class 'int'. Try 'java.lang.Integer' instead

[app:798](http://192.168.0.161/logs#)2022-12-13 10:35:10.288 PM[error](http://192.168.0.161/logs#)org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'null' with class 'null' to class 'int'. Try 'java.lang.Integer' instead on line 1610 (method bridgeLinking)
[app:798](http://192.168.0.161/logs#)2022-12-13 10:35:10.245 PM[debug](http://192.168.0.161/logs#)Parsing response: [name:Bedroom, lights:[3, 4, 2], sensors:[], type:Room, state:[all_on:false, any_on:false], recycle:false, class:Bedroom, action:[on:false, bri:254, ct:446, alert:select, colormode:hs]] for 2
[app:798](http://192.168.0.161/logs#)2022-12-13 10:35:10.135 PM[debug](http://192.168.0.161/logs#)Parsing response: [name:Living Room, lights:[23, 24], sensors:[], type:Room, state:[all_on:false, any_on:false], recycle:false, class:Living room, action:[on:false, bri:254, ct:156, alert:select, colormode:ct]] for 1
[app:798](http://192.168.0.161/logs#)2022-12-13 10:35:09.876 PM[info](http://192.168.0.161/logs#)Adding Bridge device with DNI: hue-ECB5FA3FC92D
[app:798](http://192.168.0.161/logs#)2022-12-13 10:35:09.872 PM[debug](http://192.168.0.161/logs#)Hub linking completed for Philips hue (3FC92D)
[app:798](http://192.168.0.161/logs#)2022-12-13 10:35:06.975 PM[debug](http://192.168.0.161/logs#)Obtained credentials: XXXX
[app:798](http://192.168.0.161/logs#)2022-12-13 10:35:00.856 PM[error](http://192.168.0.161/logs#)link button not pressed

So it appears the linking is working but suspect another part of the import from the Hue Hub has an issue.

My son loves to play with the 2 colour hue downlights and add scenes. It may be something like invalid characters in his names, or even too many!

I found some and have renamed them: "veg=zdsye zdsye=eerieoip" and another named like this: "ffcççvbŋkłjhgfḏßæqwęṟ "

I'm still searching and trying to find something in his naming that may cause errors. But the log above may help you.

budjik-tech commented 1 year ago

Other strange thing is the "Sensor". I do not have any Hue sensors but in the "Find Sensors" it shows a "Daylight (null)" sensor. And in the logs there is this line [app:798](http://192.168.0.161/logs#)2022-12-13 11:06:43.042 PM[error](http://192.168.0.161/logs#)unauthorized user

budjik-tech commented 1 year ago

Sorry for the sloppy debug! I've concluded that the link itself is ok and it is simply failing in the import of the Bedroom. The failure is leaving the previous state as I have deleted many scenes now from Hue App but they are still in your Hubitat App. I'm suspicious of the index numbers (assumption) of the lights in the Bedroom. There was another light originally but it may have moved to another room now. That is there was a Hue Bulb, a Hue Downlight, and 2 Hue Candlestick lights. The downlight is no longer in this room and is likely attached in another room.

[app:798](http://192.168.0.161/logs#)2022-12-13 11:36:13.201 PM[error](http://192.168.0.161/logs#)org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'null' with class 'null' to class 'int'. Try 'java.lang.Integer' instead on line 1610 (method bridgeLinking)
[app:798](http://192.168.0.161/logs#)2022-12-13 11:36:13.171 PM[debug](http://192.168.0.161/logs#)Parsing response: [name:Bedroom, lights:[3, 4, 2], sensors:[], type:Room, state:[all_on:false, any_on:false], recycle:false, class:Bedroom, action:[on:false, bri:143, ct:447, alert:select, colormode:hs]] for 2
apwelsh commented 1 year ago

Other strange thing is the "Sensor". I do not have any Hue sensors but in the "Find Sensors" it shows a "Daylight (null)" sensor. And in the logs there is this line [app:798](http://192.168.0.161/logs#)2022-12-13 11:06:43.042 PM[error](http://192.168.0.161/logs#)unauthorized user

There are internal sensor to hue. The Daylight sensor is used internally by hue automations on the hue hub. My code does not filter them out. the (null) portion is due to the fact that these hue internal virtual sensors do not have an associated sensor type.

[app:798](http://192.168.0.161/logs#)2022-12-13 11:36:13.201 PM[error](http://192.168.0.161/logs#)org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'null' with class 'null' to class 'int'. Try 'java.lang.Integer' instead on line 1610 (method bridgeLinking) [app:798](http://192.168.0.161/logs#)2022-12-13 11:36:13.171 PM[debug](http://192.168.0.161/logs#)Parsing response: [name:Bedroom, lights:[3, 4, 2], sensors:[], type:Room, state:[all_on:false, any_on:false], recycle:false, class:Bedroom, action:[on:false, bri:143, ct:447, alert:select, colormode:hs]] for 2

This is the result of code I added to get the current hue and saturation from the device, if one is not present in the event being parsed. The reason for this is to work around an issue in Hue where both hue and saturation must be set in the same command, or both are ignored. I made a rookie coding mistake, and assigned the value to an int, instead of an Integer. int values cannot be null, but the value being returned is null, because the device does not have current values yet. Anyways, I just fixed it.

budjik-tech commented 1 year ago

Thank you - Fixed Linked up the Hue Hub again and it was successful. Now I can check out your new features.