Kodi Community Forum

Full Version: Philips Hue Service & Ambilight
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
No worries, I'm not a very experienced programmer and I ask plenty of questions others might find stupid Smile But that's how you learn.

The way it works is that the Hue bridge does most of the actual work. For example, my script will tell the bridge: turn on scene #5, and hue takes care of the rest. It's basically the same as clicking a scene button in the app. By using the official scenes, it means my script can be much more compatible with Hue, other apps, or create all kinds of scenes with all your lights without adding extra code. But that 1 line command also means I don't have a lot of granular control. 

The other approach is to use individual commands. That would look like telling the bridge: Turn on light #2, set brightness of light number #2 to 154, set colour to (0.323,0.124) . Turn on light #4, brightness 130, colour (0.323,0.124), etc. All of those commands require their own logic, configuration UI and you're limited to what I've thought of and can reasonably code. It also means a more complicated UI where the user needs to select each bulb, brightness and colour (and understanding those colour codes). It's a lot more work, more likely to break or be buggy, and less flexible in the long run.

The other problem is that Hue has a limit of 10 commands per second. A scene is one command vs 3 commands per light, so it would be limited to 3 or 4 lights before Hue starts having trouble keeping up. With a scene, it's up to bridge to manage that problem. 

If you're curious, Hue's documentation is here: https://developers.meethue.com/develop/application-design-guidance/ 
Thanks, that clears things up a lot - the "hello hue" plugin for Plex must use the individual commands rather than the scenes, I remember having a slightly gruelling setup trying to figure out the brightness I wanted out of 255 rather than 100, and figuring out the colour tone in hex was a bit hit and miss! But once I finally got it how I wanted it's been rock solid and did exactly what I wanted, which is pretty rare these days.

The setup for this Kodi add-on with setting a scene and then applying it was very straightforward and really easy to use.
Hi,

I've released a new version that adds a plug-in component. This will let you manually start one of the scenes you've configured or enable or disable the service temporarily. You should be able to add these shortcuts as favourites to easily access them.  This should be helpful when you want to temporarily turn it off. 

This is a big code change and it's a first version so please include logs with any bug reports.
(2019-10-27, 23:21)Snapcase Wrote: [ -> ]Hi,

I've released a new version that adds a plug-in component. This will let you manually start one of the scenes you've configured or enable or disable the service temporarily. You should be able to add these shortcuts as favourites to easily access them.  This should be helpful when you want to temporarily turn it off. 

This is a big code change and it's a first version so please include logs with any bug reports.

Hi

Since that last update my 3rd party Dresden fls-pp Zigbee Led controller is now always purple with the AmbiLight.

The genuine Hue led strip and a Hue colour bulb still change colours OK.

Also can the new enable / disable feature be run via a Json http command(s) say from a home automation hub.

Thanks.
Also I now have the problem of the settings not being saved. First time for me.

For example if I change the AmbiLight setting Update Interval (ms) from 500 to 600 next time I go back into the settings after starting video playback of something, its back to 500 again.

Seems to do this for all the various settings I might change. They only go back to what they were, after I start video playback.

If I change a setting and select OK to exit out. I can go back in to the addon settings and and my changes have stuck. But as soon as I have played something then going back in to the settings the changes I made are lost.
Hi

That's really strange, I haven't touched anything on how the colours are calculated. I'll need debug logs to look into it.

I haven't looked into the json http commands Kodi supports but it's something I'll look into, it's a good idea. Do you have examples of how those hubs work? I've been wanting to get a Hubitat but it's not in the budget yet.
(2019-11-01, 23:24)Snapcase Wrote: [ -> ]Hi

That's really strange, I haven't touched anything on how the colours are calculated. I'll need debug logs to look into it.

I haven't looked into the json http commands Kodi supports but it's something I'll look into, it's a good idea. Do you have examples of how those hubs work? I've been wanting to get a Hubitat but it's not in the budget yet.

OK I will see if I can get you a debug log file tomorrow. I'll PM you.

I have a Vera Z-Wave hub. I hear Hubitat is good like Smartthings but better.

I currently use some json http commands to disable or enable the entire Hue Service Kodi addon from Vera run a curl command. Thus turning off or on the AmbiLight functions.

I can give you some example commands tomorrow also.

In fact thinking about it I have some examples on this thread.

https://community.getvera.com/t/kodi-v18.../200589/14
Actually I think I may have just fixed it.

I power cycled the Dresden led controller and now its working with the AmbiLight again. I will monitor it.

Thanks.
Glad it was such an easy fix for that controller!

There's a JSON RPC command "NotifyAll" which allows you to send any message to an add-on. Using that I think all of the commands I added in the plugin could be triggered, including the manual scene triggers. In theory it would also allow another add-on or skin to send commands since JSON RPC is available to them as well. I need to add support for it but it shouldn't be too hard to hook it up to the plugin commands. I should be able to add it in the near future.
(2019-11-02, 14:22)Snapcase Wrote: [ -> ]Glad it was such an easy fix for that controller!

There's a JSON RPC command "NotifyAll" which allows you to send any message to an add-on. Using that I think all of the commands I added in the plugin could be triggered, including the manual scene triggers. In theory it would also allow another add-on or skin to send commands since JSON RPC is available to them as well. I need to add support for it but it shouldn't be too hard to hook it up to the plugin commands. I should be able to add it in the near future.

