kw123 / Hue-Lights-Indigo-plugin

Philips Hue control from Indigo
MIT License
7 stars 11 forks source link

Hue Reading Jumps to Huge Values #9

Open Ghawken opened 2 years ago

Ghawken commented 2 years ago

Trying to sort out compatibility with HomeKit and not getting very far. Hue value heres jumps to well over allowed 360 - and crashes everything my end.

Seems not being coverted to 0-360, from 0-65536 prior to update IndigoDevice State. Leading to multiple state updates and eventually the right Hue setting. But jumping through these large values first which are unneeded..

Tracked down - here is device dump during such.

I'll see if can find where issue is in Hue code...

 HomeKit Spawn Error             address : 192.168.1.246 (Lid:0-10)
batteryLevel : None
blueLevel : 0.0
brightness : 100
buttonConfiguredCount : 0
buttonGroupCount : 0
configured : True
defaultBrightness : 100
description : 
deviceTypeId : hueBulb
displayStateId : brightnessLevel
displayStateImageSel : DimmerOn
displayStateValRaw : 100
displayStateValUi : 100
enabled : True
energyAccumBaseTime : None
energyAccumTimeDelta : None
energyAccumTotal : None
energyCurLevel : None
errorState : 
folderId : 1517485216
globalProps : MetaProps : (dict)
     com.GlennNZ.indigoplugin.HomeKitSpawn : (dict)
          HomeKit_deviceSensor : onOffState (string)
          HomeKit_deviceSubtype : HueLightBulb (string)
          HomeKit_publishDevice : true (bool)
          homekit-name : Upstairs Hue (string)
     com.nathansheldon.indigoplugin.HueLights : (dict)
          SupportsColor : true (bool)
          SupportsRGB : true (bool)
          SupportsRGBandWhiteSimultaneously : false (bool)
          SupportsWhite : true (bool)
          SupportsWhiteTemperature : true (bool)
          WhiteTemperatureMax : 6500 (string)
          WhiteTemperatureMin : 2000 (string)
          address : 192.168.1.246 (Lid:0-10) (string)
          bulbId : 10 (string)
          defaultBrightness : 100 (string)
          hubNumber : 0 (string)
          manufacturerName : Signify Netherlands B.V. (string)
          modelId : LCT007 (string)
          nameOnBridge : Hue Lamp Upstairs Bookcase (string)
          nameOnHub : Hue Lamp Upstairs Bookcase (string)
          rate : 0 (string)
          savedBrightness : 254 (integer)
          swVersion : 5.130.1.30000 (string)
          type : Extended color light (string)
          uniqueId : 00:17:88:01:02:44:8e:f9-0b (string)
greenLevel : 0.0
id : 1491548020
lastChanged : 2022-04-01 11:24:39
lastSuccessfulComm : 2022-04-01 11:24:39
ledStates : []
model : Hue Color/Ambiance (Original, Downlight, Spotlight, etc.)
name : Hue Light Upstairs
onBrightensToDefaultToggle : False
onBrightensToLast : False
onState : True
ownerProps : com.nathansheldon.indigoplugin.HueLights : (dict)
     SupportsColor : true (bool)
     SupportsRGB : true (bool)
     SupportsRGBandWhiteSimultaneously : false (bool)
     SupportsWhite : true (bool)
     SupportsWhiteTemperature : true (bool)
     WhiteTemperatureMax : 6500 (string)
     WhiteTemperatureMin : 2000 (string)
     address : 192.168.1.246 (Lid:0-10) (string)
     bulbId : 10 (string)
     defaultBrightness : 100 (string)
     hubNumber : 0 (string)
     manufacturerName : Signify Netherlands B.V. (string)
     modelId : LCT007 (string)
     nameOnBridge : Hue Lamp Upstairs Bookcase (string)
     nameOnHub : Hue Lamp Upstairs Bookcase (string)
     rate : 0 (string)
     savedBrightness : 254 (integer)
     swVersion : 5.130.1.30000 (string)
     type : Extended color light (string)
     uniqueId : 00:17:88:01:02:44:8e:f9-0b (string)
pluginId : com.nathansheldon.indigoplugin.HueLights
pluginProps : com.GlennNZ.indigoplugin.HomeKitSpawn : (dict)
     HomeKit_deviceSensor : onOffState (string)
     HomeKit_deviceSubtype : HueLightBulb (string)
     HomeKit_publishDevice : true (bool)
     homekit-name : Upstairs Hue (string)
