B4A Library PhilipsHUE SDK - Control your HUE System

A B4J Version is available here.

HUE

Author:
Version: 0.41

Requirements:
1- You need to follow the instructions here to get your "Username" which you them can use to Authenticate your app against the SDK.
Once you have the username (kind of a Unique ID) you can use this username and adapt the Examplecode which actually uses my Username. You need to change it to yours for sure.
- You Device must be connected to the same Network as your HueBridge(s)

B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Dim sdk As PHHueSDK
    Dim APselected As PHAccessPoint
    Dim BridgeSelected As PHBridge
    ' Define here the username you got using the registration with the Bridge debug tool
    ' See https://www.developers.meethue.com/documentation/getting-started
    ' to learn how to create the "Username" for you to Access the SDK
    Private HUEusername = "ofmxXcuFVe0okMRIxcyaSQRMtqTFBS9ANBjfCboI"
    Dim hueoverview As Map

    ' Only used when using the httpapi. Not needed here.
    'Private bridgeURL As String = "http://192.168.192.109/api/"&HUEusername&"/"
    Private lvhue As ListView
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("Layout1")
    hueoverview.Initialize

    ' Initialize the HUESDK and then the Manager inside the SDK
    sdk.Initialize("HUE","QuickStartApp")
    sdk.InitManager

    ' Setup the AccessPoint manually here.
    Dim ap As PHAccessPoint
    ap.Initialize("")
    ap.IpAddress = "192.168.192.109"    ' IP of AccessPoint
    ap.MacAddress = "00:17:88:12:CB:6E" ' Mac-Address
    ap.BridgeId = "001788FFFE12CB6E"    ' ID (usually the Mac without :)
    ap.Username = HUEusername           ' Define the Username here to gain Access to this AccessPoint
    ' Connect the SDK with the AccessPoint
    sdk.connect(ap)
    wait for HUE_onBridgeConnected(bridge As PHBridge, info As String)
    Log($"Activity_Create.HUE_onBridgeConnected(${bridge},${info})"$)
    BridgeSelected = bridge

    'sdk.addBridge(bridge)
    Dim lights As List
    lights = bridge.AllLights
    Dim lightnames As List = sdk.getLightNames(lights)

    If lights.IsInitialized Then
        If lights.Size > 0 Then
            For i = 0 To lights.Size-1
                Dim light As PHLight = lights.Get(i)
                Dim state As PHLightState = light.LastKnownLightState
                Dim name As String = lightnames.Get(i)
                hueoverview.Put("LightName"&light.Identifier,name)   
                Log($"Light = ${name} = ${light.Identifier} / Manufacturer = ${light.ManufacturerName} Model ${light.ModelNumber} LightType = ${light.LightType}"$)
                hueoverview.Put("Light"&light.Identifier,light)
                hueoverview.Put("LightState"&light.Identifier,state)
            Next
        End If
    End If

    Dim groups As List
    groups = bridge.AllGroups
    If groups.IsInitialized Then
        If groups.Size > 0 Then
            For i = 0 To groups.Size-1
                Dim group As PHGroup = groups.Get(i)
                Log($"Group = ${group.Name} / Type = ${group.GroupType} UniqueID = ${group.UniqueId}"$)
                lvhue.AddSingleLine2(group.Name,group)
                Dim grlights As List = group.LightIdentifiers
                If grlights.IsInitialized And grlights.Size > 0 Then
                    For o = 0 To grlights.Size -1
                        Dim light As PHLight = hueoverview.Get("Light"&grlights.Get(o))
                        Dim state As PHLightState = hueoverview.Get("LightState"&grlights.Get(o))
                        Log($"${light.Identifier}: ${hueoverview.Get("LightName"&grlights.Get(o))} ${light.ModelNumber} - ${light.LightType}"$)
                        lvhue.AddTwoLines2(light.Identifier&": "&hueoverview.Get("LightName"&grlights.Get(o)),$"${light.ModelNumber} - ${light.LightType}"$,Array(light,state))
                    Next
                End If
                'Log(group.LightIdentifiers)
            Next
        End If
    End If

    Dim sensors As List
    sensors = bridge.AllSensors
    If sensors.IsInitialized Then
        If sensors.Size > 0 Then
            For i = 0 To sensors.Size-1
                Dim sensor As PHSensor = sensors.Get(i)
                Log($"Sensor = ${sensor.Name} / Type = ${sensor.ModelId} - ${sensor.ManufacturerName} - UniqueID = ${sensor.UniqueId}"$)
            Next
        End If
    End If




    Log("Rules: "&bridge.AllRules)
    Log("Scenes: "&bridge.AllScenes)
    'Log("Sensors: "&bridge.AllSensors)
    Log("AllShedules: "&bridge.getAllSchedules(True))
    Log("AllTimers: "&bridge.getAllTimers(True))

