ZeroOne3010 / yetanotherhueapi

A Java library for controlling Philips Hue lights. Available from the Maven Central.
MIT License
68 stars 21 forks source link

Implement a findByUiniqueId for lights and sensors #49

Closed koenraadvds closed 1 year ago

koenraadvds commented 2 years ago

I would like to contribute a patch that allows the use of the uniqueId to search for lights and presence sensor. However, the new github authentication don't allow me to push the changes. Is there any group or email where i can post the patch?

ZeroOne3010 commented 2 years ago

Hey, cool! Patches would definitely be welcome. :) Am I guessing right that this is about the new API v2, as the library does not have any support for it yet? I pondered about the implications of changing into API v2 in issue #48, it's not entirely straight forward, but I could probably accept your patch into some branch at least.

I do recommend that you would still try pushing your changes and creating a pull request the normal way. You cannot use your password with the command line anymore, you just need a personal access token as described here: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/about-authentication-to-github#authenticating-with-the-command-line -- and obviously you cannot push directly into my repository, you need to fork this project to your account first, push the changes there, and then create a pull request from there.

Everything else failing I suppose you could copy & paste your patch to this issue and I could see what I could do with it.

koenraadvds commented 2 years ago

Hi,

Well, no, not API v2. It’s a patch to your “yetanotherhueapi” V3.2 i’m currently using. The problem is that when i refer to a light or sensor by name, that name could change and than breaks the reference. I saw that there is also a uniqueId available. S i extended the lib to use the uniqueId to find lights and sensors.

Attached is the patch.

Regards,

Koenraad

On 2 Feb 2022, at 12:51, Ville Saalo @.***> wrote:

Hey, cool! Patches would definitely be welcome. :) Am I guessing right that this is about the new API v2, as the library does not have any support for it yet? I pondered about the implications of changing into API v2 in issue #48 https://github.com/ZeroOne3010/yetanotherhueapi/issues/48, it's not entirely straight forward, but I could probably accept your patch into some branch at least.

I do recommend that you would still try pushing your changes and creating a pull request the normal way. You cannot use your password with the command line anymore, you just need a personal access token as described here: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/about-authentication-to-github#authenticating-with-the-command-line https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/about-authentication-to-github#authenticating-with-the-command-line -- and obviously you cannot push directly into my repository, you need to fork this project to your account first, push the changes there, and then create a pull request from there.

Everything else failing I suppose you could copy & paste your patch to this issue and I could see what I could do with it.

— Reply to this email directly, view it on GitHub https://github.com/ZeroOne3010/yetanotherhueapi/issues/49#issuecomment-1027861679, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAY3FGH2O3OSVYCEW6EBLWLUZELEHANCNFSM5NLXE7FA. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you authored the thread.

ZeroOne3010 commented 2 years ago

Oh, I see now! When you wrote about "unique id" that immediately got me thinking about the new API version that the Bridge exposes, the API v2, that this library does not support yet. See, in that new API the ids that the various entities have are universally unique, also known as UUIDs, such as "4cf84bbc-312e-4be9-bf6c-601edc6aab46". But yes, you are referring to the ids that the good old API v1 is using, such as "1", "2", etc.

I believe that you must be using version 2.3.0 of the library then, not 3.2. Now, you're in luck, because in version 2.4.0 the ids for both lights and rooms are indeed exposed! :) This was implemented in the context of issue #45. Sensors ids aren't exposed yet, but that can definitely be added. :+1: (Also notice that the most current version is in fact 2.5.0.)

koenraadvds commented 2 years ago

Hi,

Actually, i am not referring to the “id” but to the “uniqueId" in the API v1 json (e.g. "uniqueid": "00:17:88:01:03:b5:34:24-0b”) But on the other hand, in API v2, the uniqueId is replaced by uuid as you already mentioned. And further reading about API v2 also reveals than the “id” might also retire. It will be in for some time to allow libraries to migrate between v1 and v2 smoothly. Finally, the uuid in v2 will be the preferred method to identify the devices.

