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"));
 }
Ejemplo n.º 2
0
        private static bool ScheduleAllowScene(PhillipsHueSceneEmbyProfile profile)
        {
            if (string.IsNullOrEmpty(profile.Schedule))
            {
                return(true);
            }

            return((DateTime.Now.TimeOfDay >= TimeSpan.Parse(profile.Schedule + ":00")) &&
                   (DateTime.Now <= DateTime.Now.Date.AddDays(1).AddHours(4)));
        }
 private void PlaybackCredits(PlaybackProgressEventArgs e, PhillipsHueSceneEmbyProfile profile, PluginConfiguration config)
 {
     if (CreditSessions.Exists(s => s.Equals(e.Session.Id)))
     {
         return;                                                                  //We've already triggered the event, it's in the list - move on
     }
     CreditSessions.Add(e.Session.Id);                                            //Add the session ID to the list so this event doesn't trigger again
     logger.Info($"Phillips Hue Reports trigger Credit Scene on {e.DeviceName}"); //Log that shit.
     RunScene(JsonSerializer.SerializeToString(new SceneRequest
     {
         scene = profile.MediaItemCredits
     }), config);
 }
        // ReSharper disable once TooManyArguments
        private void PlaybackPaused(PlaybackProgressEventArgs e, PluginConfiguration config, SessionInfo session, PhillipsHueSceneEmbyProfile profile)
        {
            if (config.BridgeIpAddress == null)
            {
                return;
            }

            logger.Info("Phillips Hue Reports Playback Paused...");

            logger.Info($"Phillips Hue Found Session Device: { session.DeviceName }");

            if (!ScheduleAllowScene(profile))
            {
                logger.Info($"Phillips Hue profile not allowed to run at this time: { profile.DeviceName }");
                return;
            }

            var sceneName = string.Empty;

            switch (e.MediaInfo.Type)
            {
            case "Movie":
                sceneName = profile.MoviesPlaybackPaused;
                break;

            case "TvChannel":
                sceneName = profile.LiveTvPlaybackPaused;
                break;

            case "Series":
                sceneName = profile.TvPlaybackPaused;
                break;

            case "Season":
                sceneName = profile.TvPlaybackPaused;
                break;

            case "Episode":
                sceneName = profile.TvPlaybackPaused;
                break;
            }

            RunScene(JsonSerializer.SerializeToString(new SceneRequest
            {
                scene = sceneName
            }), config);
        }