Jump to content


Photo

Plugin for controlling Hue light

hue hue lights phillips hue home automation ha

  • Please log in to reply
150 replies to this topic

#1 nxenos83 OFFLINE  

nxenos83

    Advanced Member

  • Members
  • 86 posts
  • Local time: 05:37 PM

Posted 11 February 2017 - 10:53 AM

SEE https://emby.media/c...ht/#entry494774 for latest update

 

 

 

 

I have a plugin to control Hue lights. There's a bit of manual setup that is required on the Hue bridge, but if there is an audience that would be interested I can add bridge discovery and light configuration to the plugin config page.

 

You will need to get a User Id, Group Id and Scene Id from the Hue bridge to complete configuration:

 

A. Get Bridge User API: (source: https://developers.m...getting-started )

Step 1

First make sure your bridge is connected to your network and is functioning properly. Test that the smartphone app can control the lights on the same network.

Step 2

Then you need to discover the IP address of the bridge on your network. You can do this in a few ways.

  1. Use a UPnP discovery app to find Philips hue in your network.
  2. Use our broker server discover process by visiting www.meethue.com/api/nupnp
  3. Log into your wireless router and look Philips hue up in the DHCP table.
  4. Hue App method: Download the official Philips hue app. Connect your phone to the network the hue bridge is on. Start the hue app(iOS described here). Push link connect to the bridge. Use the app to find the bridge and try controlling lights. All working -- Go to the settings menu in the app. Go to My Bridge. Go to Network settings. Switch off the DHCP toggle. The ip address of the bridge will show. Note the ip address, then switch DHCP back on

N.B When you are ready to make a production app you will need to discover the bridge automatically using the Hue Bridge Discovery Guide or the tools provided with the official Philips hue SDKs

Step 3

Once you have the address load the test app by visiting the following address in your web browser.

http://<bridge ip address>/debug/clip.html

You should see an interface like this.

CLIP%20API%20Debugger_0.png

Using this debugger utility you can populate the components of an HTTP call – the basis of all web traffic and of the hue RESTful interface.

  1. URL: this is actually the local address of a specific resource (thing) inside the hue system. It could be light, a group of lights or many more things. This is the object you’ll be interacting with in this command.
  2. A body: this is the part of the message which describes what you want to change and how. Here you enter, in JSON format, the resource name and value you’d like to change/add.
  3. A method: here you have a choice of the 4 HTTP methods the hue call can use.
    • GET: this is the command to fetch all information about the addressed resource
    • PUT: this is the command to modify an addressed resource
    • POST: this is the command to create a new resource inside the addressed resource
    • DELETE: this is the command to deleted the addressed resource
  4. Response: In this area you’ll see the response to your command. Also in JSON format.

So let’s get started…

First let’s do a very simple command and get information about your hue system.

Fill in the details below leaving the body box empty and press the GET button.

Address http://<bridge ip address>/api/newdeveloper Body   Method GET

You should see a response like below:

Get%20info%20on%20your%20system.png

Congratulations you’ve just sent you first CLIP command!

Now this is the command to fetch all information in the bridge. You didn’t get much back and that’s because you’re using an unauthorized username “newdeveloper”.

Currently it is possible to create your own usernames in the bridge (e.g. “newdeveloper”), however, this option will be removed in future bridge versions,  so we need to use the randomly generated username that the bridge creates for you.  Fill in the info below and press the POST button.

Address http://<bridge ip address>/api Body {"devicetype":"my_hue_app#iphone peter"} Method POST

This command is basically saying please create a new resource inside /api (where usernames sit) with the following properties.

When you press the POST button you should get back an error message letting you know that you have to press the link button. This is our security step so that only apps you want to control your lights can. By pressing the button we prove that the user has physical access to the bridge.

AccessToTheBridge.png

Go and press the button on the bridge and then press the POST button again and you should get a success response like below.

SuccessResponse.png

Congratulations you’ve just created an authorized user (1028d66426293e821ecfd9ef1a0731df), which we’ll use from now on! Now if you do the first GET command again you should get a whole lot more information about what lights you have and their states. This data is all in JSON format so can be easily processed by your applications.

 

B. Create Light Group

 

Use the same CLIP application and send a GET request to 

http://<bridge ip address>/api/<username from step A>/lights

to find the id numbers for the lights you want to control.

 

Create the group by sending a POST request to

http://<bridge ip address>/api/<username from step A>/groups

With Message Body:

{
	"lights": [
		"1",
		"2"
	],
	"name": "Theater",
        "type": "LightGroup"
}

where "lights" contains the light ids you want to control.

 

The ID returned in the response body is the group ID to use.

 

C. Create Scene ID

Create the scene ID by sending a POST request to

http://<bridge ip address>/api/<username>/scenes/

With a Message Body

{"name":"EmbyCache", "lights":["1","2"], "recycle":true}

with the same light ids used in b.

Note the id in the response and use this as the scene id in the plugin configuration page.



					

Attached Files


Edited by nxenos83, 04 October 2017 - 09:27 AM.

  • julianb, Liquidfire88 and Jizmac like this

#2 chef OFFLINE  

chef

    Advanced Member

  • Developers
  • 3794 posts
  • Local time: 06:37 PM
  • LocationPeterborough, Canada

Posted 11 February 2017 - 12:12 PM

Top shelf! Great work!

#3 Luke OFFLINE  

Luke

    System Architect

  • Administrators
  • 129400 posts
  • Local time: 06:37 PM

Posted 11 February 2017 - 02:31 PM

Very cool, thanks !

#4 Overseer OFFLINE  

Overseer

    Advanced Member

  • Members
  • 245 posts
  • Local time: 03:37 PM
  • LocationYelm, WA, US

Posted 11 February 2017 - 08:18 PM

Sweet.  Slowly updating my LED lights to Hue since I picked up the Echo, especially my RGB floods.



#5 julianb OFFLINE  

julianb

    Advanced Member

  • Members
  • 125 posts
  • Local time: 12:37 AM
  • LocationNorway

Posted 13 February 2017 - 12:13 PM

Looks great! But is the group an important step if you already have a group? 

 

My group "Home Cinema" has ID "19" but the scene ID is an longer string, I can't get it to work, I must do something wrong. 

 

- The userID is OK

- Does the bridge URL have to be just IP or http://xxx.xxx.x.x/

- LightGroup IS is normally just numbers, but maybe I do something wrong here? 

- Scene ID is an longer string than the LightGroup ID? 

 

I created a scene, {"name":"EmbyCache", "lights":["1","2"], "recycle":true} (with my lights). But I can't get the group thing to work:

[
	{
		"error": {
			"type": 6,
			"address": "/lights/lights",
			"description": "parameter, lights, not available"
		}
	},

Thanks!



#6 nxenos83 OFFLINE  

nxenos83

    Advanced Member

  • Members
  • 86 posts
  • Local time: 05:37 PM

Posted 13 February 2017 - 05:17 PM

Looks great! But is the group an important step if you already have a group?

 

The group is not an important step, if you already have one. Just take note of the ID

 


- Does the bridge URL have to be just IP or http://xxx.xxx.x.x/

I'll need to double check if the plugin handles a '/' after the URL.  I checked my config and I have it as http://xxx.xxx.x.xxx

 


- LightGroup IS is normally just numbers, but maybe I do something wrong here?

Correct, light group should be an integer

 

 


 

I created a scene, {"name":"EmbyCache", "lights":["1","2"], "recycle":true} (with my lights). But I can't get the group thing to work:

[
	{
		"error": {
			"type": 6,
			"address": "/lights/lights",
			"description": "parameter, lights, not available"
		}
	},

Thanks!

I had the URL incorrect on the first post. I have updated. To create the group, the POST should be sent to http://<bridge ip address>/api/<username from step A>/groups.

 

 

 

It sounds like you have a group id and a scene id. Try changing the format of the bridge URL.  Also make sure that you have selected the Emby client that you want the lights to respond to. Make sure Enable for this device is checked, and check Movies, Episodes, or both.

 

If you are still having issues, send me your log file and configuration file and I can take a look this evening.


Edited by nxenos83, 13 February 2017 - 05:18 PM.


#7 julianb OFFLINE  

julianb

    Advanced Member

  • Members
  • 125 posts
  • Local time: 12:37 AM
  • LocationNorway

Posted 15 February 2017 - 02:34 AM

The group is not an important step, if you already have one. Just take note of the ID

 

I'll need to double check if the plugin handles a '/' after the URL.  I checked my config and I have it as http://xxx.xxx.x.xxx

 

Correct, light group should be an integer

 

 

I had the URL incorrect on the first post. I have updated. To create the group, the POST should be sent to http://<bridge ip address>/api/<username from step A>/groups.

 

 

 

It sounds like you have a group id and a scene id. Try changing the format of the bridge URL.  Also make sure that you have selected the Emby client that you want the lights to respond to. Make sure Enable for this device is checked, and check Movies, Episodes, or both.

 

If you are still having issues, send me your log file and configuration file and I can take a look this evening.

 

Thank you, works now! :) This is one great plug-in man! Thanks again


  • nxenos83 likes this

#8 nxenos83 OFFLINE  

nxenos83

    Advanced Member

  • Members
  • 86 posts
  • Local time: 05:37 PM

Posted 15 February 2017 - 01:14 PM

Good to hear.



#9 hstamas OFFLINE  

hstamas

    Advanced Member

  • Members
  • 565 posts
  • Local time: 06:37 PM

Posted 08 March 2017 - 04:59 PM

I'd be very interested in this becoming a more automated process with bridge discovery and configuration built in. The more customizable the better!



#10 julianb OFFLINE  

julianb

    Advanced Member

  • Members
  • 125 posts
  • Local time: 12:37 AM
  • LocationNorway

Posted 29 March 2017 - 12:28 PM

This plug-in is the best! Would be nice to see it in the plug-in catalog later on, with autodiscovery of brigde and so on :)



#11 Liquidfire88 OFFLINE  

Liquidfire88

    Member

  • Members
  • 17 posts
  • Local time: 05:37 PM

Posted 26 June 2017 - 04:10 PM

gonna test this when i get home tonight.  looks awesome.  would also love to see in the catalog with autodiscovery as well.  but the setup process should keep me entertained for tonight.  lol.   :)

 

 

