Esempio n. 1
0
        protected override void Execute_HomeAutomationDefinition(HomeAutomationCommandContext context)
        {
            var interpreter = context.Interpreter;
            var networks = context.Networks;
            var streamStore = context.StreamStore;
            var ip = context.ReadParameter("IP").Value;

            var appDataRepository = new AppDataRepository(streamStore);
            var appData = appDataRepository.Load();

            if (string.IsNullOrEmpty(ip))
            {
                interpreter.WriteEvent("Searching for Hue bridge...");

                ip = FindIp();
                interpreter.WriteEvent("Found " + ip);
            }

            var networkContext = new HomeAutomationNetworkContext(context.Engine, context.ThreadPool);
            var network = new Q42HueNetwork(networkContext, ip, appData, () => interpreter.WriteEvent("Press the link button on the Hue bridge."));
            networks.Add(network);

            appDataRepository.Save(appData);

            interpreter.WriteEvent("Done.");
        }
Esempio n. 2
0
        protected override void Execute_HomeAutomationDefinition(HomeAutomationCommandContext context)
        {
            var interpreter = context.Interpreter;
            var networks    = context.Networks;
            var streamStore = context.StreamStore;
            var ip          = context.ReadParameter("IP").Value;

            var appDataRepository = new AppDataRepository(streamStore);
            var appData           = appDataRepository.Load();

            if (string.IsNullOrEmpty(ip))
            {
                interpreter.WriteEvent("Searching for Hue bridge...");

                ip = FindIp();
                interpreter.WriteEvent("Found " + ip);
            }

            var networkContext = new HomeAutomationNetworkContext(context.Engine, context.ThreadPool);
            var network        = new Q42HueNetwork(networkContext, ip, appData, () => interpreter.WriteEvent("Press the link button on the Hue bridge."));

            networks.Add(network);

            appDataRepository.Save(appData);

            interpreter.WriteEvent("Done.");
        }