Code Monkey home page Code Monkey logo

philipshuesdk-java-multiplatform-android's Introduction

This repository is deprecated.

Deprecation – Philips Hue SDK

We have decided to deprecate the hue SDK effective as of July 1st 2019. This means there will be no new SDK releases except for critical updates (e.g. security) which will be maintained for one additional year. Existing Hue SDK client applications will continue to work normally but we can no longer guarantee long term compatibility with future Hue software. We strongly recommend Hue SDK users to migrate to Hue API which remains up-to-date and supported.

FAQ

Why is this changing? Philips Hue has decided to focus its resources into improving the Hue API and building new features. The usage of the SDK has been declining as has our own dependence on it so we feel it is more beneficial to focus on building directly on the Hue API.

Who’s Impacted? Anyone who is leveraging the Philips Hue SDK.

Who’s Not Impacted? Anyone who is not utilizing the Philips Hue SDK.

What should you use instead? Philips Hue API

Next steps? Migration code samples and best practice blogs by Hue Developer Program.

Question? Contact us! https://developers.meethue.com/support/

See also: https://developers.meethue.com/deprecation-philips-hue-sdk/


The Hue SDK by Philips

(c) Copyright Philips 2012-2014 Java SDK Guide

Full documentation and code examples for using the hue Java SDK can be found on our developer portal:

http://developers.meethue.com/documentation/java-multi-platform-and-android-sdk

and:

http://www.developers.meethue.com/documentation/java-sdk-getting-started


Our new developer portal also contains interviews with 3rd party developers, lists of Android 3rd party hue apps as well as instructions on how to promote your app. Your 3rd party Android apps are now promoted in the official Philips hue app meaning even greater exposure!

http://developers.meethue.com/


Acknowledgements ---------------- Please adhere to any third party licenses that are applicable on this SDK when building applications with our SDK or using the QuickStart applications as your base (see ACKNOWLEDGEMENTS file in this repository, for applicable licenses).

Philips releases this SDK with friendly house rules. These friendly house rules are part of a legal framework; this to protect both the developers and hue. The friendly house rules cover e.g. the naming of Philips and of hue which can only be used as a reference (a true and honest statement) and not as a an brand or identity. Also covered is that the hue SDK and API can only be used for hue and for no other application or product. Very common sense friendly rules that are common practice amongst leading brands that have released their SDK’s.

Copyright (c) 2012- 2013, Philips Electronics N.V. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

  • Neither the name of Philips Electronics N.V. , nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOTLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FORA PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER ORCONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, ORPROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OFLIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDINGNEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THISSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

philipshuesdk-java-multiplatform-android's People

Contributors

steveyo avatar twankamp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

philipshuesdk-java-multiplatform-android's Issues

Creating groups (as room) fails.

When I try to create a group (type: "Room" and groupClass: "CLASS_GARDEN")
with bridge.createGroup(group, listener) I receive the error "invalid value, CLASS_GARDEN, for parameter, class".

Updating a room (that was previously created with the official hue app) just ignores the changed groupClass.

No lights

Hi everyone
I use java desktop app. It searches for a bridge and find and connect to it but it couldn't find any hue lights (I have three hue lamps powered on).

Thanks in advance.

java.lang.ClassNotFoundException: com.philips.lighting.hue.listener.PHLightListener

Hello,

i want to connect philips hue to tomcat 9. But the server can't deploy and throws following exception:

Caused by: java.lang.ClassNotFoundException: com.philips.lighting.hue.listener.PHLightListener
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1275)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1109)

I develop with Eclipse and have put the two necessary jar-files to Build-Path.

What can I do?

Thanks for your help!

Provide example of non-deprecated PHBridge.createGroup

Hi, it appears the 'recommended' method of creating groups, by passing the String name and List of lightIds, is now deprecated. It appears the migration path to the alternate createGroup call is not as simple as I would have assumed. My first inclination would be to translate this old call:

bridge.createGroup( groupName, lightIdentifiers, null );

into something like this:

PHGroup group = new PHGroup( groupName, lightIdentifiers );
bridge.createGroup( group, null );

But that isn't syntactically valid since the group initializer doesn't work on the list of lightIds. It instead probably wants to be used like this:

