コード例 #1
0
        protected override void Execture_HomeAutomationSingleDeviceDefinition(HomeAutomationSingleDeviceContext context)
        {
            var device = context.Device as PiEngineeringDevice;
            var bluePower = context.ReadParameter("BluePower").ToByte();
            var redPower = context.ReadParameter("RedPower").ToByte();

            device.SetButtonLightIntensity(bluePower, redPower);
        }
コード例 #2
0
ファイル: ColorLoop.cs プロジェクト: Mavtak/roomie
        protected override void Execture_HomeAutomationSingleDeviceDefinition(HomeAutomationSingleDeviceContext context)
        {
            var device = context.Device as Q42HueDevice;
            var command = new LightCommand
            {
                Effect = Effect.ColorLoop,
            };

            device.SendCommand(command);
        }
コード例 #3
0
        protected override void Execture_HomeAutomationSingleDeviceDefinition(HomeAutomationSingleDeviceContext context)
        {
            var device = context.Device as ZWaveDevice;
            var interpreter = context.Interpreter;
            var parameterNumber = context.ReadParameter("ParameterNumber").ToByte();
            var value = context.ReadParameter("Value").ToByte();

            var parameter = device.BackingObject.ConfigurationParameters[parameterNumber];

            parameter.Value = value;
        }
コード例 #4
0
ファイル: OptimizeDevice.cs プロジェクト: Mavtak/roomie
        protected override void Execture_HomeAutomationSingleDeviceDefinition(HomeAutomationSingleDeviceContext context)
        {
            var interpreter = context.Interpreter;
            var device = context.Device as OpenZWaveDevice;
            var returnRoute = context.ReadParameter(ReturnRouteKey).ToBoolean();

            interpreter.WriteEvent("Optimizing " + device);

            device.OptimizePaths(returnRoute);

            interpreter.WriteEvent("Done");
        }
コード例 #5
0
        protected override void Execture_HomeAutomationSingleDeviceDefinition(HomeAutomationSingleDeviceContext context)
        {
            var device = context.Device as ZWaveDevice;
            var interpreter = context.Interpreter;

            for (byte i = 0; i < byte.MaxValue; i++)
            {
                ListValue(interpreter, device, i);
            }

            ListValue(interpreter, device, 255);
        }
コード例 #6
0
ファイル: SetAllButtonLights.cs プロジェクト: Mavtak/roomie
        protected override void Execture_HomeAutomationSingleDeviceDefinition(HomeAutomationSingleDeviceContext context)
        {
            var device = context.Device as PiEngineeringDevice;
            var bankString = context.ReadParameter("Color").Value;
            var power = context.ReadParameter("Power").ToBoolean();

            Bank bank;
            if (!Enum.TryParse(bankString, out bank))
            {
                throw new RoomieRuntimeException("Color \"" + bankString + "\" is not valid");
            }

            device.SetAllButtonLights(bank, power);
        }
コード例 #7
0
        protected override void Execture_HomeAutomationSingleDeviceDefinition(HomeAutomationSingleDeviceContext context)
        {
            var device = context.Device as ZWaveDevice;
            var interpreter = context.Interpreter;
            var parameterNumber = context.ReadParameter("ParameterNumber").ToByte();

            var parameter = device.BackingObject.ConfigurationParameters[parameterNumber];

            if (parameter == null)
            {
                interpreter.WriteEvent("Parameter does not exist");
                return;
            }

            interpreter.WriteEvent(parameter.Value.ToString());
        }
コード例 #8
0
ファイル: PrintData.cs プロジェクト: Mavtak/roomie
        protected override void Execture_HomeAutomationSingleDeviceDefinition(HomeAutomationSingleDeviceContext context)
        {
            var interpreter = context.Interpreter;
            var device = context.Device as OpenZWaveDevice;

            var headers = new[]
            {
                "Command Class",
                "Index",
                "Instance",
                "Value",
                "Units",
                "Type",
                "Label",
                "Help"
            };

            var values = device.Values
                               .OrderBy(x => x.Index)
                               .OrderBy(x => x.Instance)
                               .OrderBy(x => x.CommandClass.ToString());

            var rows = values.Select(TransformValue).ToArray();

            var rowsAndHeaders = new[] {headers}.Concat(rows).ToArray();

            var columnWidths = new int[headers.Length];

            for (var i = 0; i < columnWidths.Length; i++)
            {
                columnWidths[i] = rowsAndHeaders.Max(x => x[i].Length);
            }

            var tableBuilder = new TextTable(columnWidths);

            interpreter.WriteEvent(tableBuilder.StartOfTable(headers));

            foreach (var row in rows)
            {
                interpreter.WriteEvent(tableBuilder.ContentLine(row));
            }

            interpreter.WriteEvent(tableBuilder.EndOfTable());
        }
