Exemplo n.º 1
0
        public async static Task Run([TimerTrigger("0 0 */2 * * *")] TimerInfo myTimer, TraceWriter log)
        {
            var lightID  = Environment.GetEnvironmentVariable("LightId", EnvironmentVariableTarget.Process);
            var provider = new LifxProvider();

            var connected = await provider.IsLightOnlineAsync(lightID);

            if (connected)
            {
                log.Info("Light still online");
            }
            else
            {
                log.Info("Light went offline!");
                var emailProvider = new EmailProvider();
                var emailSent     = await emailProvider.SendEmailAsync("Lifx connection is down", "For more details check the Azure function portal.");

                var logMsg = emailSent ? "Message Sent" : "Failed to send message";
                log.Info(logMsg);
            }
        }
Exemplo n.º 2
0
        public static async Task UpdateLightAsync(LightSettings settings, string failureMessage, TraceWriter log)
        {
            var lightID = Environment.GetEnvironmentVariable("LightId", EnvironmentVariableTarget.Process);

            var provider     = new LifxProvider();
            var lightUpdated = await provider.UpdateLightAsync(lightID, settings);

            if (lightUpdated)
            {
                log.Info("Successfully updated light.");
            }
            else
            {
                log.Info("Failed to update light.");
                var emailProvider = new EmailProvider();
                var emailSent     = await emailProvider.SendEmailAsync(failureMessage, "For more details check the Azure function portal.");

                var logMsg = emailSent ? "Message Sent" : "Failed to send message";
                log.Info(logMsg);
            }
        }