Jump to content
BillOatman

ANSWERED New Plugin - Philips Hue Mood Lighting

Recommended Posts

Bambu Utila
Just now, chef said:

Okay, I'll take a look at the code, but scenes should only run after 6:30pm.

That isn't happening?

Nope, sadly enough not.

I tied to start a movie and tv series after 6pm but before 12am and it doesn't work, after 12am also still doesn't work for me

Share this post


Link to post
Share on other sites
BillOatman
 return (DateTime.Now.TimeOfDay >= TimeSpan.Parse(profile.Schedule + ":00") && DateTime.Now.TimeOfDay <= TimeSpan.Parse("6:00:00"));

@chef

so configured time is 6:30pm

at 7pm DateTime.Now.TimeOfDay >= TimeSpan.Parse(profile.Schedule + ":00"  is true

but DateTime.Now.TimeOfDay <= TimeSpan.Parse("6:00:00") is false

and the logic is AND

You need to include the date component, not just the time

This is what I had using sunrise/sunset

        /// <summary>
        /// Check if it is currently daylight in the supplied location.
        /// </summary>
        /// <param name="latitude"></param>
        /// <param name="longitude"></param>
        /// <param name="offset">The offset (+/-) from sunset, in hours, to use to determine when to start setting light scenes.</param>
        /// <returns>True if during daylight hours, else false.</returns>
        public static bool isDaytime(double latitude, double longitude, int offset)
        {
            DateTime now = DateTime.Now.ToLocalTime();
            DateTime sunrise = GetSunrise(now, latitude, longitude);
            DateTime sunset = GetSunset(now, latitude, longitude);

         //   SimpleLog.Info("isDaytime: offset: " + offset.ToString() + "  sunrise: " + sunrise.TimeOfDay.ToString() + "   sunset: " + sunset.TimeOfDay.ToString() + "   sunset adjusted: " + sunset.AddHours(offset).TimeOfDay.ToString());

            if (now.TimeOfDay >= sunrise.TimeOfDay && now.TimeOfDay < sunset.AddHours(offset).TimeOfDay)
                return true;

            return false;
        }

So anything not daytime, the scenes were used.

Edited by BillOatman
  • Thanks 1

Share this post


Link to post
Share on other sites
BillOatman

Maybe that's what you do @chef

Define 2 times that give the range of when not to trigger scenes like sunrise and sunset and use the logic above but with your configured times.

DST becomes a nuisance, but it was already with your current configuration.

Edited by BillOatman
  • Like 1

Share this post


Link to post
Share on other sites
chef

It took a moment but this seems to be it here:

        private static bool ScheduleAllowScene(PhillipsHueSceneEmbyProfile profile)
        {
            if (string.IsNullOrEmpty(profile.Schedule)) return true;
		
            return (DateTime.Now.TimeOfDay >= TimeSpan.Parse(profile.Schedule + ":00") || DateTime.Now.TimeOfDay <= TimeSpan.Parse("6:00:00"));
        }

Time is: 8:00pm = 20:00

Schedule Time is set: 7:00pm = 19:00

 

Time is greater then the scheduled time -> This is "true"

or

Time is less than 06:00 (6:00am) -> This is "false" (but condition is already "true").

 

at 24:00 (12:00am)  condition is already "true", is greater then 19:00

at 01:00 (1:00am) is greater then scheduled time (19:00) -> This is "false"... but is less then 06:00 -> This is  "true"

Both conditions on either side of the OR statement before 19:00 hrs will return "false", after 06:00 hrs.

 

 

 

 

 

 

 

Edited by chef
  • Like 1

Share this post


Link to post
Share on other sites
BillOatman
56 minutes ago, chef said:

It took a moment but this seems to be it here:


        private static bool ScheduleAllowScene(PhillipsHueSceneEmbyProfile profile)
        {
            if (string.IsNullOrEmpty(profile.Schedule)) return true;
		
            return (DateTime.Now.TimeOfDay >= TimeSpan.Parse(profile.Schedule + ":00") || DateTime.Now.TimeOfDay <= TimeSpan.Parse("6:00:00"));
        }

Time is: 8:00pm = 20:00

Schedule Time is set: 7:00pm = 19:00

 

Time is greater then the scheduled time -> This is "true"

or

Time is less than 06:00 (6:00am) -> This is "false" (but condition is already "true").

 

at 24:00 (12:00am)  condition is already "true", is greater then 19:00

at 01:00 (1:00am) is greater then scheduled time (19:00) -> This is "false"... but is less then 06:00 -> This is  "true"

Both conditions on either side of the OR statement before 19:00 hrs will return "false", after 06:00 hrs.

Heh, I usually see the simple solution first but not this time, well played :)