protocol : Plugin
redLevel : 100.0
remoteDisplay : True
sharedProps : com.indigodomo.indigoserver : (dict)
states : States : (dict)
     alertMode : none (string)
     alertMode.ui : none (string)
     blueLevel : 0.00000000 (real)
     blueLevel.ui : 0 (string)
     brightnessLevel : 100 (integer)
     brightnessLevel.ui : 100 (string)
     colorBlue : 1 (integer)
     colorBlue.ui : 1 (string)
     colorGreen : 1 (integer)
     colorGreen.ui : 1 (string)
     colorMode : hs (string)
     colorMode.ui : hs (string)
     colorRed : 254 (integer)
     colorRed.ui : 254 (string)
     colorTemp : 2000 (integer)
     colorTemp.ui : 2000 (string)
     colorX : 0.6750 (real)
     colorX.ui : 0.675 (string)
     colorY : 0.3220 (real)
     colorY.ui : 0.322 (string)
     effect : none (string)
     effect.ui : none (string)
     greenLevel : 0.00000000 (real)
     greenLevel.ui : 0 (string)
     **hue : 54600 (integer)
     hue.ui : 54600 (string)**
     onOffState : on (on/off bool)
     online : true (bool)
     online.ui : True (string)
     redLevel : 100.00000000 (real)
     redLevel.ui : 100 (string)
     saturation : 100 (integer)
     saturation.ui : 100 (string)
     whiteLevel : 0.00000000 (real)
     whiteLevel.ui : 0 (string)
     whiteTemperature : 2000.00000000 (real)
     whiteTemperature.ui : 2000 (string)
subModel : 
subType : 
supportsAllLightsOnOff : False
supportsAllOff : False
supportsColor : True
supportsRGB : True
supportsRGBandWhiteSimultaneously : False
supportsStatusRequest : True
supportsTwoWhiteLevels : False
supportsTwoWhiteLevelsSimultaneously : False
supportsWhite : True
supportsWhiteTemperature : True
version : None
whiteLevel : 0.0
whiteLevel2 : None
whiteTemperature : 2000
indigo-jay commented 2 years ago

Note that Karl's contributions aren't in the repo yet, but there are releases (many releases) from him. I have to sort it all out after we get 2022.1 out, but if you find the issue in the current source, just make sure that you keep careful track of what your changes are so we can try to patch Karl's version.

kw123 commented 2 years ago

Which hue plugin version are you using?

And From the dump I don’t see which value is out of limit?

Karl

On 01.04.2022, at 03:52, Jay Martin @.***> wrote:

 Note that Karl's contributions aren't in the repo yet, but there are releases (many releases) from him. I have to sort it all out after we get 2022.1 out, but if you find the issue in the current source, just make sure that you keep careful track of what your changes are so we can try to patch Karl's version.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.

Ghawken commented 2 years ago

1.8.7

Its the hue device.state Hue is 0-360 Hue.Plugin comments discuss conversion of hue 0-65565 to 0-360 but obviously not happening somewhere before deviceStateUpdated in indigo.

Here:

     hue : 54600 (integer)
     hue.ui : 54600 (string)

Happy to update and keep current - just point me in the right direction!

kw123 commented 2 years ago

I will check after Bf

Karl

On Apr 1, 2022, at 06:22, Ghawken @.***> wrote:

 1.8.7

Its the hue device.state Hue is 0-360 Hue.Plugin comments discuss conversion of hue 0-65565 to 0-360 but obviously not happening somewhere before deviceStateUpdated in indigo.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.

kw123 commented 2 years ago

code section:

Value manipulation.

        # Convert from HSB to RGB, scaling the hue and saturation values appropriately.
        if(hue == 0 and saturation == 0 and (colorX > 0 or colorY > 0)) or colorMode == "xy":
                xyY = xyYColor(colorX, colorY, brightness / 255.0)
                rgb = xyY.convert_to('rgb')
                # Let's also convert the xyY color to HSB so that related device states in Indigo are updated correctly.
                hsb = xyY.convert_to('hsv')
                hue = int(round(hsb.hsv_h * 182.0))
                saturation = int(round(hsb.hsv_s * 255.0))
        else:
                hsb = HSVColor(hue / 182.0416666668, saturation / 255.0, brightness / 255.0)
                rgb = hsb.convert_to('rgb')

it was hue = int(round(hsb.hsv_h * 182.0)) ….

        hue =(int(round(hue / 182.0)))

