예제 #1
0
        public Response MultilevelSwitchSetPower(int id, int power)
        {
            var cache  = new InMemoryRepositoryModelCache();
            var device = _deviceRepository.Get(_user, id, cache);

            if (device == null)
            {
                return(RpcDeviceRepositoryHelpers.CreateNotFoundError());
            }

            device.MultilevelSwitch.SetPower(power);

            return(Response.Empty());
        }
예제 #2
0
        public Response TemperatureSensorPoll(int id)
        {
            var cache  = new InMemoryRepositoryModelCache();
            var device = _deviceRepository.Get(_user, id, cache);

            if (device == null)
            {
                return(RpcDeviceRepositoryHelpers.CreateNotFoundError());
            }

            device.TemperatureSensor.Poll();

            return(Response.Empty());
        }
예제 #3
0
        public Response ThermostatCoreSetMode(int id, string mode)
        {
            var parsedMode = mode.ToThermostatMode();
            var cache      = new InMemoryRepositoryModelCache();
            var device     = _deviceRepository.Get(_user, id, cache);

            if (device == null)
            {
                return(RpcDeviceRepositoryHelpers.CreateNotFoundError());
            }

            device.Thermostat.Core.SetMode(parsedMode);

            return(Response.Empty());
        }
예제 #4
0
        public Response ColorSwitchSetValue(int id, string color)
        {
            var parsedColor = color.ToColor();
            var cache       = new InMemoryRepositoryModelCache();
            var device      = _deviceRepository.Get(_user, id, cache);

            if (device == null)
            {
                return(RpcDeviceRepositoryHelpers.CreateNotFoundError());
            }

            device.ColorSwitch.SetValue(parsedColor);

            return(Response.Empty());
        }
예제 #5
0
        public Response BinarySwitchSetPower(int id, string power)
        {
            var parsedPower = power.ToToggleSwitchPower();
            var cache       = new InMemoryRepositoryModelCache();
            var device      = _deviceRepository.Get(_user, id, cache);

            if (device == null)
            {
                return(RpcDeviceRepositoryHelpers.CreateNotFoundError());
            }

            device.BinarySwitch.SetPower(parsedPower);

            return(Response.Empty());
        }
예제 #6
0
        public Response ThermostatSetpointsSetSetpoint(int id, string type, string temperature)
        {
            var parsedType        = type.ToSetpointType();
            var parsedTemperature = temperature.ToTemperature();
            var cache             = new InMemoryRepositoryModelCache();
            var device            = _deviceRepository.Get(_user, id, cache);

            if (device == null)
            {
                return(RpcDeviceRepositoryHelpers.CreateNotFoundError());
            }

            device.Thermostat.Setpoints.SetSetpoint(parsedType, parsedTemperature);

            return(Response.Empty());
        }