End Sub

You can change the Lightstate as this
please note how the Value is set in the Code above. The point is that we need to have both Objects. The Light object and it´s LightState object which we get from the SDK.

B4X:
Sub lvhue_ItemClick (Position As Int, Value As Object)
    Log($"Itemclick(${Position}, ${Value})"$)
    Dim obj() As Object = Value
    Dim light As PHLight = obj(0)
    Dim state As PHLightState = obj(1)
    Log("Lightstate is "&state.ON)
    If state.ON Then
        state.ON = False
        BridgeSelected.updateLightState(light,state)
    Else
        state.ON = True
        BridgeSelected.updateLightState(light,state)
    End If
End Sub

NOTES:
- If you do not have a username then you can use the SDK to search for AccessPoints which then will raise an event for the Bridge found. If you want to use this bridge then you probably need to authenticate (calling the method of the sdk)...
Once you are authenticated you can use the bridge.
Until you you quit your app. Once closed you need to authenticate again after a new search.

The best way is to register a username an connect to your Bridge using username and known IP. Using a valid username give your direct access to the bridge.

HAVE FUN :)

Some Notes about user findings (Thank you @johndb!)

To change the state of a Light/Group/Screne:
It appears that you must create a new PHLightState object, set the parameters that you would like to adjust, and pass the new object to the updateLightState function. This eliminates the blinking and provides a smooth transition.
B4X:
Sub lvhue_ItemClick (Position As Int, Value As Object)
    Log($"Itemclick(${Position}, ${Value})"$)
    Dim obj() As Object = Value
    Dim light As PHLight = obj(0)
    Dim state As PHLightState = obj(1)
    Dim NewLightState As PHLightState
    NewLightState.Initialize("")
    NewLightState.Brightness = 254 ' 125
    NewLightState.X = 0.4574
    NewLightState.Y = 0.41
    BridgeSelected.updateLightState(light,NewLightState)
End Sub

Infos about Cached Updates:
This problem above has been solved. Here are my lessons learned to date:
  1. You must create a new PHLightState object, set the parameters that you would like to adjust, and pass the new object to the updateLightState function. This eliminates the blinking and provides a smooth transition.
  2. You cannot use "wait for <object>_onCacheUpdated(cacheNotifications As List, bridge As PHBridge)" after your "updateLightState" function call. It may not be called. The "_onCacheUpdated" event will only be called if a particular state is different than the light's current state in one of the LightState parameters. All of the "updateLightState" calls are queued for execution in the library. The "_onCacheUpdated(cacheNotifications" event will only we called if there is a change in one of the LightState parameters.
  3. You can use "wait for <object>_onAccessPointsFound(.." directly after the function call "sdk.search(True,True)".
  4. You can use "wait for <object>_onBridgeConnected (..." directly after the function call "sdk.connect(<access point>)".
I'll post more when I discover other operational anomalies as I encounter them. I hope this helps other users who would like to explore this library.
 

Attachments

  • HUEV0.2.zip
    433.3 KB · Views: 378
  • PhilipsHueExample.zip
    9.4 KB · Views: 410
  • HUEV0.21.zip
    446.8 KB · Views: 386
  • HUEV0.3.zip
    450.1 KB · Views: 397
  • HUEV0.41.zip
    64.4 KB · Views: 370
Last edited:

DonManfred

Expert
Licensed User
Longtime User
A Second Example.
This one is not using a predefined Username so we first must search for AccessPoints, Authenticate to them and then we can use the SDK.

