예제 #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.");
        }
예제 #2
0
        protected override void Execute_HomeAutomationNetworkDefinition(HomeAutomationCommandContext context)
        {
            var interpreter = context.Interpreter;
            var network     = context.Network as WeMoNetwork;
            var ip          = context.ReadParameter("IP").Value;

            network.Connect(ip);
        }
예제 #3
0
        protected override void Execute_HomeAutomationNetworkDefinition(HomeAutomationCommandContext context)
        {
            var interpreter = context.Interpreter;
            var network     = context.Network;

            var poll = context.ReadParameter("Poll").ToBoolean();

            //TODO: list all devices on all networks.
            //TODO: add type

            const string addressLabel   = "Address";
            const string typeLabel      = "Type";
            const string connectedLabel = "Connected";
            const string statusLabel    = "Status";

            var addressLength   = addressLabel.Length;
            var typeLength      = typeLabel.Length;
            var connectedLength = connectedLabel.Length;
            var statusLength    = statusLabel.Length;

            foreach (var device in network.Devices)
            {
                addressLength = Math.Max(addressLength, device.BuildVirtualAddress(false, false).Length);
                typeLength    = Math.Max(typeLength, device.Type.Name.Length);
                statusLength  = Math.Max(statusLength, device.Describe().Length);
            }

            var tableBuilder = new TextTable(new[] { addressLength, typeLength, connectedLength, statusLength });

            interpreter.WriteEvent(tableBuilder.StartOfTable(addressLabel, typeLabel, connectedLabel, statusLabel));

            foreach (var device in network.Devices)
            {
                var address = device.BuildVirtualAddress(false, false);

                if (poll)
                {
                    try
                    {
                        device.Poll();
                    }
                    catch
                    { }
                }

                var status = device.Describe();

                var connected = (device.IsConnected == true)?"Yes":" - ";

                interpreter.WriteEvent(tableBuilder.ContentLine(address, device.Type, connected, status));
            }

            interpreter.WriteEvent(tableBuilder.EndOfTable());
        }
예제 #4
0
        protected override void Execute_HomeAutomationNetworkDefinition(HomeAutomationCommandContext context)
        {
            var interpreter = context.Interpreter;
            var network = context.Network;

            var poll = context.ReadParameter("Poll").ToBoolean();

            //TODO: list all devices on all networks.
            //TODO: add type

            const string addressLabel = "Address";
            const string typeLabel = "Type";
            const string connectedLabel = "Connected";
            const string statusLabel = "Status";

            var addressLength = addressLabel.Length;
            var typeLength = typeLabel.Length;
            var connectedLength = connectedLabel.Length;
            var statusLength = statusLabel.Length;

            foreach (var device in network.Devices)
            {
                addressLength = Math.Max(addressLength, device.BuildVirtualAddress(false, false).Length);
                typeLength = Math.Max(typeLength, device.Type.Name.Length);
                statusLength = Math.Max(statusLength, device.Describe().Length);
            }

            var tableBuilder = new TextTable(new[] { addressLength, typeLength, connectedLength, statusLength });

            interpreter.WriteEvent(tableBuilder.StartOfTable(addressLabel, typeLabel, connectedLabel, statusLabel));

            foreach (var device in network.Devices)
            {
                var address = device.BuildVirtualAddress(false, false);

                if (poll)
                {
                    try
                    {
                        device.Poll();
                    }
                    catch
                    { }
                }

                var status = device.Describe();

                var connected = (device.IsConnected == true)?"Yes":" - ";

                interpreter.WriteEvent(tableBuilder.ContentLine(address, device.Type, connected, status));
            }

            interpreter.WriteEvent(tableBuilder.EndOfTable());
        }
예제 #5
0
        protected override void Execute_HomeAutomationNetworkDefinition(HomeAutomationCommandContext context)
        {
            var interpreter = context.Interpreter;
            var network     = context.Network as OpenZWaveNetwork;
            var returnRoute = context.ReadParameter(ReturnRouteKey).ToBoolean();

            interpreter.WriteEvent("Optimizing " + network);

            network.OptimizePaths(returnRoute);

            interpreter.WriteEvent("Done");
        }
예제 #6
0
        protected override void Execute_HomeAutomationDefinition(HomeAutomationCommandContext context)
        {
            var interpreter = context.Interpreter;
            var networks    = context.Networks;

            var address = context.ReadParameter("Address").Value;

            interpreter.WriteEvent("Searching for PiEngineering devices");

            var network = new PiEngineeringNetwork(new HomeAutomationNetworkContext(context.Engine, context.ThreadPool), address);

            networks.Add(network);

            interpreter.WriteEvent("Done.");
        }
예제 #7
0
        protected override void Execute_HomeAutomationDefinition(HomeAutomationCommandContext context)
        {
            var interpreter = context.Interpreter;
            var networks    = context.Networks;
            var port        = context.ReadParameter("Port").Value;

            if (port.StartsWith("COM", StringComparison.InvariantCultureIgnoreCase))
            {
                port = @"\\.\" + port;
            }

            interpreter.WriteEvent("Searching for Z-Wave network adapater at " + port + "...");

            var network = new OpenZWaveNetwork(new HomeAutomationNetworkContext(context.Engine, context.ThreadPool), port);

            networks.Add(network);

            interpreter.WriteEvent("Done.");
        }