PHGroup group = new PHGroup( groupName, {some sort of group id} );
group.setLightIdentifiers( lightIdentifiers );
bridge.createGroup( group, null );

But it's not clear to me what I should be passing as the group identifier in this case in order to initialize safely/correctly.

Any insights? Side note, are you planning on updating the javadocs? Thanks!

QuickStartApp using obsolete android build tools

Consider updating QuickStartApp to the current Android build tools (building with gradle, targeting SDK 23, etc) as this sample app still relies on deprecated build tools from before the era of Android Studio.

Please remove Android Permission GET_TASKS dependency

Using the Android permission GET_TASKS in an Android app,
triggers the following permission request while installing the app:

** Device & app history.
** Allows the app to view one or more of:
** information about activity on the
** device, which apps are running,
** browsing history and bookmarks.

Users get suspicious about what the app does with this personal information.
I looked at the code and I don't see why we would need this permission request.

If it is used with activity intents to handle the back stack, couldn't this be solved with an:
android:noHistory="true" attribute in the AndroidManifest?

Hope you can work around this permission.

Best Regards, Stefan

Rule unparsable due to error: No enum constant com.philips.lighting.model.rule.PHRuleCondition.PHRuleConditionOperator.OPERATOR_IN

Users are reporting problems caused by the SDK not supporting motion sensors:

Sensor unparsable due to error: Internal error: JSON contains invalid type data

Rule unparsable due to error: No enum constant com.philips.lighting.model.rule.PHRuleCondition.PHRuleConditionOperator.OPERATOR_IN

Also reported here:

https://developers.meethue.com/content/hue-motion-sensor-not-fully-supported-javaandroid-sdk
https://developers.meethue.com/content/motion-sensor-not-supported

Make the code better testable

Please make the code better testable. The constructor and instance field of several classes like PHHueSDK should be protected.

org.json package should not be part of the jar

It's annoying that you package org.json.* as this might cause conflicts.

better options:

  • depend on org.json from maven central
  • move those files to com.philips.internal.org.json to avoid conflict and make it clear that they should not be used.
  • make sure that they are not publicly visible.

Offline bridge?

Hi all,

I've encountered an installation that requires the Hue bridges to be on their own network with my app/device that is not connected to the internet. Using the Hue smartphone app, the bridge is found on the local network and I can control lights, I can use the Hue Tap switch, etc., but in my Java app, I get a "Bridge Not Found" error when trying to find the bridge(s).

This is using the UPNP/Portal search method (sm.search(true, true)), then catching the error, then resorting to the IP Search method (sm.search(false, false, true)), just like in the quickstart app. All search methods fail.

I can see the hue bridge IP as connected in my DD-WRT router settings page, use the clip debugger, etc. The router has its own DHCP server and local DNS server set up. I've tried a number of router configurations but haven't been able to get it to respond.

So, theoretically, is it possible to connect an SDK app to the bridge when it is offline, as you can do with the official Hue smartphone app? Any suggestions on what I can do to mitigate this problem?

Thanks a lot,
Greg

ConcurrentModificationException in the Hue SDK

We are busy with a Hue app on Android, and often when the bridge becomes unavailable we get the error below. Our implementation of PHSDKListener will post all callbacks to a handler, so we are pretty sure it is not something in our code. Can you please look into it?

Process: <MyProcess>, PID: 10493
java.util.ConcurrentModificationException
at java.util.ArrayList$ArrayListIterator.next(ArrayList.java:573)
at com.philips.lighting.hue.sdk.notification.impl.PHNotificationManagerImpl$1.onReceived(PHNotificationManagerImpl.java:128)
at com.philips.lighting.hue.sdk.notification.impl.PHHueResultReceiver.execute(PHHueResultReceiver.java:26)
at com.philips.lighting.hue.sdk.notification.impl.PHNotificationManagerImpl.notifySDKError(PHNotificationManagerImpl.java:136)
at com.philips.lighting.hue.sdk.heartbeat.PHHeartbeatProcessor.run(PHHeartbeatProcessor.java:132)
at java.util.Timer$TimerImpl.run(Timer.java:284)

NullPointerException when updating light state

Fellow hue devs,