Interesting however in the api v2 is the SSE implementation to avoid polling devices. I try to test this functionality using a SSE client from jax-rs but without success for the moment :(

Kind regards,

Koenraad Vanderschaeve

On 3 Feb 2022, at 11:22, Ville Saalo @.***> wrote:

Oh, I see now! When you wrote about "unique id" that immediately got me thinking about the new API version that the Bridge exposes, the API v2, that this library does not support yet. See, in that new API the ids that the various entities have are universally unique, also known as UUIDs, such as "4cf84bbc-312e-4be9-bf6c-601edc6aab46". But yes, you are referring to the ids that the good old API v1 is using, such as "1", "2", etc.

I believe that you must be using version 2.3.0 of the library then, not 3.2. Now, you're in luck, because in version 2.4.0 the ids for both lights and rooms are indeed exposed! :) This was implemented in the context of issue #45 https://github.com/ZeroOne3010/yetanotherhueapi/issues/45. Sensors ids aren't exposed yet, but that can definitely be added. 👍

— Reply to this email directly, view it on GitHub https://github.com/ZeroOne3010/yetanotherhueapi/issues/49#issuecomment-1028836399, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAY3FGFCH65AFC3WB6HHXILUZJJQBANCNFSM5NLXE7FA. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you authored the thread.

ZeroOne3010 commented 2 years ago

Hello! Yes, sorry, I finally understand what you mean: there is indeed a uniqueId attribute for the lights in API v1! Apparently there always has been, but I've never really paid any attention to it. :o I am inclined to think that it would actually be a disservice for anyone using this library to introduce it now, with API v2 practically just around the corner... There wouldn't really be much time to enjoy it for I do want to convert the library into using API v2 sooner or later.

koenraadvds commented 2 years ago

Hi,

I understand that it is more interesting to convert the library to v2. By this time i tested the SSE implementation in the v2 API. It works very well and will be a big advantage over polling for the state of devices.

Kind regards,

Koenraad

On 4 Feb 2022, at 20:14, Ville Saalo @.***> wrote:

Hello! Yes, sorry, I finally understand what you mean: there is indeed a uniqueId attribute for the lights in API v1! Apparently there always has been, but I've never really paid any attention to it. :o I am inclined to think that it would actually be a disservice for anyone using this library to introduce it now, with API v2 practically just around the corner... There wouldn't really be much time to enjoy it for I do want to convert the library into using API v2 sooner or later.

— Reply to this email directly, view it on GitHub https://github.com/ZeroOne3010/yetanotherhueapi/issues/49#issuecomment-1030276210, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAY3FGDBPPTHSY5EQHJWCETUZQQSHANCNFSM5NLXE7FA. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you authored the thread.

koenraadvds commented 2 years ago

Hi,

Did you had the chance to validate the simple patch i’ve send you last week to exposure the uniqueId of sensor and lights to add to your lib? I attached another simple patch in this mail that expose the id of a scene. A scene can only be found by name now. If the name changes, the scene cannot be found anymore. Therefor the id should be better. Anyhow, i have build my own version of your lib with those changes in order to use them in my project.

Kind regards,

Koenraad

On 4 Feb 2022, at 21:17, Koenraad Vanderschaeve @.***> wrote:

Hi,

I understand that it is more interesting to convert the library to v2. By this time i tested the SSE implementation in the v2 API. It works very well and will be a big advantage over polling for the state of devices.

Kind regards,

Koenraad

On 4 Feb 2022, at 20:14, Ville Saalo @. @.>> wrote:

Hello! Yes, sorry, I finally understand what you mean: there is indeed a uniqueId attribute for the lights in API v1! Apparently there always has been, but I've never really paid any attention to it. :o I am inclined to think that it would actually be a disservice for anyone using this library to introduce it now, with API v2 practically just around the corner... There wouldn't really be much time to enjoy it for I do want to convert the library into using API v2 sooner or later.

— Reply to this email directly, view it on GitHub https://github.com/ZeroOne3010/yetanotherhueapi/issues/49#issuecomment-1030276210, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAY3FGDBPPTHSY5EQHJWCETUZQQSHANCNFSM5NLXE7FA. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you authored the thread.

ZeroOne3010 commented 2 years ago

Hi there! Unfortunately no, I must admit I haven't tried the patches... I think the regular ids should be exposed first, not necessarily the unique ids, for that's what has been done with the lights and rooms. Also, I don't know how many versions of this library I will publish before moving on to API v2, at which point the interfaces will need to be changed anyway. I will keep this issue open so that if I can come up with some other feature(s) besides these id accessors, I will remember to add these too into a new version. And hey, it's good that you managed to build your own version! Power of open source software, huh? :)

ZeroOne3010 commented 2 years ago

@koenraadvds Hi, I've just released a new version of the library, 2.7.0, where you have a new getId() method for Scenes too. Now scenes, rooms, lights and sensors have one. It's still not the unique id you asked for, but it's an id for all of them anyway.

You might also be interested in the api-v2 branch that I've been working on: it is very rudimentary, but you can now use it to toggle lights on and off with the new API. 😅 There, anyway, each resource will have a long UUID.

koenraadvds commented 2 years ago

Hi,

Thx! I’ll check it out!

Regards,

Koenraad

On 19 Apr 2022, at 15:53, Ville Saalo @.***> wrote:

@koenraadvds https://github.com/koenraadvds Hi, I've just released a new version of the library, 2.7.0, where you have a new getId() method for Scenes too. Now scenes, rooms, lights and sensors have one. It's still not the unique id you asked for, but it's an id for all of them anyway.

You might also be interested in the api-v2 branch that I've been working on: it is very rudimentary, but you can now use it to toggle lights on and off with the new API. 😅 There, anyway, each resource will have a long UUID.

— Reply to this email directly, view it on GitHub https://github.com/ZeroOne3010/yetanotherhueapi/issues/49#issuecomment-1102684698, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAY3FGAP4V4CGUJEZCNDRTTVF23EHANCNFSM5NLXE7FA. You are receiving this because you were mentioned.

ZeroOne3010 commented 1 year ago

Version 3.0.0-alpha is now out, and there all the entities are referred to by their UUID. :heart: I'm just going to go ahead and close this issue, but feel free to still comment here to let me know how that works for you! I'm also looking for any and all feedback on the latest version so that I could eventually promote it to 3.0.0, so opening new issues would be much appreciated too. :pray: Cheers!