cees-elzinga / script.xbmc.hue.ambilight

XBMC add-on for Philips Hue lights with ambilight support
Do What The F*ck You Want To Public License
127 stars 122 forks source link

Turn on light , new Feature #11

Closed defuuss closed 10 years ago

defuuss commented 11 years ago

Hi It would be nice to have a feature to turn on a light or a group when the movie starts.

Another nice feature would be when a movie is paused to bright up the light only half dimmed.

Thx

cees-elzinga commented 11 years ago

Hi defuuss,

Thanks for the suggestions. I might implement the first feature as on option. This was actually the way the add-on used to work, but I recently spent time making sure "turned off" lights stay off..

The second one is already there.... kinda...

If you select ambilight for say group 0 (all lights). If you then go to the advanced settings panel, in the ambilight section, select to "dim and undim" a group in ambilight mode, and set the group again to 0. When playback starts group 0 is now dimmed, but right away set to a different color/brightness by the ambilight. When pausing, the lights go to the undimmed setting.

Yes it's hacky ;-)

defuuss commented 11 years ago

I am just trying myself to understand the code .:-)

Just some more info about my setup. I have 3 Philips Hue and 4 Living Whites in the room of my Tv. One Living white switch is triggering my self made Led Ambilight connected through Boblight. It would be perfect if this living white could be triggered as soon as the script starts. At this point i am just trying to understand your code . That's why the workaround for the second requested feature won't work at my setup because then my Led Ambilight will be turned off when the movie starts.

You are doing a great job here that's why I just donated something. Thx

cees-elzinga commented 11 years ago

You're welcome :)

Sounds like you got a pretty cool setup over there!

I'm not sure I understand the details completely... The living white switch you're talking about isn't an actual bulb, right? It's a light that is converted into a switch?

So when the add-on starts, it should turn this light on (ie triggering the switch), and that will activate your boblight?

I'm thinking you would be the only one using the add-on in this way, so I probably won't include this in the add-on, but I can help you out a little to add it yourself :)

PS And what do you want to do with the remaining 3 living white light and philips hue light? Should they be dimmed or put into ambilight mode?

cees-elzinga commented 11 years ago

Maybe this will help you getting started...

In the following example light number 2 is the livingwhite light that is the switch for the boblight. Everytime playback starts this light is set to "on" with a specific brightness.

All the way at the bottom of default.py add the following function:

`def switch_trigger():

use the default settings

tmp_settings = settings()

override it to use a single bulb (0 would be group)

tmp_settings.light = 1

override the number of the light to use to 2

tmp_settings.light_id = 2

l = Light(tmp_settings)

override the add-on to think the light is turned on (if you don't do this, the light is ignored if it's turned off)

l.start_settings['on'] = True

set light to state "on" and "bri" 100

data = '{"on":true,"bri":100}' l.set_light(data)`

Everytime you call swtich_trigger(), is should turn on light 2 to brightness 100. Now all you have to do is tell the plugin when you want this to happen.

line 259 is prob what you want:

def state_changed(state): logger.debuglog("state changed to: %s" % state) if state == "started": switch_trigger() # turn the trigger livingwhite to "on" logger.debuglog("retrieving current setting before starting")

Code is untested, hope it helps!

defuuss commented 11 years ago

Oh thank you , I will play with it a little bit the weekend :-)

Just to clarify a little bit more .

So in my Living Room , I have 2 Hue Lights ( They go of when Movie starts ) I have 2 Living Colors from Philips ( go es out when Movie Starts) one living white ( normal light , goes out when movie start ) and one living white connected to my Ambilight ( a lot LED Stripes ) which is connected per USB to my XBMC.

I am pretty sure that this config won't be used for now , but on the other side when those osram Zigbee Light Modules are out I am pretty sure some people might want to turn on a light when XBMC starts. But until then I totally agree with you . Ok let's go back

So The problem with my ambilight and xbmc with boblight is that it only recognize it when the boblight plugin is started , so if I enable it after I have to restart the boblight plugin. That's why I thought maybe it should start directly at the beginning , ok enough of the explanation , you see where it goes. :-)

So to answer your questions the other lights I don't use the ambilight modus for the other lights because my ambilight are 120 Samsungs LEDS lol , that will be to much lol :-)

Another question I have , I don't know if it's a bug or working as designed.

Let's assume I have 2 groups

Group 1 ( all the 5 lights in the Living Room except one ) Group 2 the other light.

I just had 1 light on of the group 1 so 4 Lights where off. the moment the script starts. So then I switched on the other 4 lights. When the movie starts only the first light switch off the other 4 stays on.

I assume that this has to do with the last_state. Do you take this value when the script starts ?

I am sorry but I have another question

I assume , just tell me if I am corrrect

override it to use a single bulb (0 would be group)

tmp_settings.light = 1

override the number of the light to use to 2

tmp_settings.light_id = 2

So if you would like to use group 3 for example it would be look like that tmp_settings.light = 0 tmp_settings.light_id = 3

Thx

Chris

cees-elzinga commented 11 years ago

I'll get back on the other questions, but regarding the last one: no, then you'll have to use "group_id".:

    tmp_settings.light           = 0 # 0 = group, 1 = single light
    tmp_settings.light_id        = 2 # only used when a single light is configured
    tmp_settings.group_id        = 0 # only used when a group is configured
defuuss commented 11 years ago

Ok thanks I will try it out tonight

cees-elzinga commented 11 years ago

Hi Chris,

didn't spend a lot of time on the project recently. do you have any remaining questions regarding this issue? or can i close it? thanks