This is most probably the Example you want to start with as it shows how to search for an AccessPoint if no saved AP is in the KVS.
While searching it will raise an Event for each APs found (there may be more than one inside the Event. The event may raise multiple times.
Ok, the Example is asuming you are using ONE Accesspoint (like me).
Once the event is raised I try to connect to this AP. As i do not have a valid Username the Event AuthentificationRequired is raised. Inside this Event i start the Pushautification... You must then press the button on your AP.
After you pressed the event onConnected is raised. Inside this event i write the information about the AP into a KVS (which is checked in Activity_Create in a later run of the app)
The SDK can now be used.

Later, when you restart the app it will look into the KVS and it will find the saved AP-Infos.
I manually create a new AP (including Username) and then directly connect to it. As i now have a valid Username i do not need to Authenticate again and i do not need to Search for APs...

Have fun!

B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Type MyCustomAP (BridgeId As String, BridgeIP As String, BridgeMac As String, BridgeUsername As String)

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Dim sdk As PHHueSDK
    Dim APselected As PHAccessPoint
    Dim BridgeSelected As PHBridge
    ' Define here the username you got using the registration with the Bridge debug tool
    ' See https://www.developers.meethue.com/documentation/getting-started
    ' to learn how to create the "Username" for you to Access the SDK
    Private HUEusername = ""
    Dim hueoverview As Map

    ' Only used when using the httpapi. Not needed here.
    'Private bridgeURL As String = "http://192.168.192.109/api/"&HUEusername&"/"
    Private lvhue As ListView
    Private lvbridges As ListView
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("Layout1")
    hueoverview.Initialize

    ' Initialize the HUESDK and then the Manager inside the SDK
    sdk.Initialize("HUE","QuickStartApp")
    sdk.InitManager

    Dim def As MyCustomAP
    def.Initialize

    Dim AccessPoint As MyCustomAP = Starter.kvs.GetDefault("AP",def)
    If AccessPoint.BridgeUsername <> "" Then
        Log("Username in a saved AP found... Try to connect directly to this AccessPoint")
        Dim ap As PHAccessPoint
        ap.Initialize("")
        ap.BridgeId = AccessPoint.BridgeId
        ap.IpAddress = AccessPoint.BridgeIP
        ap.MacAddress = AccessPoint.BridgeMac
        ap.Username = AccessPoint.BridgeUsername
        APselected = ap
        sdk.connect(ap)
    Else
        sdk.search(True,True)
    End If
    ' Do a search for find the Bridge
End Sub
Sub HUE_onAccessPointsFound(aps As List)
    'Log($"HUE_onAccessPointsFound(${APs})"$)
    Log($"HUE_onAccessPointsFound()"$)
    If aps.IsInitialized Then
        Log($"AP list is initialized. size = ${aps.Size}"$)
        'Log(APs)
        If aps.Size = 1 Then
            Log("get 1st")
            If aps.Get(0) Is PHAccessPoint Then
                Log("get PHAccessPoint")
                Dim ap As PHAccessPoint = aps.Get(0)
                Log(ap.BridgeId)
                Log(ap.IpAddress)
                Log(ap.MacAddress)
                'Log(ap.Username)
                lvbridges.AddTwoLines2(ap.IpAddress,ap.MacAddress,ap)
            else if aps.Get(0) Is PHBridge Then
                Log("get PHBridge")
                Dim bridge As PHBridge = aps.Get(0)
                sdk.addBridge(bridge)
            else if aps.Get(0) Is PHBridgeHeader Then
                Log("get PHBridgeHeader")
                Dim bridgehdr As PHBridgeHeader = aps.Get(0)
            else if aps.Get(0) Is PHLight Then
                Log("get PHLigth")
                Dim light As PHLight = aps.Get(0)
            End If
            'sdk.startPushlinkAuthentication(ap)
            'Log("Groups: "&bridge.AllGroups)
            'Log("Lights: "&bridge.AllLights)
            'Log("Rules: "&bridge.AllRules)
            'Log("Scenes: "&bridge.AllScenes)
            'Log("Sensors: "&bridge.AllSensors)
            'Log("AllShedules: "&bridge.getAllSchedules(True))
            'Log("AllTimers: "&bridge.getAllTimers(True))
        Else
            For i = 0 To aps.Size-1
                Dim ap As PHAccessPoint = aps.Get(i)
                
            Next
        End If
    End If
End Sub
Sub HUE_onAuthenticationRequired(apoint As PHAccessPoint)
    Log($"HUE_onAuthenticationRequired(${apoint})"$)
    If apoint<>Null And apoint Is PHAccessPoint Then
        Dim ap As PHAccessPoint = apoint
        ' Start the Pushlinkauthentification. You then need to press
        ' on the Pushlink button on the Bridge to connect it
        ' The sdk is waiting 30 seconds for a buttonpress
        sdk.startPushlinkAuthentication(ap)
    End If
End Sub
Sub HUE_onBridgeConnected(bridge As PHBridge, info As String)
    Log($"HUE_onBridgeConnected(${bridge},${info})"$)
    BridgeSelected = bridge
    Log("Check APs Username after connection: "&APselected.Username)
    ' Store the info about the AP into KVS for later autoconnecting...
    Dim ap As MyCustomAP
    ap.Initialize
    ap.BridgeId = APselected.BridgeId
    ap.BridgeIP = APselected.IpAddress
    ap.BridgeMac = APselected.MacAddress
    ap.BridgeUsername = APselected.Username
    Starter.kvs.Put("AP",ap)


    Dim lights As List
    lights = bridge.AllLights
    If lights.IsInitialized Then
        If lights.Size > 0 Then
            For i = 0 To lights.Size-1
                Dim light As PHLight = lights.Get(i)
            
                Log($"Light = ${light.Identifier} / Manufacturer = ${light.ManufacturerName} Model ${light.ModelNumber} LightType = ${light.LightType}"$)
                hueoverview.Put("Light"&light.Identifier,light)
            Next
        End If
    End If
    'Log("Lights: "&bridge.AllLights)

    Dim groups As List
    groups = bridge.AllGroups
    If groups.IsInitialized Then
        If groups.Size > 0 Then
            For i = 0 To groups.Size-1
                Dim group As PHGroup = groups.Get(i)
                Log($"Group = ${group.Name} / Type = ${group.GroupType} UniqueID = ${group.UniqueId}"$)
                Dim grlights As List = group.LightIdentifiers
                If grlights.IsInitialized And grlights.Size > 0 Then
                    For o = 0 To grlights.Size -1
                        Dim light As PHLight = hueoverview.Get("Light"&grlights.Get(o))
                        Log($"${light.Identifier}: ${light.ModelNumber} - ${light.LightType}"$)
                    Next
                End If
                'Log(group.LightIdentifiers)
            Next
        End If
    End If

    Dim sensors As List
    sensors = bridge.AllSensors
    If sensors.IsInitialized Then
        If sensors.Size > 0 Then
            For i = 0 To sensors.Size-1
                Dim sensor As PHSensor = sensors.Get(i)
                Log($"Sensor = ${sensor.Name} / Type = ${sensor.ModelId} - ${sensor.ManufacturerName} - UniqueID = ${sensor.UniqueId}"$)
            Next
        End If
    End If




    Log("Rules: "&bridge.AllRules)
    Log("Scenes: "&bridge.AllScenes)
    'Log("Sensors: "&bridge.AllSensors)
    Log("AllShedules: "&bridge.getAllSchedules(True))
    Log("AllTimers: "&bridge.getAllTimers(True))

End Sub
Sub HUE_onCacheUpdated(cacheNotifications As List, bridge As PHBridge)
    Log($"HUE_onCacheUpdated(${cacheNotifications},)"$)
End Sub
Sub HUE_onConnectionLost(ap As PHAccessPoint)
    Log($"HUE_onConnectionLost(${ap})"$)
End Sub
Sub HUE_onConnectionResumed(bridge As PHBridge)
    Log($"HUE_onConnectionResumed(${bridge})"$)
End Sub
Sub HUE_onError(code As Int, message As String)
    Log($"HUE_onError(${code},${message})"$)
End Sub
Sub HUE_onParsingErrors(errors As List)
    Log($"HUE_onParsingErrors(${errors})"$)
End Sub


Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub


Sub lvhue_ItemClick (Position As Int, Value As Object)
    Log($"Itemclick(${Position}, ${Value})"$)
    Dim obj() As Object = Value
    Dim light As PHLight = obj(0)
    Dim state As PHLightState = obj(1)
    Log("Lightstate is "&state.ON)
    If state.ON Then
        state.ON = False
        BridgeSelected.updateLightState(light,state)
    Else
        state.ON = True
        BridgeSelected.updateLightState(light,state)
    End If
End Sub

Sub lvbridges_ItemClick (Position As Int, Value As Object)
    Dim ap As PHAccessPoint = Value
    ' We want to connect to this AccessPoint.
    ' The SDK starts to connect to the Accesspoint.
    ' If you do not have it setup with a valid username then the Event HUE_onAuthenticationRequired is raised
    APselected = ap
    sdk.connect(ap)

End Sub
 

Attachments

  • PhilipsHueExample2-WithoutUsername.zip
    10.9 KB · Views: 363
Last edited:

DonManfred

Expert
Licensed User
Longtime User
WoW I now able to create my own discotheque in my room.
Hope you have fun :)