I've been implementing the SDK into a desktop app over the past week or so, and I've been able to connect to the bridge, list all lights, and add parameters like Ct and brightness to new light states. However, when I go to update the light state using either bridge.updateLightState or bridge.setLightStateForDefaultGroup, execution halts on this line and Eclipse throws out a null pointer exception.

The (somewhat out of date) javadoc says this will occur if either the light identifier or the state are null, at least for setLightStateForDefaultGroup. I don't believe either of these are null in my case: running lightState.validateState returns no errors, the same values are returned that I entered with commands like lightState.getCt and getBrightness, the lights are already on (and are verified to be on), and I can spit out the same light identifier that I request with light.getIdentifier. Additionally, if I use the CLIP debugger in the browser, I can control the lights just fine.

Here are the steps I am taking in a bit more detail, with the output I get in comments:

lightState = new PHLightState();

lightState.setOn(true);
lightState.setBrightness(120);
lightState.setCt(250);

System.out.println(lightState.isOn()); // prints true
System.out.println(lightState.getBrightness()); // prints 120
System.out.println(lightState.getCt()); // prints 250
System.out.println(lightState.validateState()); // prints null, meaning no errors

// Assuming lightID = 1:
public static void updateLightState(int lightID) {
    PHLight light = lightList.get(lightID - 1); // with lightList a List(PHLight) of all the lights I have
    System.out.println(light.getIdentifier()); // prints 1
    bridge.updateLightState(light, lightState, lightListener); // returns java.lang.NullPointerException
}

The same thing happens if I try to update all the lights:

bridge.setLightStateForDefaultGroup(lightState); // returns java.lang.NullPointerException

Now, I could see setLightStateForDefaultGroup failing in my case, because I have 3 full-color hue A19s, 1 hue BR30, and one hue lux A19 - the hue lux could theoretically throw an error (although a different one?) because it can't accept Ct values. However, the three A19 full-color bulbs are numbered 1-3 in my case, and if I try individually addressing any of these bulbs with updateLightState, I get the same NullPointerException.

Any ideas about what could be going wrong here?

Thanks in advance!
Greg

PHBridgeResourcesCache

The PHBridgeResourcesCache class and the getScenes or getAllScenes return more scenes than on meethue.com or in the apps (Android or iOS) Some of those scenes are having only identifier names and are missing the normal names.

Is the getAllScenes method returning deleted scenes as well? Is there a way to return only available scenes that are visible on each app (android, iOS or Meethue ) with the correct names?

com.philips.lighting.model.PHBridge#removeSchedule(String, PHScheduleListener) is not working

Hi

The removeSchedule() method provided on the PHBridge object seems to be broken. When I call it my schedules don't get deleted from the bridge and the listener is not called on any of its methods.

I decompiled the code from the SDK and it seems to me that the problem is that the PHLocalBridgeDelegator1_0#removeSchedule() method, which calls PHNotificationManagerImpl.getNotificationManager() instead of PHNotificationManagerImpl.getInstance(). The getNotificationManager() just returns the value currently set on PHNotificationManagerImpl#notificationManager instead of creating such an instance. As the return value of this call is NULL, the removeSchedule() method returns on line 1042 without having removed the schedules.

Can you have a look into this?

Best,
Lorenz

p.s. Are there any plans on opensourcing the API? That way I could fix it myself and attach a pull request.

ConcurrentModificationException

Hi guys, I keep getting the below exception. I suspect it has to do with starting and stopping the bridge heartbeat too quickly due to android's lifecycle but I haven't been able to root cause it. Anybody have any ideas? Thanks!

Exception java.util.ConcurrentModificationException: java.util.ArrayList$ArrayListIterator.next (ArrayList.java:573) com.philips.lighting.hue.sdk.notification.impl.PHNotificationManagerImpl$8.onReceived (PHNotificationManagerImpl.java:296) com.philips.lighting.hue.sdk.notification.impl.PHHueResultReceiver.execute (PHHueResultReceiver.java:24) com.philips.lighting.hue.sdk.notification.impl.PHNotificationManagerImpl.notifyConnectionResumed (PHNotificationManagerImpl.java:303) com.philips.lighting.hue.sdk.heartbeat.PHHeartbeatProcessor.run (PHHeartbeatProcessor.java:148) java.util.Timer$TimerImpl.run (Timer.java:284)