コード例 #9
0
        protected override void Execute_HomeAutomationDefinition(HomeAutomationCommandContext context)
        {
            var interpreter = context.Interpreter;
            var scope       = context.Scope;
            var networks    = context.Networks;
            var retries     = context.ReadParameter(RetriesParameterAttribute.Key).ToInteger();

            Device device = null;

            if (scope.Local.ContainsVariable("Device"))
            {
                var allDevices = networks.SelectMany(x => x.Devices);
                var address    = context.ReadParameter("Device").ToVirtualAddress();
                device = allDevices.GetDevice(address);
            }

            var greaterContext = new HomeAutomationSingleDeviceContext(context)
            {
                Device = device
            };

            while (true)
            {
                try
                {
                    Execture_HomeAutomationSingleDeviceDefinition(greaterContext);
                    return;
                }
                catch (HomeAutomationException exception)
                {
                    if (retries == 0)
                    {
                        throw;
                    }

                    interpreter.WriteEvent("retrying: " + exception.Message);

                    if (retries > 0)
                    {
                        retries--;
                    }
                }
            }
        }
コード例 #10
0
        protected override void Execute_HomeAutomationDefinition(HomeAutomationCommandContext context)
        {
            var interpreter = context.Interpreter;
            var scope = context.Scope;
            var networks = context.Networks;
            var retries = context.ReadParameter(RetriesParameterAttribute.Key).ToInteger();

            Device device = null;
            if (scope.Local.ContainsVariable("Device"))
            {
                var allDevices = networks.SelectMany(x => x.Devices);
                var address = context.ReadParameter("Device").ToVirtualAddress();
                device = allDevices.GetDevice(address);
            }

            var greaterContext = new HomeAutomationSingleDeviceContext(context)
            {
                Device = device
            };

            while (true)
            {
                try
                {
                    Execture_HomeAutomationSingleDeviceDefinition(greaterContext);
                    return;
                }
                catch (HomeAutomationException exception)
                {
                    if (retries == 0)
                    {
                        throw;
                    }

                    interpreter.WriteEvent("retrying: " + exception.Message);

                    if (retries > 0)
                    {
                        retries--;
                    }
                }
            }
        }
コード例 #11
0
ファイル: SetLed.cs プロジェクト: Mavtak/roomie
        protected override void Execture_HomeAutomationSingleDeviceDefinition(HomeAutomationSingleDeviceContext context)
        {
            var device = context.Device as PiEngineeringDevice;
            var ledString = context.ReadParameter("LED").Value;
            var statusString = context.ReadParameter("Status").Value;

            Led led;
            if (!Enum.TryParse(ledString, out led))
            {
                throw new RoomieRuntimeException("LED \"" + ledString + "\" is not valid");
            }

            LightStatus status;
            if (!Enum.TryParse(statusString, out status))
            {
                throw new RoomieRuntimeException("Status \"" + statusString + "\" is not valid");
            }

            device.SetLeds(led, status);
        }
コード例 #12
0
ファイル: SetButtonLight.cs プロジェクト: Mavtak/roomie
        protected override void Execture_HomeAutomationSingleDeviceDefinition(HomeAutomationSingleDeviceContext context)
        {
            var device = context.Device as PiEngineeringDevice;
            var bankString = context.ReadParameter("Color").Value;
            var button = context.ReadParameter("Button").Value;
            var statusString = context.ReadParameter("Status").Value;

            Bank bank;
            if (!Enum.TryParse(bankString, out bank))
            {
                throw new RoomieRuntimeException("Color \"" + bankString + "\" is not valid");
            }

            var column = (byte) (button[0] - 'A');
            var row = (byte) (button[1] - '1');

            LightStatus status;
            if (!Enum.TryParse(statusString, out status))
            {
                throw new RoomieRuntimeException("Status \"" + statusString + "\" is not valid");
            }

            device.SetButtonLight(bank, row, column, status);
        }
コード例 #13
0
 protected abstract void Execture_HomeAutomationSingleDeviceDefinition(HomeAutomationSingleDeviceContext context);
コード例 #14
0
 protected abstract void Execture_HomeAutomationSingleDeviceDefinition(HomeAutomationSingleDeviceContext context);
コード例 #15
0
ファイル: ReconnectDevice.cs プロジェクト: Mavtak/roomie
        protected override void Execture_HomeAutomationSingleDeviceDefinition(HomeAutomationSingleDeviceContext context)
        {
            var device = context.Device as PiEngineeringDevice;

            device.Reconnect();
        }