I´ve just tested it with White Lights (no Color) but the lib should work with Color-bulbs too.
I´ll receive a 2m Lightstrip in the next days so i can test it with color.
 

Daniel-White

Active Member
Licensed User
Longtime User
Hope you have fun :)

I´ve just tested it with White Lights (no Color) but the lib should work with Color-bulbs too.
I´ll receive a 2m Lightstrip in the next days so i can test it with color.

Make a video about your experiment, and please share here. :)
 

Johan Schoeman

Expert
Licensed User
Longtime User

Johan Schoeman

Expert
Licensed User
Longtime User
MagicLight are not compatible with the Philips HUE SDK.
Wrap it and post it separately if you can find one to test it with. Maybe you have better luck in locating such a light than what I have.
 

johndb

Active Member
Licensed User
Longtime User
Would this library work with B4J? Here is my thinking. AUDIO CONNECTION FROM SPEAKER -> MSGEQ7 -> ARDUINO -> RP3 (b4j) -> HUE.
This would sync lights with music. Yes, there are APPs that can do this but they don't use real time audio from your hi-fi equipment from what I understand.
 

johndb

Active Member
Licensed User
Longtime User
There appears to be a problem with the Bridge.updateLightState method where any light updates causes the light to blink. If the the color or brightness is changed there should not be any blinking of the light. This can be confirmed by modifying the lvhue_ItemClick event in the sample program as follows. Just make sure that your light is already on. Has anyone else had an issue with this?

