Beispiel #1
0
        static bool firstAuto = true;         //Prevents AutoEffect from running more than once.

        async public static void AutoEffect()
        {
            if (firstAuto)
            {
                await Task.Delay(1000);                 //Gives RefreshData some time to complete successfully.

                if (Ready())
                {
                    if (Platform.ReadSetting("autoEffect") < 0)                       //Scenes
                    {
                        bool hardCoded = false;
                        if (Platform.ReadSetting("autoEffect") == -2)
                        {
                            hardCoded = true;
                        }
                        PutEvents.ChangeScene(Platform.ReadSetting("autoName"), hardCoded);
                    }
                    else if (Platform.ReadSetting("autoEffect") > 0)                         //Effects
                    {
                        ModeOn(Platform.ReadSetting("autoName"));
                    }
                }
                firstAuto = false;
            }
        }
Beispiel #2
0
        public static void ModeOn(string modeName)
        {
            //Turn on the lights if any of them are disabled
            foreach (string light in Storage.groupData.lights)
            {
                if (JsonParser.Read(Storage.latestData, new string[] { "lights", light, "state", "on" }) == false)
                {
                    PutEvents.ToggleLight(light, true);
                }
            }

            effectMode = modeName;
            Platform.NotifyCheck(modeName, true);

            switch (effectMode)
            {
            case "test":
            case "ambient":
                effectTimer.Interval      = 150;
                bufferData.transitiontime = Platform.ReadSetting("ambientTransition");
                break;

            case "daylight":
                effectTimer.Interval      = 1500;
                bufferData.transitiontime = 40;
                if (Platform.ReadSetting("daylightSetting") == 0)                           //Regional
                {
                    chosenSunrise = SunriseEquation.JulianToTime(SunriseEquation.sunrise);
                    chosenSunset  = SunriseEquation.JulianToTime(SunriseEquation.sunset);
                }
                else if (Platform.ReadSetting("daylightSetting") == 1) //Equinox
                {
                    chosenSunrise = 480;                               //06:00
                    chosenSunset  = 1080;                              //18:00
                }
                else if (Platform.ReadSetting("daylightSetting") == 2) //Startup
                {
                    chosenSunrise = SunriseEquation.JulianToTime(SunriseEquation.startup);
                    chosenSunset  = SunriseEquation.JulianToTime(SunriseEquation.startup + 0.5);
                }
                break;
            }

            if (!effectsOn)
            {
                EffectTimerOn();
            }
        }
Beispiel #3
0
        public static void EffectsOff()
        {
            if (effectTimer.Enabled)
            {
                effectMode           = "";
                effectTimer.Elapsed -= OnTimedEvent;
                effectTimer.Enabled  = false;
                foreach (string light in Storage.groupData.lights)                   //Restore last scene data from backup

                {
                    JsonParser.Create(Storage.latestData, new string[] { "lights", light, "state" }, JsonParser.Read(Storage.sceneBackup, new string[] { light, "state" }));
                    PutEvents.CustomPut(light, JsonParser.Serialize(JsonParser.Read(Storage.sceneBackup, new string[] { light, "state" })), true);
                }
                effectsOn = false;
                Platform.NotifyCheck("", false);
            }
        }