Share this post


Link to post
Share on other sites
Bambu Utila

YES! It's working!

I've downloaded the new version 1.1.0.1 and tried to start something before and after 12am, both are working as expected now!

Thanks you for fixing this!

Share this post


Link to post
Share on other sites
BillOatman

@chef Don't forget to update GIT :)

  • Like 1

Share this post


Link to post
Share on other sites
chef

We could have also used De Morgan's Law, of Inversion ("!") to inverse the && (and) truth table to get the exact same outcome.

De Morgan's Law in Computer science says that by inverting an inverse && we get an || and vice versa, using the "bang" ("!").

"!(!bollean.value && ! boolean.value) == boolean.value || boolean.value"

Which is just Crazy right!

Edited by chef
  • Like 1

Share this post


Link to post
Share on other sites
NSBrad
On 8/24/2020 at 5:16 PM, NSBrad said:

Love the plugin.  It was exactly what I as looking for in Hue support.

I'm having an issue though where it randomly stops working.  I haven't found any pattern to it.  Last night it happened when a video I was watching ended and and when I hit play on the next episode it stayed in my stopped scene and didn't go to the playing scene.  I've had this happen to me a number of times over the last few months.  When it happens the configuration page doesn't list any of my scenes when I select any of the states in the configuration screen.  The only fix I've found so far is to reboot the server.  Are there any logs or anything that I can check or send in to try to figure out what's causing it?  I'm running the Emby server on a Synology NAS btw if that makes a difference.  

Is this issue not happening for anyone else?  I ran into it again last night.  

Share this post


Link to post
Share on other sites
BillOatman
On 9/18/2020 at 5:43 PM, NSBrad said:

Is this issue not happening for anyone else?  I ran into it again last night.  

@NSBrad  If your plugin config screen does not list any scenes that would imply that your Emby server cannot communicate with your hue hub. If it's a problem with the hub or the server is anyones guess, but if a server reboot corrects the situation, it would imply a server issue of some sort, either the server itself or Emby.  Maybe the Emby logs could shed some light on it.

Share this post


Link to post
Share on other sites
marciodantas

 

On 3/6/2020 at 3:55 PM, BillOatman said:

If you go to the dashboard get the server log.  And make note in your post here the time you tried it.

Hey @BillOatman sorry to bump this, but here in my place we watch every movie through Chromecast. Would you mind taking a look at my server log and checking if you can enable Chromecast as a device in the plugin configuration? As @zackidack pointed before, it does show as an "active device" in dashboard even tough it's not shown as a "pickable" device in Hue plugin.

I started casting ~ 23:55

image.png.4a0057b998823e3a067a0835ecc4e21f.png

embyserver.txt

Share this post


Link to post
Share on other sites
BillOatman

@marciodantas The hue commands originate from the server not the client, so not the chromecast in your case.  There must be something wrong in the plugin configuration screen that isn't allowing the chromecast to be selected.,  @chef largely rewrote that code, but between he and I we should be able to figure it out.  But I do not have a chromecast device to test with and I do not know if @chef does or not.

Also is this a older chromecast or one of the new ones?

Edited by BillOatman

Share this post


Link to post
Share on other sites
chef

Chromecast is a strange one. That device doesn't report playback. It is possible that the device which instantiated the playback to chromecast would trigger the event.

Share this post


Link to post
Share on other sites
BillOatman
1 minute ago, chef said:

Chromecast is a strange one. That device doesn't report playback. It is possible that the device which instantiated the playback to chromecast would trigger the event.

Yeah the older ones only operate when something "casts" to them.  The new ones are more like shields and run android tv.  Thats why I asked old or new chromecast.

@marciodantas  If it is a older chromecast is the device that is casting to it in the plugin list?

  • Like 1

Share this post


Link to post
Share on other sites
marciodantas

 

On 10/18/2020 at 1:22 PM, BillOatman said:

Yeah the older ones only operate when something "casts" to them.  The new ones are more like shields and run android tv.  Thats why I asked old or new chromecast.

@marciodantas  If it is a older chromecast is the device that is casting to it in the plugin list?

Yes guys, it's the old one (Chromecast Ultra) without the Google TV! 

 

@BillOatman yes all the device that is casting is in the plugin list. I tried with iPad (native emby app), S20 (Android 10) and through Chrome (OSX).. None of them worked... 

I'll try again later, but i'm thinking that chromecast makes the connection directly with the server, right? Doesn't seems to me that using the devices would trigger the plugin. 

On a side note, if you could enable a "Whatever device" in the list, that would defintely works for me! :)

Edited by marciodantas

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