Jump to content
nxenos83

Plugin for controlling Hue light

Recommended Posts

nxenos83

SEE https://emby.media/community/index.php?/topic/44781-plugin-for-controlling-hue-light/&do=findComment&comment=494774 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.meethue.com/documentation/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.


HueControl.zip

Edited by nxenos83
  • Like 3

Share this post


Link to post
Share on other sites
chef

Top shelf! Great work!

Share this post


Link to post
Share on other sites
Luke

Very cool, thanks !

Share this post


Link to post
Share on other sites
Overseer

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

Share this post


Link to post
Share on other sites
julianb

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!

Share this post


Link to post
Share on other sites
nxenos83

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

Share this post


Link to post
Share on other sites
julianb

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

  • Like 1

Share this post


Link to post
Share on other sites
hstamas

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

Share this post


Link to post
Share on other sites
julianb

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 :)

Share this post


Link to post
Share on other sites
Liquidfire88

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

Share this post


Link to post
Share on other sites
julianb

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

Share this post


Link to post
Share on other sites
Luke

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.

Share this post


Link to post
Share on other sites
julianb

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

Share this post


Link to post
Share on other sites
julianb

 

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

Share this post


Link to post
Share on other sites
hstamas

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.

Share this post


Link to post
Share on other sites
Luke

I think it is a great idea.

Share this post


Link to post
Share on other sites
hstamas

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!

Share this post


Link to post
Share on other sites
Luke

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

Share this post


Link to post
Share on other sites
julianb

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 :(

Share this post


Link to post
Share on other sites
nxenos83

@@julianb can you send a copy of your config file (located at %appdata%\plugins\configuration) and a copy of the log file from tour server with debug logging turned on.

Share this post


Link to post
Share on other sites
nxenos83

 

 
Looks like the maker of this plug-in @@nxenos83 has left it for dead :(

 

 

Unfortunately, I've been pulled away from the Emby community with some other projects, and just recently saw the post in this thread. I've reflected a little on this and how Emby should be integrated with smart home devices. I'm willing to devote some time to looking into issue with the plugin and making setup easier if anyone convince my I'm wrong. 

 

Instead of maintaining a plugin that targets one smart home lighting product and performs one action, it makes sense to focus on a method that is highly extensible, easier to maintain, and leverages other projects dedicated to home automation. The webhooks plugin I started on seems to me to be a better route. Using this in conjunctions with a dedicated smart home sever [like home-assistant io (HA)], you can use Emby events to instantaneously trigger an actions that target a miriad of smart home products.  Projects like HA and openHab are dedicated to proving integration with smart home products and are better situated to provide long term maintenance to keep up with changes in smart product APIs. 

 

As an example, with the webhooks, I could potentially dim smart lights (hue lights and zwave switches controlled by a Wink hub), set my Yahama network receiver to the appropriate input and volume, and send a python script command to a network projector to set appropriate aspect ration. All of this by sending a http request to HA triggered by Emby events. The heavy lifting is done by HA and Emby gets to focus on serving up media.

 

I can write up a quick tutorial on how to setup HA and how to integrate with Emby Webhooks if anyone would be interested.

 

 

 

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

 

Just as a side note, using emby api is already available by default in HA. The only down side is that HA has to pool emby every few minutes. Using webhooks allows much faster response.

Share this post


Link to post
Share on other sites
hstamas

Unfortunately, I've been pulled away from the Emby community with some other projects, and just recently saw the post in this thread. I've reflected a little on this and how Emby should be integrated with smart home devices. I'm willing to devote some time to looking into issue with the plugin and making setup easier if anyone convince my I'm wrong. 

 

Instead of maintaining a plugin that targets one smart home lighting product and performs one action, it makes sense to focus on a method that is highly extensible, easier to maintain, and leverages other projects dedicated to home automation. The webhooks plugin I started on seems to me to be a better route. Using this in conjunctions with a dedicated smart home sever [like home-assistant io (HA)], you can use Emby events to instantaneously trigger an actions that target a miriad of smart home products.  Projects like HA and openHab are dedicated to proving integration with smart home products and are better situated to provide long term maintenance to keep up with changes in smart product APIs. 

 

As an example, with the webhooks, I could potentially dim smart lights (hue lights and zwave switches controlled by a Wink hub), set my Yahama network receiver to the appropriate input and volume, and send a python script command to a network projector to set appropriate aspect ration. All of this by sending a http request to HA triggered by Emby events. The heavy lifting is done by HA and Emby gets to focus on serving up media.

 

I can write up a quick tutorial on how to setup HA and how to integrate with Emby Webhooks if anyone would be interested.

 

 

 

 

Just as a side note, using emby api is already available by default in HA. The only down side is that HA has to pool emby every few minutes. Using webhooks allows much faster response.

 

As long as the setup is user friendly/accessible I am all for it. I have above average computer skills and dont mind tinkering but I have just reached the point in my life where I dont relish sitting at a computer til 3am trying to get automation software working. Sort of the whole reason I paid the premium and purchases Hue lights instead of less expensive alternatives that require a lot of set up.

Share this post


Link to post
Share on other sites
julianb

Unfortunately, I've been pulled away from the Emby community with some other projects, and just recently saw the post in this thread. I've reflected a little on this and how Emby should be integrated with smart home devices. I'm willing to devote some time to looking into issue with the plugin and making setup easier if anyone convince my I'm wrong. 

 

Instead of maintaining a plugin that targets one smart home lighting product and performs one action, it makes sense to focus on a method that is highly extensible, easier to maintain, and leverages other projects dedicated to home automation. The webhooks plugin I started on seems to me to be a better route. Using this in conjunctions with a dedicated smart home sever [like home-assistant io (HA)], you can use Emby events to instantaneously trigger an actions that target a miriad of smart home products.  Projects like HA and openHab are dedicated to proving integration with smart home products and are better situated to provide long term maintenance to keep up with changes in smart product APIs. 

 

As an example, with the webhooks, I could potentially dim smart lights (hue lights and zwave switches controlled by a Wink hub), set my Yahama network receiver to the appropriate input and volume, and send a python script command to a network projector to set appropriate aspect ration. All of this by sending a http request to HA triggered by Emby events. The heavy lifting is done by HA and Emby gets to focus on serving up media.

 

I can write up a quick tutorial on how to setup HA and how to integrate with Emby Webhooks if anyone would be interested.

 

 

 

 

Just as a side note, using emby api is already available by default in HA. The only down side is that HA has to pool emby every few minutes. Using webhooks allows much faster response.

 

I would love a good solution, cause right now I can't even get my lights to dim automatically anymore :(

Share this post


Link to post
Share on other sites
julianb

@@julianb can you send a copy of your config file (located at %appdata%\plugins\configuration) and a copy of the log file from tour server with debug logging turned on.

removed xml file
Edited by julianb

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...