Jump to content

New Plugin - Philips Hue Mood Lighting


Go to solution Solved by Prydwyn,

Recommended Posts

BillOatman
Posted (edited)

I took the HueControl plugin by Biofects and modified it to set scenes defined within the Hue bridge instead of using light groups.  It is now in the Emby plugin catalog!

Additionally I added a couple new features:

 

1) Control for movies only. If checked, only movies will set the scenes.  Not TV Series for example.

2) Control only at night.  If checked, the plugin will only set the scenes between sunset and sunrise in your area.  You will need to set your latitude and longitude for this to work correctly. (Link on settings page)

3) The lights will not be controlled while you are watching live TV.

4) During the playing of trailers/prerolls, the scene will be set to your "paused" scene.

 

Note that when you enter scene names, they do not need to match the case of the scenes defined in the bridge.

That being said, even though the bridge allows you to create multiple scenes with the same name, but different case, you won't want to do that if using this plugin.

 

Feel free to try it out and let me know here if you see any issues.

If you currently use HueControl, I would suggest disabling it if you try this one.  Otherwise you might get a confusing, albeit interesting, light-show :)

 

Also note that transition time needs to be set in the scene for this plugin.  

Apparently not all Hue bridge apps allow this to be set.  

One free one that does for Windows is Huetro.

https://www.microsoft.com/en-us/p/huetro-for-hue/9wzdncrfjj3t?activetab=pivot:overviewtab

 

Version 1.1.0.0 now in the catalog. This version adds a configuration item to set a sunset offset that is used when determining whether or not to control the lights.

Edited by BillOatman
  • Like 5
WilhelmStroker
Posted

Ah this looks interesting as i currently use HomeAssistant to dim my lights...

I think i set everything up correctly but when i start watching something, nothing happens. The emby server log gives me this error for the plugin:

System.ArgumentException: System.ArgumentException: An item with the same key has already been added. Key: version
     at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
     at Emby.WebHueMoodLighting.API.ServerApiEndpoints.ParseJSON(String s)
     at Emby.WebHueMoodLighting.API.ServerApiEndpoints.Get(GetScenes request)
     at Emby.Server.Implementations.Services.ServiceExecGeneral.Execute(Type serviceType, IRequest request, Object instance, Object requestDto, String requestName)
     at Emby.Server.Implementations.Services.ServiceController.Execute(HttpListenerHost appHost, Object requestDto, IRequest req)
     at Emby.Server.Implementations.Services.ServiceHandler.ProcessRequestAsync(HttpListenerHost appHost, IRequest httpReq, IResponse httpRes, ILogger logger, String operationName, CancellationToken cancellationToken)
     at Emby.Server.Implementations.HttpServer.HttpListenerHost.RequestHandler(IRequest httpReq, String urlString, String host, String localPath, CancellationToken cancellationToken)
    Source: System.Private.CoreLib
    TargetSite: Void ThrowAddingDuplicateWithKeyArgumentException[T](T)
BillOatman
Posted (edited)

 

Ah this looks interesting as i currently use HomeAssistant to dim my lights...

I think i set everything up correctly but when i start watching something, nothing happens. The emby server log gives me this error for the plugin:

System.ArgumentException: System.ArgumentException: An item with the same key has already been added. Key: version
     at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
     at Emby.WebHueMoodLighting.API.ServerApiEndpoints.ParseJSON(String s)
     at Emby.WebHueMoodLighting.API.ServerApiEndpoints.Get(GetScenes request)
     at Emby.Server.Implementations.Services.ServiceExecGeneral.Execute(Type serviceType, IRequest request, Object instance, Object requestDto, String requestName)
     at Emby.Server.Implementations.Services.ServiceController.Execute(HttpListenerHost appHost, Object requestDto, IRequest req)
     at Emby.Server.Implementations.Services.ServiceHandler.ProcessRequestAsync(HttpListenerHost appHost, IRequest httpReq, IResponse httpRes, ILogger logger, String operationName, CancellationToken cancellationToken)
     at Emby.Server.Implementations.HttpServer.HttpListenerHost.RequestHandler(IRequest httpReq, String urlString, String host, String localPath, CancellationToken cancellationToken)
    Source: System.Private.CoreLib
    TargetSite: Void ThrowAddingDuplicateWithKeyArgumentException[T](T)

Thanks for reporting this.  Can you please try this?  It won't work, but in the log it should have an entry that starts:

[HueMoodLighting or ServerApiEndpoints] jsonString:

That will help me see what is happening. Please go into the settings page  and see if it saved your scenes as well. before looking in the log. And if it did not, please enter them and save, then look at the log.