it should be:

        hue = min(360,(int(round(hue / 182.0416666668)))

guess that is a int/ float rounding issue.

I am also adding a logging statement to /Library/Application Support/Perceptive Automation/Indigo 2022.1/Logs/com.nathansheldon.indigoplugin.HueLights/plugin.log in case hue is >= 65535

will change the code in the next release

Karl

On Apr 1, 2022, at 06:22, Ghawken @.***> wrote:

1.8.7

Its the hue device.state Hue is 0-360 Hue.Plugin comments discuss conversion of hue 0-65565 to 0-360 but obviously not happening somewhere before deviceStateUpdated in indigo.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.

kw123 commented 2 years ago

that statement is actually in many places, I need to go through each.

And unfortunately the variable name hue is used for the hue system value as well as the hue indigo dev state

one is 0-65k (2**32-1) — hue system the other is 0-360 (or may be it should be 0-359?) — indigo dev states

both integer values

Karl

On Apr 1, 2022, at 06:22, Ghawken @.***> wrote:

1.8.7

Its the hue device.state Hue is 0-360 Hue.Plugin comments discuss conversion of hue 0-65565 to 0-360 but obviously not happening somewhere before deviceStateUpdated in indigo.

— Reply to this email directly, view it on GitHub https://github.com/IndigoDomotics/Hue-Lights-Indigo-plugin/issues/9#issuecomment-1085406055, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEH2SNAQLNKHXXHO6FQH3TDVCZ2ZLANCNFSM5SHDNJSQ. You are receiving this because you commented.

Ghawken commented 2 years ago

Thanks. hue ends up being divided by 360 in colorsys conversion - so would guess is 0-360

kw123 commented 2 years ago

if you could try this one:

https://github.com/IndigoDomotics/Hue-Lights-Indigo-plugin/releases/tag/v1.10.16

it should fix the hue >360 and also colorX or ColorY ==0

Compared to your version it has several changes:

Karl

On Apr 1, 2022, at 03:52, Jay Martin @.***> wrote:

Note that Karl's contributions aren't in the repo yet, but there are releases (many releases) from him. I have to sort it all out after we get 2022.1 out, but if you find the issue in the current source, just make sure that you keep careful track of what your changes are so we can try to patch Karl's version.

— Reply to this email directly, view it on GitHub https://github.com/IndigoDomotics/Hue-Lights-Indigo-plugin/issues/9#issuecomment-1085308673, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEH2SNABPOWCRE5QOWQPB23VCZJFXANCNFSM5SHDNJSQ. You are receiving this because you are subscribed to this thread.

Ghawken commented 2 years ago

Thanks - have updated. No update issues. All seems good. Thanks

Ghawken commented 2 years ago

Morning, Karl.. On 1.10.20 Unfortunately seems something is still up with Hue state in Hue plugin. Getting very high readings saved as display state - currently Hue = 56984.. Was debugging homekit integration trying to find issue - because was fixed…. ?something not merged…

kw123 commented 2 years ago

Sorry I am out of town until May 10. No access to indigo. Will check when I am back.
If you could some more info ie compare the values on the app w what indigo shows etc.

Karl

On Apr 23, 2022, at 18:25, Ghawken @.***> wrote:

 Morning, Karl.. Unfortunately seems something is still up with Hue state in Hue plugin. Getting very high readings saved as display state - currently Hue = 56984.. Was debugging homekit integration trying to find issue - because was fixed…. On 1.10.20

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.

Ghawken commented 2 years ago

Thanks - Sorry to bother. I also spammed you with another issue - obviously can wait.

Hue values in Indigo are thousands on 1.10.20 -- does seem like something not merged?

hueValues

I have worked around, by simply ignoring the hue values - probably best anyway and more indigo.dimmer compatible - same for everything. But does seem like hopefully an easy merge to update?

kw123 commented 1 year ago

.. along those lines:

if colorX ==0 or ColorY ==0 the library used throws an error

        if(hue == 0 and saturation == 0 and (colorX > 0 or colorY > 0)) or colorMode == "xy”:
            ## adding: 
                colorX = max(0.00001, colorX)
                colorY = max(0.00001, colorY)
                xyY = xyYColor(colorX, colorY, brightness / 255.0) ## this one does not like ==0 values 
                rgb = xyY.convert_to('rgb')

Karl

That lib (color math included in the plugin distribution) has no check for div by 0 eg: xyzcolor.xyz_x = (cobj.xyy_x * cobj.xyy_Y) / (cobj.xyy_y)

On Apr 1, 2022, at 09:07, Ghawken @.***> wrote:

Thanks. hue ends up being divided by 360 in colorsys conversion - so would guess is 0-360

— Reply to this email directly, view it on GitHub https://github.com/IndigoDomotics/Hue-Lights-Indigo-plugin/issues/9#issuecomment-1085514450, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEH2SNGXNMR7ETY7YMDY2KDVC2OB5ANCNFSM5SHDNJSQ. You are receiving this because you commented.