EDIT:

i got through most of it, and had an error while trying to create the SceneID.

 

URL
http:// IPADDRESS / api / THE_API_I_CREATED / scenes /                    *i added the spaces so it wouldnt auto-URL

 

 

 

MESSAGE BODY

{
"name":"EmbyCache","lights":["1","2","3","4","10"],"recycle":true}
}
 
 
 
 
COMMAND RESPONSE
[
{
"error": {
"type": 2,
"address": "/scenes/",
"description": "body contains invalid json"
}
}
]
 
 
im sure i did something wrong; just not sure what. lol.  any help?
 
 
 
 
------------------------------------------------------------------------------------------------------------------
on a side note, i did [[/api/API ID/scenes/]] without the "[[" "]]" and did the GET function
------------------------------------------------------------------------------------------------------------------
{
"6Oa9Vygdr6qWL1w": {
"name": "Dimmed",
"lights": [
"1",
"2",
"3"
],
"owner": "A DIFFERENT API ID",
"recycle": false,
"locked": false,
"appdata": {
"version": 1,
"data": "asjxy_r02_d06"
},
"picture": "",
"lastupdated": "2017-02-04T21:04:13",
"version": 2
},
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
this looks like a scene that was created with the Official Hue app.  it looks like it has much more data then when i tried to create POST create a scene.  so idk if this is part of an update.  i have updated my hub at least once maybe a few times
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Edited by Liquidfire88, 27 June 2017 - 01:42 AM.


#12 julianb OFFLINE  

julianb

    Advanced Member

  • Members
  • 125 posts
  • Local time: 12:37 AM
  • LocationNorway

Posted 30 July 2017 - 03:00 PM

I can't get this to work anymore after a few updates. I tried adding a new user but still not working. Was working fine before

Sent from my SM-G935F using Tapatalk

#13 Luke OFFLINE  

Luke

    System Architect

  • Administrators
  • 129400 posts
  • Local time: 06:37 PM

Posted 30 July 2017 - 03:01 PM

I can't get this to work anymore after a few updates. I tried adding a new user but still not working. Was working fine before

Sent from my SM-G935F using Tapatalk

 

Can you please provide more detail about the issue that you're having? That might help the developer help you resolve it. Thanks.



#14 julianb OFFLINE  

julianb

    Advanced Member

  • Members
  • 125 posts
  • Local time: 12:37 AM
  • LocationNorway

Posted 31 July 2017 - 12:14 PM

I don't know when it stopped working, but it was a few months ago. I thought maybe it was after a brigde update, but after creating a new user, group and scene it doesn't look like it.

Would be nice to know if it still work for some other of those who use it.



Sent from my SM-G935F using Tapatalk

#15 julianb OFFLINE  

julianb

    Advanced Member

  • Members
  • 125 posts
  • Local time: 12:37 AM
  • LocationNorway

Posted 05 August 2017 - 07:54 AM

 

I have a plugin to control Hue lights. There's a bit of manual setup that is required on the Hue bridge, but if there is an audience that would be interested I can add bridge discovery and light configuration to the plugin config page...........

 

 

Does this plugin still work? It was one great plugin, but some months ago, I couldn't get it to work anymore. I have tried everything, even tested to controll them over Eventghost, just to make sure that the username, groups and scenes was working. I have tried to reinstall it without any luck.
 
This was one of the best plugins for emby, it really completed my Home Cinema


#16 hstamas OFFLINE  

hstamas

    Advanced Member

  • Members
  • 565 posts
  • Local time: 06:37 PM

Posted 05 August 2017 - 11:18 AM

I’m really surprised that there is not more demand for a working plugin like this? I would think a good portion of the people using a media server like Emby are HTPC enthusiasts and have the desire to control lighting in an easy to implement way.

Even the alternatives are lacking. Kodi only has 2 addons that I know of that “sort of”work. Plex only has one but luckily its feature complete and works well.

If I had the skills, I would make one myself but sadly that isnt going to happen.

#17 Luke OFFLINE  

Luke

    System Architect

  • Administrators
  • 129400 posts
  • Local time: 06:37 PM

Posted 05 August 2017 - 12:33 PM

I think it is a great idea.



#18 hstamas OFFLINE  

hstamas

    Advanced Member

  • Members
  • 565 posts
  • Local time: 06:37 PM

Posted 05 August 2017 - 06:29 PM

I think it is a great idea.


Reiterating a previous post to anyone out there who could create a proper server side plugin that controls Hue Lights, I would be more than happy to contribute financiallly to get this made!

#19 Luke OFFLINE  

Luke

    System Architect

  • Administrators
  • 129400 posts
  • Local time: 06:37 PM

Posted 05 August 2017 - 08:17 PM

It doesn't even have to be a plugin. It can also be it's own standalone app that uses the emby api.

#20 julianb OFFLINE  

julianb

    Advanced Member

  • Members
  • 125 posts
  • Local time: 12:37 AM
  • LocationNorway

Posted 27 August 2017 - 06:01 AM

It doesn't even have to be a plugin. It can also be it's own standalone app that uses the emby api.

Do we know anyone that could do this? I would if i've had enough knowledge about coding and scripting, but unfortunately i'm just a noob with some basic knowledgde.
 
Looks like the maker of this plug-in @nxenos83 has left it for dead :(






Also tagged with one or more of these keywords: hue, hue lights, phillips hue, home automation, ha

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users