B4X:
Sub lvhue_ItemClick (Position As Int, Value As Object)
    Log($"Itemclick(${Position}, ${Value})"$)
    Dim obj() As Object = Value
    Dim light As PHLight = obj(0)
    Dim state As PHLightState = obj(1)
 
    state.Brightness = 254 ' 125
    state.X = 0.4574
    state.Y = 0.41
    BridgeSelected.updateLightState(light,state)
 
'    Log("Lightstate is "&state.ON)
'    If state.ON Then
'        state.ON = False
'        BridgeSelected.updateLightState(light,state)
'    Else
'        state.ON = True
'        BridgeSelected.updateLightState(light,state)
'    End If
End Sub
 

johndb

Active Member
Licensed User
Longtime User
There appears to be a problem with the Bridge.updateLightState method where any light updates causes the light to blink. If the the color or brightness is changed there should not be any blinking of the light. This can be confirmed by modifying the lvhue_ItemClick event in the sample program as follows. Just make sure that your light is already on. Has anyone else had an issue with this?

B4X:
Sub lvhue_ItemClick (Position As Int, Value As Object)
    Log($"Itemclick(${Position}, ${Value})"$)
    Dim obj() As Object = Value
    Dim light As PHLight = obj(0)
    Dim state As PHLightState = obj(1)

    state.Brightness = 254 ' 125
    state.X = 0.4574
    state.Y = 0.41
    BridgeSelected.updateLightState(light,state)

'    Log("Lightstate is "&state.ON)
'    If state.ON Then
'        state.ON = False
'        BridgeSelected.updateLightState(light,state)
'    Else
'        state.ON = True
'        BridgeSelected.updateLightState(light,state)
'    End If
End Sub
Hi @DonManfred . Have you had an opportunity to review this issue?

Thank you,

John
 

DonManfred

Expert
Licensed User
Longtime User
Hi @DonManfred . Have you had an opportunity to review this issue?
Partially

Remark: I wrote the Lib as i got some bulbs. But honestly i did not work much with it at all. Except for the base tests if the Events are running, the objects are responding correctly and so