Provide an alternative to PHBridgeInternal.generateUniqueKey()

Hello I have a method:

   public String getLastAccessPointUser() {
        if (!isNullOrEmpty(getPropertyAsString(PHILIPS_HUE_LAST_CONNECTED_USERNAME))) {
            return getPropertyAsString(PHILIPS_HUE_LAST_CONNECTED_USERNAME);
        } else {
            String username = PHBridgeInternal.generateUniqueKey();
            savePropertyAsString(PHILIPS_HUE_LAST_CONNECTED_USERNAME, username);
            return username;
        }
    }

I see that in latest JAR this method doesn't exist, please help me figuring out how should I do it using current version of JARs.

Thank you,
Timur

Can I use HUE API in MATLAB?

Hello,

I'm trying to control Hue with diverse way. However, SDK is provided as only Apple or JAVA style.
Unfortunately, I am not familiar with those environment. So, I want to use them or another SDK for MATLAB program.

So.... is there any possible way to use JAVA API in MATLAB?

Connect twice in one app

Hi,

I have some special requirements.. ;)

I have an app which is connecting to the bridge as usual -> means that I implemented the connection like in the example (http://www.developers.meethue.com/documentation/java-sdk-getting-started#connectingToABridge).
My app is using a BroadcastReceiver, so it is waking if some events come up. Is this BroadcastReceiver I want to connect to the bridge and do some color changes. The problem is now that it is sometimes not possible to connect because the other part of the app is already connected to the bridge.
I get no error message but it seems to be that the method phHueSDK.isAccessPointConnected(lastAccessPoint) is hanging and do nothing.

Any suggestions how to solve these multiple connect to one bridge?

Thanks!
tomu

Provide a method to get the modelid from a PHAccessPoint

There is no way currently to show the correct bridge image when it requires authentication because we have no way to know to which kind of device we are connecting to. The API may support it but the sdk doesn't seem to provide a method to do it.

autoDelete flag is sent for recurring schedules

Although the flag is as said by the doc not used by the recurring schedules, the flag is sent with the updateSchedule Command which produces an error:

code=6;message=parameter, autodelete, not available

Bridge version is: 01036659
SDK -> Master

Android N crash

java.lang.Throwable: Explicit termination method 'close' not called
                                                                        at dalvik.system.CloseGuard.open(CloseGuard.java:180)
                                                                        at java.net.AbstractPlainSocketImpl.create(AbstractPlainSocketImpl.java:103)
                                                                        at java.net.Socket.createImpl(Socket.java:451)
                                                                        at java.net.Socket.getImpl(Socket.java:517)
                                                                        at java.net.Socket.setSoTimeout(Socket.java:1108)
                                                                        at com.android.okhttp.Connection.connectSocket(Connection.java:195)
                                                                        at com.android.okhttp.Connection.connect(Connection.java:172)
                                                                        at com.android.okhttp.Connection.connectAndSetOwner(Connection.java:367)
                                                                        at com.android.okhttp.OkHttpClient$1.connectAndSetOwner(OkHttpClient.java:130)
                                                                        at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:329)
                                                                        at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:246)
                                                                        at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:457)
                                                                        at com.android.okhttp.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:126)
                                                                        at com.philips.lighting.hue.sdk.connection.impl.PHHueHttpConnection.getData(PHHueHttpConnection.java:74)
                                                                        at com.philips.lighting.hue.sdk.upnp.IPAddressScanner.call(IPAddressScanner.java:36)
                                                                        at com.philips.lighting.hue.sdk.upnp.IPAddressScanner.call(IPAddressScanner.java:12)
                                                                        at java.util.concurrent.FutureTask.run(FutureTask.java:237)
                                                                        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
                                                                        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
                                                                        at java.lang.Thread.run(Thread.java:761)

Strobe effect not working

Hello,
I am trying to get the strobe light effect with my hue bulbs, but for reason the result that I get are not satisfactory. I don't see a smooth strobe effect. Sometimes light gets stuck at a state and lags in giving the strobe effect. Every time the behavior is random. Is it difficult to have strobe effect? Here is the code that I use.

