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);
        }
Exemple #2
0
        protected override void Execture_HomeAutomationSingleDeviceDefinition(HomeAutomationSingleDeviceContext context)
        {
            var device = context.Device as Q42HueDevice;
            var command = new LightCommand
            {
                Effect = Effect.ColorLoop,
            };

            device.SendCommand(command);
        }
        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;
        }
Exemple #4
0
        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");
        }
        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);
        }
Exemple #6
0
        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);
        }
        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());
        }
Exemple #8
0
        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());
        }
Exemple #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--;
                    }
                }
            }
        }
        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--;
                    }
                }
            }
        }
Exemple #11
0
        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);
        }
Exemple #12
0
        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);
        }
 protected abstract void Execture_HomeAutomationSingleDeviceDefinition(HomeAutomationSingleDeviceContext context);
Exemple #14
0
 protected abstract void Execture_HomeAutomationSingleDeviceDefinition(HomeAutomationSingleDeviceContext context);
Exemple #15
0
        protected override void Execture_HomeAutomationSingleDeviceDefinition(HomeAutomationSingleDeviceContext context)
        {
            var device = context.Device as PiEngineeringDevice;

            device.Reconnect();
        }