In fact i did connected my HUE-Bridge with Amazons Alexa and i use Voicecommands to switch the lights in my rooms using Alexa.

I tried your code with the only Colorbulb i have. A Lightstrip.
I ran into the same result. Just a short blinking.
Honestly: I would have done the code the same way like you. That´s how i understand the SDK. Maybe i did miss a detail in the wrapper.

Looks for me that we are missing something here when updating a bulb.
Maybe updating the new state in the bulb itself or in the Bridge.

I need (and will) to investigate

If you know a java example app which uses the java sdk then give me a link to the app-source. I´ll have a look and compare how it works
 

johndb

Active Member
Licensed User
Longtime User
Partially

Remark: I wrote the Lib as i got some bulbs. But honestly i did not work much with it at all. Except for the base tests if the Events are running, the objects are responding correctly and so

In fact i did connected my HUE-Bridge with Amazons Alexa and i use Voicecommands to switch the lights in my rooms using Alexa.

I tried your code with the only Colorbulb i have. A Lightstrip.
I ran into the same result. Just a short blinking.
Honestly: I would have done the code the same way like you. That´s how i understand the SDK. Maybe i did miss a detail in the wrapper.

Looks for me that we are missing something here when updating a bulb.
Maybe updating the new state in the bulb itself or in the Bridge.

I need (and will) to investigate

If you know a java example app which uses the java sdk then give me a link to the app-source. I´ll have a look and compare how it works

Thank you @DonManfred. I'm working on a project that will interface my 16 light system using audio control (FFT) hence the need for smooth lighting transitions. I don't know of any java sample code but will do some hunting. I very much appreciate you looking into this and for the great work that you do.

Thank you,

John
 

DonManfred

Expert
Licensed User
Longtime User
https://github.com/PhilipsHue/Phili...pApp/src/com/philips/lighting/Controller.java

This code is from a java desktop app...
This code does not use the given Lightstate. Instead it is using a NEW State and change the properties of this new state.

B4X:
 public void randomLights() {
        PHBridge bridge = phHueSDK.getSelectedBridge();
        PHBridgeResourcesCache cache = bridge.getResourceCache();

        List<PHLight> allLights = cache.getAllLights();
        Random rand = new Random();

        for (PHLight light : allLights) {
            PHLightState lightState = new PHLightState();
            lightState.setHue(rand.nextInt(MAX_HUE));
            bridge.updateLightState(light, lightState); // If no bridge response is required then use this simpler form.
        }
}
 

johndb

Active Member
Licensed User
Longtime User
Thank you @DonManfred. Your suggestion worked! It appears that you must create a new PHLightState object, set the parameters that you would like to adjust, and pass the new object to the updateLightState function. This eliminates the blinking and provides a smooth transition.

B4X:
Sub lvhue_ItemClick (Position As Int, Value As Object)
    Log($"Itemclick(${Position}, ${Value})"$)
    Dim obj() As Object = Value
    Dim light As PHLight = obj(0)
    Dim state As PHLightState = obj(1)
 
    Dim NewLightState As PHLightState
    NewLightState.Initialize("")
    NewLightState.Brightness = 254 ' 125
    NewLightState.X = 0.4574
    NewLightState.Y = 0.41
    BridgeSelected.updateLightState(light,NewLightState)
 
 
'    Log("Lightstate is "&state.ON)
'    If state.ON Then
'        state.ON = False
'        BridgeSelected.updateLightState(light,state)
'    Else
'        state.ON = True
'        BridgeSelected.updateLightState(light,state)
'    End If
End Sub

Thank you again Manfred. It may be worth updating your post 1 to include this information.

John
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
Your suggestion worked! It appears that you must create a new PHLightState object, set the parameters that you would like to adjust, and pass the new object to the updateLightState function. This eliminates the blinking and provides a smooth transition.
Cool. Great you figured it out. I´ll update #1 with this info
 

johndb

Active Member
Licensed User
Longtime User
@DonManfred. I have written the HUE code in a class and have discovered a problem with the sdk's "_onCacheUpdated" event. It is not called in response to an "updateLightState" call when the event sub is located in the class. The other events such as "_onBridgeConnected" and "_onAuthenticationRequired" are called properly. Could the callback for "onCacheUpdated" in the library be hardwired to the activity by error instead of dynamic?

Thanks for your help,

John
 
Top