public void strobe(final int timeInMillis, final int speed) {

    Thread t1 = new Thread() {

        @Override
        public void run() {

            long startTime = SystemClock.uptimeMillis();
            while ((SystemClock.uptimeMillis() - startTime) < timeInMillis) { // Strobe for the amount of time specified. 
                if (flag) { // True initially
                    flag = false;
                    lightState.setOn(true);
                } else {
                    flag = true;
                    lightState.setOn(false);
                }
                lightState.setTransitionTime(1); // max 65500
                lightState.setBrightness(254);
                Log.e("TAG", "State is" + lightState.validateState());
                bridge.updateLightState(light1, lightState, listener);
                try {
                    Thread.sleep(20);
                } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        }
    };
    t1.start();
}

Am I doing something wrong? I do get the log that the state is validated, but light bridge doesnt update everytime as I want. Why am I not getting expected results?

Blinking Hue

Hello,
Just started writing my hue apps and so far the basics look good, except that lack of javadocs for some APIs makes life a little harder. So my question is how can I make the light have a blinking effect? I tried doing something like this

//pseudo code
lightState.setOn(true);
Log.e("TAG", "State for Light 2 =" + lightState.validateState());
bridge.updateLightState(light2, lightState, listener);

// Sleep thread for sometime

lightState.setOn(false);
Log.e("TAG", "State for Light 2 =" + lightState.validateState());
bridge.updateLightState(light2, lightState, listener);

so on and so forth. Is this the best way to do it? The problem is I barely see any blink. Sometimes it happens sometimes it just get dimmed. What is a best way to blink?

Thanks

-Snehal

Android 8.0+ Pushlink Issue

My Android 8.0+ emulators targeting API 26+ are hanging up when trying to authenticate the user at the pushlink activity.

Any idea on how to fix?

Thanks!

R class not present

Hello everybody,

I tried to import your great source code on eclipse IDE.

I can't find the class com.philips.lighting.quickstart.R then I have a lot of erros related if I am adding android.R

Could you help me ?

error1
error2

Regular `JSONException` on PHHueSDK.connect

Regularly, when calling connect on an instance of PHHueSDK, or when pushlinking (specifically, in the response I get after pushing the link button), I'm getting a JSONException from the PH internals:

04-24 00:05:52.162 28977-29009/me.steenman.wearhue W/System.err: org.json.hue.JSONException: Expected a ',' or '}' at 21495 [character 1 line 2]
04-24 00:05:52.162 28977-29009/me.steenman.wearhue W/System.err:     at org.json.hue.JSONTokener.syntaxError(JSONTokener.java:433)
04-24 00:05:52.162 28977-29009/me.steenman.wearhue W/System.err:     at org.json.hue.JSONObject.<init>(JSONObject.java:233)
04-24 00:05:52.162 28977-29009/me.steenman.wearhue W/System.err:     at org.json.hue.JSONObject.<init>(JSONObject.java:325)
04-24 00:05:52.162 28977-29009/me.steenman.wearhue  W/System.err:     at com.philips.lighting.hue.sdk.connection.impl.PHBridgeInternal.processResponse(PHBridgeInternal.java:438)
04-24 00:05:52.162 28977-29009/me.steenman.wearhue W/System.err:     at com.philips.lighting.hue.sdk.connection.impl.PHBridgeInternal$1.run(PHBridgeInternal.java:119)

This is the error that is thrown when connecting to a known bridge, specifically. It's always at the same character, and it seems to be just a single '}' from the end of the response. It seems to happen about once every three launches, and I have not seen it when simply updating a light's state, so far.

I'm developing for Android Wear 2.0, PHHueSDK 1.11.2, the newest huesdkresources.jar (as far as I know), and a bridge v2 running the April 12 patch.

How I'm connecting:

PHHueSDK hueSDK = PHHueSDK.create();
hueSDK.setAppName("WearHue");
hueSDK.setDeviceName(android.os.Build.MODEL);
hueSDK.getNotificationManager().registerSDKListener(this);

PHAccessPoint ap = new PHAccessPoint();
ap.setIpAddress(bridgeIp);
ap.setUsername(bridgeUser);