Edited by BillOatman
hstamas
Posted

Just discovered the triggering of the pause scene during intros/trailers.

 

So cool!

 

Excellent work!

  • Like 2
WilhelmStroker
Posted

Thanks for reporting this.  Can you please try this?  It won't work, but in the log it should have an entry that starts:

[HueMoodLighting or ServerApiEndpoints] jsonString:

That will help me see what is happening. Please go into the settings page  and see if it saved your scenes as well. before looking in the log. And if it did not, please enter them and save, then look at the log.

 

Ok, so it definitely had saved the scenes. I'll PM you the log as it's a bit messy to post here. Let me know if there's anything else you need!

  • Like 1
BillOatman
Posted

Got it and investigating, thanks.

  • Like 1
BillOatman
Posted (edited)

Much thanks to @@WilhelmStroker for the problem report and quick response debugging!

 

New version will be published in the initial post later today.

Edited by BillOatman
  • Like 1
WilhelmStroker
Posted

And much thanks for the quick fix! Working fine now.

BillOatman
Posted

New version in initial post,

pir8radio
Posted

does this plugin still act like the old one, as in if ANY user plays a movie on ANY DEVICE this will activate?   Or can you set what device actually triggers the scenes?     Again, i have lots of users my theater will look like a disco if it responds to anyone playing a movie..    :)

hstamas
Posted

does this plugin still act like the old one, as in if ANY user plays a movie on ANY DEVICE this will activate?   Or can you set what device actually triggers the scenes?     Again, i have lots of users my theater will look like a disco if it responds to anyone playing a movie..    :)

You can specify which clients will or won’t trigger the plugin.

pir8radio
Posted

You can specify which clients will or won’t trigger the plugin.

 

excellent.......    :)

BillOatman
Posted (edited)

You select scenes for, and enable individual devices .  If you find it activating scenes for devices you have not configured let me know and I will fix it.

Yeah, what hstamas said ;)

Edited by BillOatman
  • Like 1
pir8radio
Posted (edited)

@@BillOatman

 

Ok so far so good, I was able to set this up on my server thats in a datacenter talking to my home hue hub...   good, good,  API success   got to this section. what text box is for what i assume play pause stop in that order?   and i have many rooms, how do i enter like theater MovieTime?     there are some default scenes like Dimmed,   How do i enter Theater Dimmed vs the other rooms Dimmed?  And the "re-Load Scenes doesnt seem to do anything?   also i save leave the plugin come back in and everything is blank?

 

not sure if it matters but my hue address is in this format:    my.domain.com:2222        

 

5d082fdc2a9de_Screenshotfrom201906171926

Edited by pir8radio
BillOatman
Posted

It's supposed to look like this.

 

5d0833490f380_Capture.jpg

 

If you are using safari, try chrome.

 

Look at the first post, scenes used for this need to be uniquely named.

pir8radio
Posted

It's supposed to look like this.

 

5d0833490f380_Capture.jpg

 

If you are using safari, try chrome.

 

Look at the first post, scenes used for this need to be uniquely named.

 

was using IE on windows 10.    chrome looks better...    What does the reload scenes button do?   And should i see anything next to the green dot below that showing the API or something?   maybe that can be an option?

BillOatman
Posted (edited)

If you change the scenes in the bridge you can press the reload scenes button to load the new list into the plugin without needing to restart Emby.

 

Green dot means all is well and it can talk to the bridge.  Otherwise you will see an error icon and message.

 

I'll have to post and see what is up with that config section that IE and safari don't want to display the labels but chrome does.

Edited by BillOatman
  • Like 1
pir8radio
Posted (edited)

If you change the scenes in the bridge you can press the reload scenes button to load the new list into the plugin without needing to restart Emby.

 

Green dot means all is well and it can talk to the bridge.  Otherwise you will see an error icon and message.

 

I'll have to post and see what is up with that config section that IE and safari don't want to display the labels but chrome does.

ok cool   i was confused by the green dot, when i got the api it had a check mark and said success   went back in only saw the green dot...     

 

@@BillOatman

 

Still not working though...   

