B4J Library HUE4j - Philips SDK - Control your HUE System

HUE4j
Version:
0.3
  • PHAccessPoint
    Methods:
    • Initialize (EventName As String)
      The PHAccessPoint abstracts a hue access point.
      An access point is an entry point to the hue system.
    • IsInitialized As Boolean
    Properties:
    • BridgeId As String
    • IpAddress As String
      Returns IP address of the access point.
    • MacAddress As String
      Returns MAC address of the access
      point in upper case.
    • Username As String
      Returns user name of access point.
  • PHBridge
    Events:
    • onAllGroups (groups As List)
    • onAllLights (lights As List)
    • onConfig (config As PHBridgeConfiguration)
    • onError (code As Int, message As String, mgstype As String)
    • onGroupCreated (group As PHGroup)
    • onGroupDetail (group As PHGroup)
    • onLightDetail (light As PHLight)
    • onReceivingRuleDetails (rule As PHRule)
    • onReceivingSensorDetails (sensor As PHSensor)
    • onRuleReceived (rules As List)
    • onSceneReceived (scene As PHScene)
    • onScenesReceived (scenes As List)
    • onScheduleCreated (schedule As PHSchedule)
    • onSearchComplete ( As )
    • onSensorSearchFinished ( As )
    • onSensorsReceived (sensors As List)
    • onStateUpdate (success As Map, errors As List, updType As String)
    • onSuccess (msgtype As String)
    Methods:
    • Initialize (EventName As String, bridge As PHBridge)
    • IsInitialized As Boolean
    • activateScene (sceneIdentifier As String, groupIdentifier As String)
      Activates a Scene with given identifier.
      sceneIdentifier:
      groupIdentifier:
    • createGroup (name As String, lightIdentifiers As List)
      Creates new group using given name and the associated lights.
      name:
      lightIdentifiers:
    • createRule (rule As PHRule)
      Create a new rule in the bridge
    • createSchedule (schedule As PHSchedule)
      Create schedule with given schedule object.
      schedule:
    • createSensor (sensor As PHSensor)
      Create a new sensor in the bridge
    • deleteGroup (groupidentifier As String)
      Deletes the group corresponding to identifier.
    • deleteLightbyId (light As String)
    • deleteRule (ruleidentifier As String)
      Deletes the rule corresponding to identifier.
    • deleteSensor (sensoridentifier As String)
      Deletes the sensor corresponding to identifier.
    • findNewLights
      Returns newly found lights around the bridge.
    • findNewLightsWithSerials (serials As List)
    • findNewSensors
      Returns newly found lights around the bridge.
    • findNewSensorsWithSerials (serials As List)
    • getAllSchedules (arg0 As Boolean) As List
    • getAllTimers (arg0 As Boolean) As List
    • removeSchedule (schedule As String)
      Remove schedule with given identifier.
      schedule:
    • saveLightState (lightIdentifier As String, sceneIdentifier As String, state As PHLightState)
      Save light state for Scene with given scene identifier
      lightIdentifier:
      sceneIdentifier:
      state:
    • saveScene (scene As PHScene)
      Saves a scene in bridge
      scene:
    • saveSceneWithCurrentLightStates (scene As PHScene)
      Save a Scene with current light state
      scene:
    • saveSensorConfiguration (sensor As PHSensor)
      Save the sensor configuration to the sensor on the bridge
      sensor:
    • saveSensorState (sensor As PHSensor)
      Save the sensor state to the sensor on the bridge
      sensor:
    • setLightStateForGroup (groupIdentifier As String, state As PHLightState)
      Replaces current light state for a group
      with the new light state.
      groupIdentifier:
      state:
    • updateBridgeConfigurations (bridgeConfig As PHBridgeConfiguration)
      Replace current configuration of the bridge based
      on the information inside new PHBridgeConfiguration
      object.
      config:
    • updateGroup (group As PHGroup)
      Updates the group with the given identifier
      using the information in the PHGroup object.
    • updateLight (light As PHLight)
      Updates the light corresponding to identifier
      using the information in the new PHLight object.
      light:
    • updateLightState (light As PHLight, state As PHLightState)
      Updates the LightState of the given light
    • updateRule (rule As PHRule)
      Update the rule
    • updateSensor (sensor As PHSensor)
      Update the Sensor
    • updateShedule (shedule As PHSchedule)
      Update the Schedule
    • updateSoftware
      Enables update Software process.
    Properties:
    • AllGroups As List [read only]
    • AllLights As List [read only]
    • AllRules As List [read only]
    • AllScenes As List [read only]
    • AllSensors As List [read only]
    • LightStateForDefaultGroup As PHLightState [write only]
      Replaces current light state for a group
      with the new light state.
  • PHBridgeConfiguration
    Methods:
    • Initialize (EventName As String, config As PHBridgeConfiguration)
    • IsInitialized As Boolean
    Properties:
    • APIVersion As String
  • PHBridgeHeader
    Methods:
    • Initialize (EventName As String, bridge As BridgeHeader)
    • IsInitialized As Boolean
    Properties:
    • IPAddress As String
    • LastHeartbeat As Long
    • Status As String
  • PHBridgeResource
    Methods:
    • Initialize (EventName As String, identifier As String, name As String)
    • IsInitialized As Boolean
    Properties:
    • Identifier As String
    • Name As String
  • PHGroup
    Methods:
    • Initialize (EventName As String, identifier As String, versionNumber As String, modelNumber As String)
    • IsInitialized As Boolean
    Properties:
    • GroupType As String
    • Identifier As String
    • LightIdentifiers As List
    • ModelId As String
    • Name As String
    • UniqueId As String
  • PHHueSDK
    Events:
    • onAccessPointsFound (APs As List)
    • onAuthenticationRequired (ap As PHAccessPoint)
    • onBridgeConnected (bridge As PHBridge, info As String)
    • onCacheUpdated (cacheNotifications As List, bridge As PHBridge)
    • onConnectionLost (as As PHAccessPoint)
    • onConnectionResumed (bridge As PHBridge)
    • onError (code As Int, message As String)
    • onParsingErrors (errors As List)
    Fields:
    • TAG As String
    Methods:
    • InitManager As Boolean
    • Initialize (EventName As String, appName As String, Devicename As String)
      Creates a hue SDK instance which enables
      searching, connecting and interacting
      with bridge.
    • addBridge (bridge As PHBridge)
      Adds connected bridge to list of available bridges for
      internal modules if the array list of bridge or the
      PHBridge object is null, then it doesn't add.
    • cancelSearchNotification
    • connect (accessPoint As PHAccessPoint)
      User connects to a bridge using connect(PHAccessPoint).
      The bridge will need authentication(push link) if the
      device is connecting to the bridge for first time
    • destroySDK
      Cleans up resources held by the SDK.
    • disableAllHeartbeat
      Stops all running heartbeats for all bridges.
    • disconnect (bridge As PHBridge)
    • enableHeartbeat (bridge As PHBridge, time As Long)
      Enables heartbeat for requested bridge to receive
      the full configuration with time interval in
      milliseconds.
      bridge:
      time:
    • getGroupNames (groups As List)
      Gives group name array from
      array list of PHGroup objects.
    • getLightNames (ligths As List) As List
      Gives lights name array from
      array list of PHLight objects.
    • getSDKService (msgType As Byte) As Object
      Returns a handle to the
      requested hue SDK service.
    • getScheduleNames (shedules As List) As String[]
      Gives timer name array from
      array list of PHSchedule objects.
    • ipAddressSearch
    • isAccessPointConnected (ap As PHAccessPoint) As Boolean
    • isHeartbeatEnabled (bridge As PHBridge) As Boolean
    • portalSearch
    • randomLights
    • removeBridge (bridge As PHBridge) As Boolean
    • search (searchUpnp As Boolean, searchPortal As Boolean)
    • search2 (searchUpnp As Boolean, searchPortal As Boolean, searchIpAddress As Boolean)
    • startPushlinkAuthentication (accessPoint As PHAccessPoint)
      Allows user to authenticate
      by pressing link button of
      the bridge within 30 second.
    • stopPushlinkAuthentication
      Allows the user to cancel
      the Pushlink authentication.
    • upnpSearch
    Properties:
    • AccessPointsFound As List [read only]
      Returns a list of found Access Points.
    • AllBridges As List [read only]
      Returns list of bridges connected to hue SDK.
    • AppName As String [read only]
      Returns the appName in which the SDK is embedded
    • BridgesForDisplay As List [read only]
      Provides a list of a bridges.
    • CurrentLightState As PHLightState [read only]
      Convenience method for getting
      the current light state
    • DeviceName As String [read only]
      Returns device name on which SDK running
    • DisconnectedAccessPoint As List [read only]
      Returns a disconnected access point.
    • HeartbeatManager As PHHeartbeatManager [read only]
      This should be used for more advanced heartbeat
      configuration options (e.g Start heartbeat for
      just lights and groups)
    • InternalObject As PHBridgeInternal [read only]
      Provides a new bridge internal object PHBridgeInternal
    • LastHeartbeat As Map [read only]
      Returns the last heartbeat.
    • NotificationManager As PHNotificationManager [read only]
      Provides the Notificatino Manager
    • PortalAddress As String
    • SDKVersion As String [read only]
      Provides hue SDK version.
    • SelectedBridge As PHBridge [read only]
      Setter for the selected
      (currently active) bridge.
  • PHLight
    Methods:
    • Initialize (EventName As String, identifier As String, versionNumber As String, modelNumber As String)
    • IsInitialized As Boolean
    Properties:
    • Identifier As String
    • LastKnownLightState As PHLightState
    • LightType As PHLightType
    • LuminaireUniqueId As String
    • ManufacturerName As String
    • ModelNumber As String
  • PHLightState
    Methods:
    • Initialize (EventName As String)
    • IsInitialized As Boolean
    • validateState As String
    Properties:
    • AlertMode As PHLightAlertMode
    • Brightness As Integer
    • ColorMode As PHLightColorMode
    • ColorModeCt As PHLightColorMode [read only]
    • ColorModeHueSat As PHLightColorMode [read only]
    • ColorModeNone As PHLightColorMode [read only]
    • ColorModeUnknown As PHLightColorMode [read only]
    • ColorModeXY As PHLightColorMode [read only]
    • Ct As Int
    • EffectMode As PHLightEffectMode
    • Hue As Integer
    • IncrementBri As Int
    • IncrementCt As Int
    • IncrementHue As Int
    • IncrementSat As Int
    • IncrementX As Float
    • IncrementY As Float
    • LightAlertModeLSelect As PHLightAlertMode [read only]
    • LightAlertModeNone As PHLightAlertMode [read only]
    • LightAlertModeSelect As PHLightAlertMode [read only]
    • LightAlertModeUnknown As PHLightAlertMode [read only]
    • LightEffectModeColorLoop As PHLightEffectMode [read only]
    • LightEffectModeNone As PHLightEffectMode [read only]
    • LightEffectModeUnknown As PHLightEffectMode [read only]
    • ON As Boolean
    • Reachable As Boolean
    • Saturation As Integer
    • TransitionTime As Integer
    • X As Float
    • Y As Float
  • PHRule
    Methods:
    • Initialize (EventName As String, name As String, identifier As String)
    • IsInitialized As Boolean
    Properties:
    • Actions As List
    • Conditions As List
    • CreationTime As Long
    • LastTriggered As Long
    • Name As String
    • Owner As String
  • PHRuleCondition
    Methods:
    • Initialize (EventName As String)
    • IsInitialized As Boolean
    Properties:
    • Address As String
    • Operator As PHRuleConditionOperator
    • OperatorDDX As PHRuleConditionOperator [read only]
    • OperatorDT As PHRuleConditionOperator [read only]
    • OperatorDX As PHRuleConditionOperator [read only]
    • OperatorEQ As PHRuleConditionOperator [read only]
    • OperatorGT As PHRuleConditionOperator [read only]
    • OperatorLT As PHRuleConditionOperator [read only]
    • Value As Object
  • PHScene
    Methods:
    • Initialize (EventName As String, identifier As String, versionNumber As String, modelNumber As String)
    • IsInitialized As Boolean
    • getVersion (version As Int)
    Properties:
    • ActiveState As PHSceneActiveState
    • AppData As PHAppData
    • Lastupdated As Long
    • LightIdentifiers As List
    • LightStates As Map [read only]
    • Locked As Boolean
    • Name As String
    • Owner As String
    • Picture As String
    • Recycle As Boolean
    • SCENE_STATE_ACTIVE As PHSceneActiveState [read only]
    • SCENE_STATE_INACTIVE As PHSceneActiveState [read only]
    • SCENE_STATE_UNKNOWN As PHSceneActiveState [read only]
    • SceneIdentifier As String
    • TransitionTime As Int
    • Version As Integer [read only]
  • PHSchedule
    Methods:
    • Initialize (EventName As String, name As String, identifier As String)
    • IsInitialized As Boolean
    Properties:
    • Name As String
    • Owner As String
  • PHSensor
    Methods:
    • Initialize (EventName As String, sensor As PHSensor)
    • IsInitialized As Boolean
    • getSwVersion (version As String)
    Properties:
    • Identifier As String
    • ManufacturerName As String
    • ModelId As String
    • Name As String
    • SwVersion As String [read only]
    • UniqueId As String
 