hueSDK.connect(ap);

Program Dangling? (Thread still active)

Hello,

I think this is going back to a previous issue listed here - #13.

I have built a java program where I want to change a few configurations on the lights. To keep it as relevant as possible, here is the following code I altered from the original Java Desktop App:

 private PHSDKListener listener = new PHSDKListener() {

        @Override
        public void onAccessPointsFound(List<PHAccessPoint> accessPointsList) {
            System.out.println("INFO: Found Access Points! Using the first one");

            // Get the first Access Point listed
            phHueSDK.connect(accessPointsList.get(0));
        }

        @Override
        public void onAuthenticationRequired(PHAccessPoint accessPoint) {
            // Start the Pushlink Authentication.
            System.out.println("INFO: Press the link button on the bridge to authenticate");
            phHueSDK.startPushlinkAuthentication(accessPoint);
        }

        @Override
        public void onBridgeConnected(PHBridge bridge, String username) {           
            phHueSDK.stopPushlinkAuthentication();

            System.out.println("Connected to the bridge!");

            phHueSDK.setSelectedBridge(bridge);
            phHueSDK.enableHeartbeat(bridge, PHHueSDK.HB_INTERVAL);
            String lastIpAddress =  bridge.getResourceCache().getBridgeConfiguration().getIpAddress();   
            HueProperties.storeUsername(username);
            HueProperties.storeLastIPAddress(lastIpAddress);
            HueProperties.saveProperties();

            randomLights();

            phHueSDK.disableAllHeartbeat();
            phHueSDK.destroySDK();
        }

        ...

As you can see in the "onBridgeConnected()", I want to run the "randomLights()" method as soon as I am connected to the bridge and then immediately close the SDK and exit the program. I found that if the properties are saved in a separate file, this works completely fine. However, if I run this for the very first time where I have to to push the link button for authentication, the program dangles and does not exit. Any suggestions on how to fix this issue? I know I can use System.exit() but feel that this is the unclean version of how to fix the issue.

Thank you,
Zack

Hue Lux

Does there need to be any changes to the library to support Philips Hue Lux?

Open source API

While the example applications are open source, I cannot recompile the libraries in lib/. Is there any plan open sourcing these API's?

phBridge.getScene() not available in sdk 1.2.0

The new sdk version 1.2.0 does not have the getScene() method, to get a scene with it's lightstates. The method is completely gone in the PHBridge class. The PHGroupClass is also gone from the SDK. What happened? Did these get relocated?

SDK or source for the ambilight to hue color transition algorithm

I'm trying to create a desktop and server version of the ambilight+hue mobile application and stuck with the colors conversion as this part is not available via SDK or the source code. Also, algorithm seems to be pretty complex.

It would be nice if it becomes a part of the SDK or if the source becomes open.

Please check my forum post for more details.

PHUtilities.calculateXYFromRGB doesn't support Gamut C (Hue Go)

I had a look at the source and it appears there isn't a colorPoints definition for Gamut C devices. This means it will end up with the default colorPoints definition, which is less than ideal. Is Gamut C slated for a future update? If so, when would you expect to publish that?

Thanks!

Handling multiple bridges

It looks like the SDK has not been designed to handle more than one bridge by the same application.
Am I doing something wrong or this is actually the case?
If that is, are you planning to add support for multiple bridges?
Thanks

Are these libraries 64-bit compatible?

Hi! I'm still using portions of these libraries in my app:

huelocalsdk.jar
huesdkresources.jar

Are they 64-bit compatible per the new Google Play requirements?

Thanks!

Updating LightState with 'on' value fails unintuitively

In the application I'm working on, I send state updates in 'full frames'. That is, I set the 'on', 'transitiontime', 'hue', 'saturation', and 'brightness' in one call. I've found that when I try to do this for a light which is off, I need to initially send an 'on' update with transtiontime of 0 in order to then get the other updates to work well. I do that using something like the following:

final PHLightState state = light.getLastKnownLightState();
final Runnable afterOnRunnable = new Runnable() {
    public void run() {
        state.setHue(hue);
        state.setSaturation(saturation);
        state.setBrightness(brightness);
        state.setTransitionTime(transitionTime);
        bridge.updateLightState( light, state );
    }
}

if ( state.isOn() ) {
    afterOnRunnable.run();
    return;
}

state.setTransitionTime( 0 );
state.setOn( true );
bridge.updateLightState( light, state, new PHLightListener() {
    public void onSuccess() {
        afterOnRunnable.run();
    }
    ...
});

I've found that if the light is already on then this fails in the runnable's call to updateLightState, presumably because I'm trying to 're-set' the on value. When I log out the 'onError' callback information it says:

code: 6
message: parameter, reachable, not available

If I change the code to use a new PHLightState within the runnable, and take care not to set an on value, then it runs fine. This seems to go against the note in the documentation that you can update the light state by 1) retrieving the last known light state 2) updating the value you want to change and 3) sending the update to the bridge.