2019-06-17 21:00:06.003 Error SessionManager: Error in event handler
	*** Error Report ***
	Version: 4.2.0.17
	Command line: C:\Users\nam\AppData\Roaming\Emby-Server\System\EmbyServer.dll -noautorunwebapp
	Operating system: Microsoft Windows NT 6.2.9200.0
	64-Bit OS: True
	64-Bit Process: True
	User Interactive: True
	Runtime: file:///C:/Users/nam/AppData/Roaming/Emby-Server/System/System.Private.CoreLib.dll
	Processor count: 40
	Program data path: C:\Users\nam\AppData\Roaming\Emby-Server
	Application directory: C:\Users\nam\AppData\Roaming\Emby-Server\System
	System.MissingMethodException: System.MissingMethodException: Method not found: 'Boolean MediaBrowser.Model.Dto.BaseItemDto.IsType(System.String)'.
	   at Emby.HueMoodLighting.HueMoodLighting.PlaybackProgress(Object sender, PlaybackProgressEventArgs e)
	   at MediaBrowser.Common.Events.EventHelper.FireEventIfNotNull[T](EventHandler`1 handler, Object sender, T args, ILogger logger)
	Source: Emby.HueMoodLighting
	TargetSite: Void PlaybackProgress(System.Object, MediaBrowser.Controller.Library.PlaybackProgressEventArgs)
	
2019-06-17 21:00:06.061 Info HttpServer: HTTP POST http://my.domain.com/emby/Sessions/Playing/Progress. UserAgent: Dalvik/2.1.0 (Linux; U; Android 7.1.2; AFTMM Build/NS6263)
2019-06-17 21:00:06.065 Error SessionManager: Error in event handler
	*** Error Report ***
	Version: 4.2.0.17
	Command line: C:\Users\nam\AppData\Roaming\Emby-Server\System\EmbyServer.dll -noautorunwebapp
	Operating system: Microsoft Windows NT 6.2.9200.0
	64-Bit OS: True
	64-Bit Process: True
	User Interactive: True
	Runtime: file:///C:/Users/nam/AppData/Roaming/Emby-Server/System/System.Private.CoreLib.dll
	Processor count: 40
	Program data path: C:\Users\nam\AppData\Roaming\Emby-Server
	Application directory: C:\Users\nam\AppData\Roaming\Emby-Server\System
	System.MissingMethodException: System.MissingMethodException: Method not found: 'Boolean MediaBrowser.Model.Dto.BaseItemDto.IsType(System.String)'.
	   at Emby.HueMoodLighting.HueMoodLighting.PlaybackProgress(Object sender, PlaybackProgressEventArgs e)
	   at MediaBrowser.Common.Events.EventHelper.FireEventIfNotNull[T](EventHandler`1 handler, Object sender, T args, ILogger logger)
	Source: Emby.HueMoodLighting
	TargetSite: Void PlaybackProgress(System.Object, MediaBrowser.Controller.Library.PlaybackProgressEventArgs)
Edited by pir8radio
pir8radio
Posted (edited)

those errors seem to be flooding my log file ever second.  since i added the plugin.

Edited by pir8radio
BillOatman
Posted

Don't know,  It runs on windows and mac on a server in the same network as the bridge,

 

@Luke  This is the code that is having the problem. in his setup (error 2 posts above) on a emby server running in a linux datacenter (the IsType call).  Any ideas as to why?

       private void PlaybackProgress(object sender, PlaybackProgressEventArgs e)
        {          
            if (e.Item.MediaType != "Video") { return; }


            var DeviceOptions = Plugin.Instance.Configuration.Options.Where(i => i.embyDeviceID == e.DeviceId && i.Enabled);
            bool isMovie = e.MediaInfo.IsType("Movie");
Posted

Looks like it's trying to parse bad json.

pir8radio
Posted (edited)

 

Don't know,  It runs on windows and mac on a server in the same network as the bridge,

 

@Luke  This is the code that is having the problem. in his setup (error 2 posts above) on a emby server running in a linux datacenter (the IsType call).  Any ideas as to why?

       private void PlaybackProgress(object sender, PlaybackProgressEventArgs e)
        {          
            if (e.Item.MediaType != "Video") { return; }


            var DeviceOptions = Plugin.Instance.Configuration.Options.Where(i => i.embyDeviceID == e.DeviceId && i.Enabled);
            bool isMovie = e.MediaInfo.IsType("Movie");

 

 

Its a windows server...   My physical server in a datacenter.       These errors are local though, have not even gotten to the part where it sends controls to the hue. 

Edited by pir8radio
pir8radio
Posted

Well, i had to remove the plugin for now until it works...   my log file was growing fast...   and it wasn't working.

Posted (edited)
Edited by chef
Posted (edited)

You want to monitor the playback progress event for things like pausing and unpause in sessions.

 

Also, it is good to check mediaItem.Type = "Movie"

 

Or "Series", "Episode" etc

Edited by chef

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...