Attachments

  • PhilipsHueExample4j.zip
    3.9 KB · Views: 524
  • HUE4jV0.3.zip
    444.7 KB · Views: 517
Last edited:

miker2069

Active Member
Licensed User
Longtime User
Dude - you totally rock. I have a ton of hue lights and just haven't had a time to go over the HUE rest API. This I am sure will save a lot of time! I will most certainly download and donate ;)
 

DonManfred

Expert
Licensed User
Longtime User
I have a ton of hue lights
You best get started with this library if you already configured some scenes, groups, rooms inside the Philips HUE app. But i guess you already done that like me.

Have fun! Share your results :)
 

tufanv

Expert
Licensed User
Longtime User
I don't have a hue to work with but you are totally opening doors for many developers here ! Thanks Don !
 

miker2069

Active Member
Licensed User
Longtime User
Hi DonManfred, I finally got a chance to play with this library (I have a ton of color hue lights also!) and I must say great work. I was pretty much up and running the example which lists all my lights in about 20 minutes or so.

I'm playing with basic things like turning lights on/off, brightness, saturation - all that works great. The only thing that doesn't seem to respond is changing the hue. So if I try something like:

B4X:
state.Hue = 10000 'should change to an orange/yellowish color
BridgeSelected.updateLightState(light,state)

It doesn't seem to work (the light sorta flickers), but the color stays the same. I verified I can change the color using the Phillips CLIP API Debugger web page (and actually I chose hue=10000 from the Phillips API getting started page here.

Other than that, pretty awesome work! I plan on digging into some of the other features this weekend.

Also out of curiousity did you wrap the Hue Java SDK or just go directly against the web SDK/API?
 
Last edited:
Top