Am I wrong in my understanding of how to go about updating these values, or is this something that could be addressed?

PHHueSDK leaves an open thread

I don't know if this is a wanted effect, but even when destroying the PHHueSDK, there remains an open thread. Consider the following Java program

import com.philips.lighting.hue.sdk.PHHueSDK;

public class Test {
    public static void main(String[] args) {
        // Create SDK
        PHHueSDK phHueSDK = PHHueSDK.create();

        // Main code
        System.out.println("Do main task");

        // Exit program
        phHueSDK.disableAllHeartbeat();
        phHueSDK.destroySDK();
    }
}

It won't exit unless you add a System.exit(0) at the end because there will be a thread [Timer-0] even after you "Clean up resources held by the SDK" through destroySDK().

Get groups does not exists in sdk

Here are few calls are missing in SDK.

Get all groups from the bridge
Get a group from the bridge
List lights from the group

Thank you.

Schedule can not work ,but the callback was success

public static void addGroupTimer(Bridge bridge, LightState lightState, String scheduleName,
                                 String scheduleDesc, TimerScheduleBean timerScheduleBean,
                                 LightPoint lightPoint, final IStateCallBack iStateCallBack) {
    Schedule schedule = new Schedule();
    schedule.setAutoDelete(true);
    schedule.setName(scheduleName);
    schedule.setDescription(scheduleDesc);
    schedule.setStatus(ScheduleStatus.ENABLED);

    ClipActionBuilder clipActionBuilder = new ClipActionBuilder();

// clipActionBuilder.setGroupLightState(groupId, lightState);
clipActionBuilder.updateDeviceState(lightPoint,lightState);
schedule.setClipAction(clipActionBuilder.buildSingle(bridge.getBridgeConfiguration().getVersion()));
// Triggers 1-1-2035 @ 10:05 A.M.
TimePatternBuilder timePatternBuilder = new TimePatternBuilder();
// day month year hour min sec
timePatternBuilder.startAtDate(timerScheduleBean.day, timerScheduleBean.month, timerScheduleBean.year,
timerScheduleBean.hour, timerScheduleBean.minute, timerScheduleBean.second);
schedule.setLocalTime(timePatternBuilder.build());
bridge.updateResource(schedule, BridgeConnectionType.LOCAL, new MyBridgeResponseCallback(iStateCallBack));

}

Another concurrent modification error

Looking at the code, it probably needs a semaphore, though I can't see everything.

I can't fix this in my code (except perhaps by not searching or retrying). This happens when I retry a bridge search after there is no response (at all) from the SDK. Seems like perhaps when the response finally arrives there's two handlers and they step on each other? Since it's down in the guts in a separate thread I don't have any way to catch this and ignore - it crashes my app.

java.util.ConcurrentModificationException
java.util.ArrayList$Itr.next(ArrayList.java:831)
com.philips.lighting.hue.sdk.notification.impl.PHNotificationManagerImpl$1.onReceived(PHNotificationManagerImpl.java:138)
com.philips.lighting.hue.sdk.notification.impl.PHHueResultReceiver.execute(PHHueResultReceiverjava:24)
com.philips.lighting.hue.sdk.notification.impl.PHNotificationManagerImpl.notifySDKError(PHNotificationManagerImpl.java:146)
com.philips.lighting.hue.sdk.connection.impl.PHBridgeInternal$1.run(PHBridgeInternal.java:132)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.