Sounds promising. The main one I would use is to disable and enable AmbiLight from the Vera home automation controller.

I can then just ask Google Home or Alexa to "disable AmbiLight" or "enable AmbiLight" to run a scene on the Vera hub to then send the correct curl (json) command to the Kodi HTPC and your addon etc.
@cw-kid I have a dev release with JSON support. I haven't tested this version much yet so I haven't updated the repo, but you can get it here: https://github.com/zim514/script.service....11.0.dev1

Note that the enable & disable commands won't disable the whole add-on like the command you were using. It will do the same as the "temporary" disable in the plugin menu. You should probably avoid using both methods at the same time


There's 3 JSON RPC commands I've added:

Enable
json:
{
    "jsonrpc": "2.0",
    "method": "JSONRPC.NotifyAll",
    "params": {
        "sender": "script.service.hue",
        "message": "enable"
    },
    "id": 1


Disable:
json:

{
    "jsonrpc": "2.0",
    "method": "JSONRPC.NotifyAll",
    "params": {
        "sender": "script.service.hue",
        "message": "disable"
    },
    "id": 1
}


Actions:
play, pause, stop
group 1: video
group 2: audio

json:

{
    "jsonrpc": "2.0",
    "method": "JSONRPC.NotifyAll",
    "params": {
        "sender": "script.service.hue",
        "message": "actions",
        "data": {"command": "stop","group": "1"}
    },
    "id": 1
}
(2019-11-03, 15:56)Snapcase Wrote: [ -> ]@cw-kid I have a dev release with JSON support. I haven't tested this version much yet so I haven't updated the repo, but you can get it here: https://github.com/zim514/script.service....11.0.dev1

Note that the enable & disable commands won't disable the whole add-on like the command you were using. It will do the same as the "temporary" disable in the plugin menu. You should probably avoid using both methods at the same time


There's 3 JSON RPC commands I've added:

Enable
json:
{
    "jsonrpc": "2.0",
    "method": "JSONRPC.NotifyAll",
    "params": {
        "sender": "script.service.hue",
        "message": "enable"
    },
    "id": 1
Disable:
json:

{
    "jsonrpc": "2.0",
    "method": "JSONRPC.NotifyAll",
    "params": {
        "sender": "script.service.hue",
        "message": "disable"
    },
    "id": 1
}
Actions:
play, pause, stop
group 1: video
group 2: audio

json:

{
    "jsonrpc": "2.0",
    "method": "JSONRPC.NotifyAll",
    "params": {
        "sender": "script.service.hue",
        "message": "actions",
        "data": {"command": "stop","group": "1"}
    },
    "id": 1
}
Well it works ! 

Below are the commands I have to send from my Vera Home Automation controller to disable or enable the Ambilight function of the Kodi add-on. 

The Ambilight "Hue Status" is also correctly reflected in the Kodi Hue Service add-on, when you go in to it from the Program Add-ons area of the Kodi GUI.

Google Home speaker doesn't always recognise the word "ambilight" so I have add "disable hue" and "enable hue" in to the Google Home routines as well. I can now say those phrases to Google Home and the Ambilight is disabled or enabled by voice command ! 

The IP address (192.168.1.5) should be the IP address of your own Kodi HTPC etc. Also change the username and password as appropriate.

Disables Ambilight
 
Quote:os.execute('curl -X POST -H "content-type:application/json" http://username:[email protected]:8080/jsonrpc -d \'{"jsonrpc": "2.0", "method": "JSONRPC.NotifyAll", "params": {"sender": "script.service.hue", "message": "disable" }, "id": 1}\'')

Enables Ambilight
Quote:os.execute('curl -X POST -H "content-type:application/json" http://username:[email protected]:8080/jsonrpc -d \'{"jsonrpc": "2.0", "method": "JSONRPC.NotifyAll", "params": {"sender": "script.service.hue", "message": "enable" }, "id": 1}\'')
That's great. Whenever I get around to getting home automation I'll be able to use this. Thanks for the suggestion
Hi. 2 days ago I bought a hue starter kit (3 bulbs, bridge and a switch) with a lightstrip. I use CoreELEC 9.2.0 (Kodi v18.4) and this script from repo. How to configure the extension for this actions:
-when playback starts, turn off the lightstip around the tv (the other 3 bulb is currently turned off). 
-when I paused the movie, undim the 3 bulbs for 50% brightness (but the lightstip now turned off).
-if the playback ends, undim the lightstip around the tv.
I dont want the ambilight or music reaction, just this function. I tried the older release (script.kodi.hue.ambilight 1.0) but the lightstip not works, just the three bulbs. I tried this extension and not able to configure this easy steps. Please help me. Thank you Smile
Hi Grizzlie,

You just need to set up scenes for each action. For example, use the official Hue app to set up the lights like you would like them when a movie starts. In the addon, select "Create Scene" and choose the lights that should be saved and give it a name like "Play". Under video actions, under play, select your new scene. Repeat for pause and stop. By default ambilight and music are turned off so you don't need to do anything for those.

Hope this helps!
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24