Beispiel #1
0
        public void Apply()
        {
            var hsrel5 = (HSREL5)_ccToolsBoardService.RegisterDevice(CCToolsDeviceType.HSRel5, InstalledDevice.ReadingRoomHSREL5.ToString(), 62);
            var input2 = _deviceService.GetDevice <HSPE16InputOnly>(InstalledDevice.Input2.ToString());

            var area = _areaService.RegisterArea(Room.ReadingRoom);

            _sensorFactory.RegisterWindow(area, ReadingRoom.Window, new PortBasedWindowAdapter(input2.GetInput(8))); // Tilt = input2.GetInput(9) -- currently broken!

            _sensorFactory.RegisterTemperatureSensor(area, ReadingRoom.TemperatureSensor,
                                                     new MqttBasedNumericSensorAdapter("sensors-bridge/temperature/5", _deviceMessageBrokerService, _logService));

            _sensorFactory.RegisterHumiditySensor(area, ReadingRoom.HumiditySensor,
                                                  new MqttBasedNumericSensorAdapter("sensors-bridge/humidity/5", _deviceMessageBrokerService, _logService));

            _actuatorFactory.RegisterLamp(area, ReadingRoom.LightCeilingMiddle, hsrel5[HSREL5Pin.GPIO0]);

            _actuatorFactory.RegisterRollerShutter(area, ReadingRoom.RollerShutter, hsrel5[HSREL5Pin.Relay4], hsrel5[HSREL5Pin.Relay3]);
            _sensorFactory.RegisterButton(area, ReadingRoom.RollerShutterButtonUp, input2.GetInput(12));
            _sensorFactory.RegisterButton(area, ReadingRoom.RollerShutterButtonDown, input2.GetInput(11));

            _actuatorFactory.RegisterSocket(area, ReadingRoom.SocketWindow, hsrel5[HSREL5Pin.Relay0]);
            _actuatorFactory.RegisterSocket(area, ReadingRoom.SocketWallLeft, hsrel5[HSREL5Pin.Relay1]);
            _actuatorFactory.RegisterSocket(area, ReadingRoom.SocketWallRight, hsrel5[HSREL5Pin.Relay2]);

            _sensorFactory.RegisterButton(area, ReadingRoom.Button, input2.GetInput(13));

            area.GetButton(ReadingRoom.Button).CreatePressedShortTrigger(_messageBroker).Attach(() => area.GetLamp(ReadingRoom.LightCeilingMiddle).TryTogglePowerState());

            _automationFactory.RegisterRollerShutterAutomation(area, ReadingRoom.RollerShutterAutomation)
            .WithRollerShutters(area.GetRollerShutter(ReadingRoom.RollerShutter));

            area.GetRollerShutter(ReadingRoom.RollerShutter)
            .ConnectWith(area.GetButton(ReadingRoom.RollerShutterButtonUp), area.GetButton(ReadingRoom.RollerShutterButtonDown), _messageBroker);
        }
Beispiel #2
0
        public void Apply()
        {
            var hsrel5 = _ccToolsBoardService.RegisterHSREL5(InstalledDevice.KitchenHSREL5, new I2CSlaveAddress(58));
            var hspe8  = _ccToolsBoardService.RegisterHSPE8OutputOnly(InstalledDevice.KitchenHSPE8, new I2CSlaveAddress(39));

            var input0            = _deviceService.GetDevice <HSPE16InputOnly>(InstalledDevice.Input0);
            var input1            = _deviceService.GetDevice <HSPE16InputOnly>(InstalledDevice.Input1);
            var input2            = _deviceService.GetDevice <HSPE16InputOnly>(InstalledDevice.Input2);
            var i2CHardwareBridge = _deviceService.GetDevice <I2CHardwareBridge>();

            const int SensorPin = 11;

            var room = _areaService.CreateArea(Room.Kitchen);

            _sensorFactory.RegisterWindow(room, Kitchen.Window, w => w.WithCenterCasement(input0.GetInput(6), input0.GetInput(7)));

            _sensorFactory.RegisterTemperatureSensor(room, Kitchen.TemperatureSensor,
                                                     i2CHardwareBridge.DHT22Accessor.GetTemperatureSensor(SensorPin));

            _sensorFactory.RegisterHumiditySensor(room, Kitchen.HumiditySensor,
                                                  i2CHardwareBridge.DHT22Accessor.GetHumiditySensor(SensorPin));

            _sensorFactory.RegisterMotionDetector(room, Kitchen.MotionDetector, input1.GetInput(8));

            _actuatorFactory.RegisterLamp(room, Kitchen.LightCeilingPassageOuter, hspe8.GetOutput(2).WithInvertedState());
            _actuatorFactory.RegisterLamp(room, Kitchen.LightCeilingMiddle, hsrel5.GetOutput(5).WithInvertedState());
            _actuatorFactory.RegisterLamp(room, Kitchen.LightCeilingWindow, hsrel5.GetOutput(6).WithInvertedState());
            _actuatorFactory.RegisterLamp(room, Kitchen.LightCeilingWall, hsrel5.GetOutput(7).WithInvertedState());
            _actuatorFactory.RegisterLamp(room, Kitchen.LightCeilingDoor, hspe8.GetOutput(0).WithInvertedState());
            _actuatorFactory.RegisterLamp(room, Kitchen.LightCeilingPassageInner, hspe8.GetOutput(1).WithInvertedState());

            _actuatorFactory.RegisterSocket(room, Kitchen.SocketWall, hsrel5.GetOutput(2));
            _actuatorFactory.RegisterRollerShutter(room, Kitchen.RollerShutter, hsrel5.GetOutput(4), hsrel5.GetOutput(3));
            _sensorFactory.RegisterButton(room, Kitchen.ButtonKitchenette, input1.GetInput(11));
            _sensorFactory.RegisterButton(room, Kitchen.ButtonPassage, input1.GetInput(9));
            _sensorFactory.RegisterRollerShutterButtons(room, Kitchen.RollerShutterButtonUp, input2.GetInput(15),
                                                        Kitchen.RollerShutterButtonDown, input2.GetInput(14));

            room.GetLamp(Kitchen.LightCeilingMiddle).ConnectToggleActionWith(room.GetButton(Kitchen.ButtonKitchenette));
            room.GetLamp(Kitchen.LightCeilingMiddle).ConnectToggleActionWith(room.GetButton(Kitchen.ButtonPassage));

            _automationFactory.RegisterRollerShutterAutomation(room, Kitchen.RollerShutterAutomation)
            .WithRollerShutters(room.GetRollerShutter(Kitchen.RollerShutter));

            room.GetRollerShutter(Kitchen.RollerShutter).ConnectWith(
                room.GetButton(Kitchen.RollerShutterButtonUp), room.GetButton(Kitchen.RollerShutterButtonDown));

            _actuatorFactory.RegisterLogicalActuator(room, Kitchen.CombinedAutomaticLights)
            .WithActuator(room.GetLamp(Kitchen.LightCeilingWall))
            .WithActuator(room.GetLamp(Kitchen.LightCeilingDoor))
            .WithActuator(room.GetLamp(Kitchen.LightCeilingWindow));

            _automationFactory.RegisterTurnOnAndOffAutomation(room, Kitchen.CombinedAutomaticLightsAutomation)
            .WithTrigger(room.GetMotionDetector(Kitchen.MotionDetector))
            .WithTarget(room.GetActuator(Kitchen.CombinedAutomaticLights))
            .WithEnabledAtNight();

            _synonymService.AddSynonymsForArea(Room.Kitchen, "Küche", "Kitchen");
        }
Beispiel #3
0
        public void Apply()
        {
            var hsrel8 = _ccToolsBoardService.RegisterHSREL8(InstalledDevice.LivingRoomHSREL8, new I2CSlaveAddress(18));
            var hsrel5 = _ccToolsBoardService.RegisterHSREL5(InstalledDevice.LivingRoomHSREL5, new I2CSlaveAddress(57));

            var input0            = _deviceService.GetDevice <HSPE16InputOnly>(InstalledDevice.Input0);
            var input1            = _deviceService.GetDevice <HSPE16InputOnly>(InstalledDevice.Input1);
            var i2CHardwareBridge = _deviceService.GetDevice <I2CHardwareBridge>();

            const int SensorPin = 12;

            var room = _areaService.CreateArea(Room.LivingRoom);

            _sensorFactory.RegisterWindow(room, LivingRoom.WindowLeft,
                                          w => w.WithLeftCasement(input0.GetInput(10), input0.GetInput(11)).WithRightCasement(input0.GetInput(9), input0.GetInput(8)));

            _sensorFactory.RegisterWindow(room, LivingRoom.WindowRight,
                                          w => w.WithLeftCasement(input1.GetInput(14), input1.GetInput(15)).WithRightCasement(input1.GetInput(13), input1.GetInput(12)));

            _sensorFactory.RegisterTemperatureSensor(room, LivingRoom.TemperatureSensor,
                                                     i2CHardwareBridge.DHT22Accessor.GetTemperatureSensor(SensorPin));

            _sensorFactory.RegisterHumiditySensor(room, LivingRoom.HumiditySensor,
                                                  i2CHardwareBridge.DHT22Accessor.GetHumiditySensor(SensorPin));

            _actuatorFactory.RegisterLamp(room, LivingRoom.LampCouch, hsrel8.GetOutput(8).WithInvertedState());
            _actuatorFactory.RegisterLamp(room, LivingRoom.LampDiningTable, hsrel8.GetOutput(9).WithInvertedState());

            _actuatorFactory.RegisterSocket(room, LivingRoom.SocketWindowLeftLower, hsrel8.GetOutput(1));
            _actuatorFactory.RegisterSocket(room, LivingRoom.SocketWindowMiddleLower, hsrel8.GetOutput(2));
            _actuatorFactory.RegisterSocket(room, LivingRoom.SocketWindowRightLower, hsrel8.GetOutput(3));
            _actuatorFactory.RegisterSocket(room, LivingRoom.SocketWindowLeftUpper, hsrel8.GetOutput(5));
            _actuatorFactory.RegisterSocket(room, LivingRoom.SocketWindowRightUpper, hsrel8.GetOutput(7));
            _actuatorFactory.RegisterSocket(room, LivingRoom.SocketWallRightEdgeRight, hsrel8.GetOutput(4));
            _actuatorFactory.RegisterSocket(room, LivingRoom.SocketWallLeftEdgeLeft, hsrel8.GetOutput(0));

            _sensorFactory.RegisterButton(room, LivingRoom.ButtonUpper, input0.GetInput(15));
            _sensorFactory.RegisterButton(room, LivingRoom.ButtonMiddle, input0.GetInput(14));
            _sensorFactory.RegisterButton(room, LivingRoom.ButtonLower, input0.GetInput(13));
            _sensorFactory.RegisterButton(room, LivingRoom.ButtonPassage, input1.GetInput(10));

            room.GetLamp(LivingRoom.LampDiningTable)
            .ConnectToggleActionWith(room.GetButton(LivingRoom.ButtonUpper))
            .ConnectToggleActionWith(room.GetButton(LivingRoom.ButtonPassage));

            room.GetLamp(LivingRoom.LampCouch).
            ConnectToggleActionWith(room.GetButton(LivingRoom.ButtonMiddle));

            room.GetSocket(LivingRoom.SocketWallRightEdgeRight).
            ConnectToggleActionWith(room.GetButton(LivingRoom.ButtonLower));

            _synonymService.AddSynonymsForArea(Room.LivingRoom, "Wohnzimmer", "LivingRoom");
        }
        public void Apply()
        {
            var hsrel8 = _ccToolsBoardService.RegisterHSREL8(InstalledDevice.LivingRoomHSREL8.ToString(), new I2CSlaveAddress(18));
            var hsrel5 = _ccToolsBoardService.RegisterHSREL5(InstalledDevice.LivingRoomHSREL5.ToString(), new I2CSlaveAddress(57));

            var input0            = _deviceService.GetDevice <HSPE16InputOnly>(InstalledDevice.Input0.ToString());
            var input1            = _deviceService.GetDevice <HSPE16InputOnly>(InstalledDevice.Input1.ToString());
            var i2CHardwareBridge = _deviceService.GetDevice <I2CHardwareBridge>();

            const int SensorPin = 12;

            var area = _areaService.RegisterArea(Room.LivingRoom);

            _sensorFactory.RegisterWindow(area, LivingRoom.WindowLeftL, input0.GetInput(10), input0.GetInput(11));
            _sensorFactory.RegisterWindow(area, LivingRoom.WindowLeftR, input0.GetInput(9), input0.GetInput(8));
            _sensorFactory.RegisterWindow(area, LivingRoom.WindowRightL, input1.GetInput(14), input1.GetInput(15));
            _sensorFactory.RegisterWindow(area, LivingRoom.WindowRightR, input1.GetInput(13), input1.GetInput(12));

            _sensorFactory.RegisterTemperatureSensor(area, LivingRoom.TemperatureSensor,
                                                     i2CHardwareBridge.DHT22Accessor.GetTemperatureSensor(SensorPin));

            _sensorFactory.RegisterHumiditySensor(area, LivingRoom.HumiditySensor,
                                                  i2CHardwareBridge.DHT22Accessor.GetHumiditySensor(SensorPin));

            _actuatorFactory.RegisterLamp(area, LivingRoom.LampCouch, hsrel8.GetOutput(8).WithInvertedState());
            _actuatorFactory.RegisterLamp(area, LivingRoom.LampDiningTable, hsrel8.GetOutput(9).WithInvertedState());

            _actuatorFactory.RegisterSocket(area, LivingRoom.SocketWindowLeftLower, hsrel8.GetOutput(1));
            _actuatorFactory.RegisterSocket(area, LivingRoom.SocketWindowMiddleLower, hsrel8.GetOutput(2));
            _actuatorFactory.RegisterSocket(area, LivingRoom.SocketWindowRightLower, hsrel8.GetOutput(3));
            _actuatorFactory.RegisterSocket(area, LivingRoom.SocketWindowLeftUpper, hsrel8.GetOutput(5));
            _actuatorFactory.RegisterSocket(area, LivingRoom.SocketWindowRightUpper, hsrel8.GetOutput(7));
            _actuatorFactory.RegisterSocket(area, LivingRoom.SocketWallRightEdgeRight, hsrel8.GetOutput(4));
            _actuatorFactory.RegisterSocket(area, LivingRoom.SocketWallLeftEdgeLeft, hsrel8.GetOutput(0));

            _sensorFactory.RegisterButton(area, LivingRoom.ButtonUpper, input0.GetInput(15));
            _sensorFactory.RegisterButton(area, LivingRoom.ButtonMiddle, input0.GetInput(14));
            _sensorFactory.RegisterButton(area, LivingRoom.ButtonLower, input0.GetInput(13));
            _sensorFactory.RegisterButton(area, LivingRoom.ButtonPassage, input1.GetInput(10));

            area.GetButton(LivingRoom.ButtonUpper).PressedShortTrigger.Attach(
                () => area.GetComponent(LivingRoom.LampDiningTable).TryTogglePowerState());

            area.GetButton(LivingRoom.ButtonMiddle).PressedShortTrigger.Attach(() =>
                                                                               area.GetComponent(LivingRoom.LampCouch).TryTogglePowerState());

            area.GetButton(LivingRoom.ButtonLower).PressedShortTrigger.Attach(() =>
                                                                              area.GetComponent(LivingRoom.SocketWallRightEdgeRight).TryTogglePowerState());

            area.GetButton(LivingRoom.ButtonPassage).PressedShortTrigger.Attach(
                () => area.GetComponent(LivingRoom.LampDiningTable).TryTogglePowerState());
        }
Beispiel #5
0
        public void Apply()
        {
            var hsrel8            = _ccToolsBoardService.RegisterHSREL8(InstalledDevice.OfficeHSREL8, new I2CSlaveAddress(20));
            var hspe8             = _ccToolsBoardService.RegisterHSPE8OutputOnly(InstalledDevice.UpperFloorAndOfficeHSPE8, new I2CSlaveAddress(37));
            var input4            = _deviceService.GetDevice <HSPE16InputOnly>(InstalledDevice.Input4);
            var input5            = _deviceService.GetDevice <HSPE16InputOnly>(InstalledDevice.Input5);
            var i2CHardwareBridge = _deviceService.GetDevice <I2CHardwareBridge>();

            const int SensorPin = 2;

            var room = _areaService.CreateArea(Room.Office);

            _sensorFactory.RegisterWindow(room, Office.WindowLeft,
                                          w => w.WithLeftCasement(input4.GetInput(11)).WithRightCasement(input4.GetInput(12), input4.GetInput(10)));

            _sensorFactory.RegisterWindow(room, Office.WindowRight,
                                          w => w.WithLeftCasement(input4.GetInput(8)).WithRightCasement(input4.GetInput(9), input5.GetInput(8)));

            _sensorFactory.RegisterTemperatureSensor(room, Office.TemperatureSensor,
                                                     i2CHardwareBridge.DHT22Accessor.GetTemperatureSensor(SensorPin));

            _sensorFactory.RegisterHumiditySensor(room, Office.HumiditySensor,
                                                  i2CHardwareBridge.DHT22Accessor.GetHumiditySensor(SensorPin));

            _sensorFactory.RegisterMotionDetector(room, Office.MotionDetector, input4.GetInput(13));

            _actuatorFactory.RegisterSocket(room, Office.SocketFrontLeft, hsrel8.GetOutput(0));
            _actuatorFactory.RegisterSocket(room, Office.SocketFrontRight, hsrel8.GetOutput(6));
            _actuatorFactory.RegisterSocket(room, Office.SocketWindowLeft, hsrel8.GetOutput(10).WithInvertedState());
            _actuatorFactory.RegisterSocket(room, Office.SocketWindowRight, hsrel8.GetOutput(11).WithInvertedState());
            _actuatorFactory.RegisterSocket(room, Office.SocketRearLeftEdge, hsrel8.GetOutput(7));
            _actuatorFactory.RegisterSocket(room, Office.SocketRearLeft, hsrel8.GetOutput(2));
            _actuatorFactory.RegisterSocket(room, Office.SocketRearRight, hsrel8.GetOutput(1));
            _actuatorFactory.RegisterSocket(room, Office.RemoteSocketDesk, _remoteSocketService.GetOutput(0));

            _sensorFactory.RegisterButton(room, Office.ButtonUpperLeft, input5.GetInput(0));
            _sensorFactory.RegisterButton(room, Office.ButtonLowerLeft, input5.GetInput(1));
            _sensorFactory.RegisterButton(room, Office.ButtonLowerRight, input4.GetInput(14));
            _sensorFactory.RegisterButton(room, Office.ButtonUpperRight, input4.GetInput(15));

            _actuatorFactory.RegisterStateMachine(room, Office.CombinedCeilingLights, (s, a) => SetupLight(s, hsrel8, hspe8, a));

            room.GetButton(Office.ButtonUpperLeft).GetPressedLongTrigger().Attach(() =>
            {
                room.GetStateMachine(Office.CombinedCeilingLights).TryTurnOff();
                room.GetSocket(Office.SocketRearLeftEdge).TryTurnOff();
                room.GetSocket(Office.SocketRearLeft).TryTurnOff();
                room.GetSocket(Office.SocketFrontLeft).TryTurnOff();
            });
        }
Beispiel #6
0
        public void Apply()
        {
            var hsrel8 = (HSREL8)_ccToolsBoardService.RegisterDevice(CCToolsDeviceType.HSRel8, InstalledDevice.LivingRoomHSREL8.ToString(), 18);
            ////var hsrel5 = (HSREL5)_ccToolsBoardService.RegisterDevice(CCToolsDeviceType.HSRel5, InstalledDevice.LivingRoomHSREL5.ToString(), 57);

            var input0 = _deviceService.GetDevice <HSPE16InputOnly>(InstalledDevice.Input0.ToString());
            var input1 = _deviceService.GetDevice <HSPE16InputOnly>(InstalledDevice.Input1.ToString());

            var area = _areaService.RegisterArea(Room.LivingRoom);

            _sensorFactory.RegisterWindow(area, LivingRoom.WindowLeftL, input0.GetInput(10), input0.GetInput(11));
            _sensorFactory.RegisterWindow(area, LivingRoom.WindowLeftR, input0.GetInput(9), input0.GetInput(8));
            _sensorFactory.RegisterWindow(area, LivingRoom.WindowRightL, input1.GetInput(14), input1.GetInput(15));
            _sensorFactory.RegisterWindow(area, LivingRoom.WindowRightR, input1.GetInput(13), input1.GetInput(12));

            _sensorFactory.RegisterTemperatureSensor(area, LivingRoom.TemperatureSensor,
                                                     new MqttBasedNumericSensorAdapter("sensors-bridge/temperature/0", _deviceMessageBrokerService, _logService));

            _sensorFactory.RegisterHumiditySensor(area, LivingRoom.HumiditySensor,
                                                  new MqttBasedNumericSensorAdapter("sensors-bridge/humidity/0", _deviceMessageBrokerService, _logService));

            _actuatorFactory.RegisterLamp(area, LivingRoom.LampCouch, hsrel8.GetOutput(8).WithInvertedState());
            _actuatorFactory.RegisterLamp(area, LivingRoom.LampDiningTable, hsrel8.GetOutput(9).WithInvertedState());

            _actuatorFactory.RegisterSocket(area, LivingRoom.SocketWindowLeftLower, hsrel8.GetOutput(1));
            _actuatorFactory.RegisterSocket(area, LivingRoom.SocketWindowMiddleLower, hsrel8.GetOutput(2));
            _actuatorFactory.RegisterSocket(area, LivingRoom.SocketWindowRightLower, hsrel8.GetOutput(3));
            _actuatorFactory.RegisterSocket(area, LivingRoom.SocketWindowLeftUpper, hsrel8.GetOutput(5));
            _actuatorFactory.RegisterSocket(area, LivingRoom.SocketWindowRightUpper, hsrel8.GetOutput(7));
            _actuatorFactory.RegisterSocket(area, LivingRoom.SocketWallRightEdgeRight, hsrel8.GetOutput(4));
            _actuatorFactory.RegisterSocket(area, LivingRoom.SocketWallLeftEdgeLeft, hsrel8.GetOutput(0));

            _sensorFactory.RegisterButton(area, LivingRoom.ButtonUpper, input0.GetInput(15));
            _sensorFactory.RegisterButton(area, LivingRoom.ButtonMiddle, input0.GetInput(14));
            _sensorFactory.RegisterButton(area, LivingRoom.ButtonLower, input0.GetInput(13));
            _sensorFactory.RegisterButton(area, LivingRoom.ButtonPassage, input1.GetInput(10));

            area.GetButton(LivingRoom.ButtonUpper).CreatePressedShortTrigger(_messageBrokerService).Attach(
                () => area.GetComponent(LivingRoom.LampDiningTable).TryTogglePowerState());

            area.GetButton(LivingRoom.ButtonMiddle).CreatePressedShortTrigger(_messageBrokerService).Attach(() =>
                                                                                                            area.GetComponent(LivingRoom.LampCouch).TryTogglePowerState());

            area.GetButton(LivingRoom.ButtonLower).CreatePressedShortTrigger(_messageBrokerService).Attach(() =>
                                                                                                           area.GetComponent(LivingRoom.SocketWallRightEdgeRight).TryTogglePowerState());

            area.GetButton(LivingRoom.ButtonPassage).CreatePressedShortTrigger(_messageBrokerService).Attach(
                () => area.GetComponent(LivingRoom.LampDiningTable).TryTogglePowerState());
        }
        public void Apply()
        {
            var hspe16_FloorAndLowerBathroom = _deviceService.GetDevice <HSPE16OutputOnly>(InstalledDevice.LowerFloorAndLowerBathroomHSPE16.ToString());
            var input3            = _deviceService.GetDevice <HSPE16InputOnly>(InstalledDevice.Input3.ToString());
            var i2CHardwareBridge = _deviceService.GetDevice <I2CHardwareBridge>();

            const int SensorPin = 3;

            var area = _areaService.RegisterArea(Room.LowerBathroom);

            _sensorFactory.RegisterWindow(area, LowerBathroom.Window, new PortBasedWindowAdapter(input3.GetInput(13), input3.GetInput(14)));

            _sensorFactory.RegisterTemperatureSensor(area, LowerBathroom.TemperatureSensor,
                                                     i2CHardwareBridge.DHT22Accessor.GetTemperatureSensor(SensorPin));

            _sensorFactory.RegisterHumiditySensor(area, LowerBathroom.HumiditySensor,
                                                  i2CHardwareBridge.DHT22Accessor.GetHumiditySensor(SensorPin));

            _sensorFactory.RegisterMotionDetector(area, LowerBathroom.MotionDetector, input3.GetInput(15));

            var bathModeButton = _sensorFactory.RegisterVirtualButton(area, LowerBathroom.StartBathmodeButton);

            bathModeButton.PressedShortTrigger.Attach(() => StartBathode(area));

            _actuatorFactory.RegisterLamp(area, LowerBathroom.LightCeilingDoor,
                                          hspe16_FloorAndLowerBathroom.GetOutput(0).WithInvertedState());

            _actuatorFactory.RegisterLamp(area, LowerBathroom.LightCeilingMiddle,
                                          hspe16_FloorAndLowerBathroom.GetOutput(1).WithInvertedState());

            _actuatorFactory.RegisterLamp(area, LowerBathroom.LightCeilingWindow,
                                          hspe16_FloorAndLowerBathroom.GetOutput(2).WithInvertedState());

            _actuatorFactory.RegisterLamp(area, LowerBathroom.LampMirror,
                                          hspe16_FloorAndLowerBathroom.GetOutput(4).WithInvertedState());

            _actuatorFactory.RegisterLogicalComponent(area, LowerBathroom.CombinedLights)
            .WithComponent(area.GetLamp(LowerBathroom.LightCeilingDoor))
            .WithComponent(area.GetLamp(LowerBathroom.LightCeilingMiddle))
            .WithComponent(area.GetLamp(LowerBathroom.LightCeilingWindow))
            .WithComponent(area.GetLamp(LowerBathroom.LampMirror));

            _automationFactory.RegisterTurnOnAndOffAutomation(area, LowerBathroom.CombinedLightsAutomation)
            .WithTrigger(area.GetMotionDetector(LowerBathroom.MotionDetector))
            .WithTarget(area.GetComponent(LowerBathroom.CombinedLights));
        }
Beispiel #8
0
        public void Apply()
        {
            var hspe16_FloorAndLowerBathroom = _deviceService.GetDevice <HSPE16OutputOnly>(InstalledDevice.LowerFloorAndLowerBathroomHSPE16);
            var input3            = _deviceService.GetDevice <HSPE16InputOnly>(InstalledDevice.Input3);
            var i2CHardwareBridge = _deviceService.GetDevice <I2CHardwareBridge>();

            const int SensorPin = 3;

            var room = _areaService.CreateArea(Room.LowerBathroom);

            _sensorFactory.RegisterWindow(room, LowerBathroom.Window, w => w.WithCenterCasement(input3.GetInput(13), input3.GetInput(14)));

            _sensorFactory.RegisterTemperatureSensor(room, LowerBathroom.TemperatureSensor,
                                                     i2CHardwareBridge.DHT22Accessor.GetTemperatureSensor(SensorPin));

            _sensorFactory.RegisterHumiditySensor(room, LowerBathroom.HumiditySensor,
                                                  i2CHardwareBridge.DHT22Accessor.GetHumiditySensor(SensorPin));

            _sensorFactory.RegisterMotionDetector(room, LowerBathroom.MotionDetector, input3.GetInput(15));

            _sensorFactory.RegisterVirtualButton(room, LowerBathroom.StartBathmodeButton, b => b.GetPressedShortlyTrigger().Attach(() => StartBathode(room)));

            _actuatorFactory.RegisterLamp(room, LowerBathroom.LightCeilingDoor,
                                          hspe16_FloorAndLowerBathroom.GetOutput(0).WithInvertedState());

            _actuatorFactory.RegisterLamp(room, LowerBathroom.LightCeilingMiddle,
                                          hspe16_FloorAndLowerBathroom.GetOutput(1).WithInvertedState());

            _actuatorFactory.RegisterLamp(room, LowerBathroom.LightCeilingWindow,
                                          hspe16_FloorAndLowerBathroom.GetOutput(2).WithInvertedState());

            _actuatorFactory.RegisterLamp(room, LowerBathroom.LampMirror,
                                          hspe16_FloorAndLowerBathroom.GetOutput(4).WithInvertedState());

            _actuatorFactory.RegisterLogicalActuator(room, LowerBathroom.CombinedLights)
            .WithActuator(room.GetLamp(LowerBathroom.LightCeilingDoor))
            .WithActuator(room.GetLamp(LowerBathroom.LightCeilingMiddle))
            .WithActuator(room.GetLamp(LowerBathroom.LightCeilingWindow))
            .WithActuator(room.GetLamp(LowerBathroom.LampMirror));

            _automationFactory.RegisterTurnOnAndOffAutomation(room, LowerBathroom.CombinedLightsAutomation)
            .WithTrigger(room.GetMotionDetector(LowerBathroom.MotionDetector))
            .WithTarget(room.GetActuator(LowerBathroom.CombinedLights));

            _synonymService.AddSynonymsForArea(Room.LowerBathroom, "BadUnten", "LowerBathroom");
        }
        public void Apply()
        {
            var hspe16_FloorAndLowerBathroom = _deviceService.GetDevice <HSPE16OutputOnly>(InstalledDevice.LowerFloorAndLowerBathroomHSPE16.ToString());
            var input3 = _deviceService.GetDevice <HSPE16InputOnly>(InstalledDevice.Input3.ToString());

            var area = _areaService.RegisterArea(Room.LowerBathroom);

            _sensorFactory.RegisterWindow(area, LowerBathroom.Window, new PortBasedWindowAdapter(input3.GetInput(13), input3.GetInput(14)));

            _sensorFactory.RegisterTemperatureSensor(area, LowerBathroom.TemperatureSensor,
                                                     new MqttBasedNumericSensorAdapter("sensors-bridge/temperature/4", _deviceMessageBrokerService, _logService));

            _sensorFactory.RegisterHumiditySensor(area, LowerBathroom.HumiditySensor,
                                                  new MqttBasedNumericSensorAdapter("sensors-bridge/humidity/4", _deviceMessageBrokerService, _logService));

            _sensorFactory.RegisterMotionDetector(area, LowerBathroom.MotionDetector, input3.GetInput(15));

            var bathModeButton = _sensorFactory.RegisterVirtualButton(area, LowerBathroom.StartBathmodeButton);

            bathModeButton.CreatePressedShortTrigger(_messageBroker).Attach(() => StartBathode(area));

            _actuatorFactory.RegisterLamp(area, LowerBathroom.LightCeilingDoor,
                                          hspe16_FloorAndLowerBathroom.GetOutput(0).WithInvertedState());

            _actuatorFactory.RegisterLamp(area, LowerBathroom.LightCeilingMiddle,
                                          hspe16_FloorAndLowerBathroom.GetOutput(1).WithInvertedState());

            _actuatorFactory.RegisterLamp(area, LowerBathroom.LightCeilingWindow,
                                          hspe16_FloorAndLowerBathroom.GetOutput(2).WithInvertedState());

            _actuatorFactory.RegisterLamp(area, LowerBathroom.LampMirror,
                                          hspe16_FloorAndLowerBathroom.GetOutput(4).WithInvertedState());

            _actuatorFactory.RegisterLogicalComponent(area, LowerBathroom.CombinedLights)
            .WithComponent(area.GetLamp(LowerBathroom.LightCeilingDoor))
            .WithComponent(area.GetLamp(LowerBathroom.LightCeilingMiddle))
            .WithComponent(area.GetLamp(LowerBathroom.LightCeilingWindow))
            .WithComponent(area.GetLamp(LowerBathroom.LampMirror));

            _automationFactory.RegisterTurnOnAndOffAutomation(area, LowerBathroom.CombinedLightsAutomation)
            .WithTrigger(area.GetMotionDetector(LowerBathroom.MotionDetector))
            .WithTarget(area.GetComponent(LowerBathroom.CombinedLights));
        }
        public void Apply()
        {
            var hsrel5            = _ccToolsBoardService.RegisterHSREL5(InstalledDevice.UpperBathroomHSREL5, new I2CSlaveAddress(61));
            var input5            = _deviceService.GetDevice <HSPE16InputOnly>(InstalledDevice.Input5);
            var i2CHardwareBridge = _deviceService.GetDevice <I2CHardwareBridge>();

            const int SensorPin = 4;

            var room = _areaService.CreateArea(Room.UpperBathroom);

            _actuatorFactory.RegisterStateMachine(room, UpperBathroom.Fan, (s, r) => SetupFan(s, hsrel5));

            _sensorFactory.RegisterTemperatureSensor(room, UpperBathroom.TemperatureSensor,
                                                     i2CHardwareBridge.DHT22Accessor.GetTemperatureSensor(SensorPin));

            _sensorFactory.RegisterHumiditySensor(room, UpperBathroom.HumiditySensor,
                                                  i2CHardwareBridge.DHT22Accessor.GetHumiditySensor(SensorPin));

            _sensorFactory.RegisterMotionDetector(room, UpperBathroom.MotionDetector, input5.GetInput(15));

            _actuatorFactory.RegisterLamp(room, UpperBathroom.LightCeilingDoor, hsrel5.GetOutput(0));
            _actuatorFactory.RegisterLamp(room, UpperBathroom.LightCeilingEdge, hsrel5.GetOutput(1));
            _actuatorFactory.RegisterLamp(room, UpperBathroom.LightCeilingMirrorCabinet, hsrel5.GetOutput(2));
            _actuatorFactory.RegisterLamp(room, UpperBathroom.LampMirrorCabinet, hsrel5.GetOutput(3));

            var combinedLights =
                _actuatorFactory.RegisterLogicalActuator(room, UpperBathroom.CombinedCeilingLights)
                .WithActuator(room.GetLamp(UpperBathroom.LightCeilingDoor))
                .WithActuator(room.GetLamp(UpperBathroom.LightCeilingEdge))
                .WithActuator(room.GetLamp(UpperBathroom.LightCeilingMirrorCabinet))
                .WithActuator(room.GetLamp(UpperBathroom.LampMirrorCabinet));

            _automationFactory.RegisterTurnOnAndOffAutomation(room, UpperBathroom.CombinedCeilingLightsAutomation)
            .WithTrigger(room.GetMotionDetector(UpperBathroom.MotionDetector))
            .WithTarget(combinedLights);

            new BathroomFanAutomation(AutomationIdGenerator.Generate(room, UpperBathroom.FanAutomation), _schedulerService, _settingsService)
            .WithTrigger(room.GetMotionDetector(UpperBathroom.MotionDetector))
            .WithActuator(room.GetStateMachine(UpperBathroom.Fan));

            _synonymService.AddSynonymsForArea(Room.UpperBathroom, "BadOben", "UpperBathroom");
        }
Beispiel #11
0
        public void Apply()
        {
            var hsrel5            = _ccToolsBoardService.RegisterHSREL5(InstalledDevice.ReadingRoomHSREL5, new I2CSlaveAddress(62));
            var input2            = _deviceService.GetDevice <HSPE16InputOnly>(InstalledDevice.Input2);
            var i2CHardwareBridge = _deviceService.GetDevice <I2CHardwareBridge>();

            const int SensorPin = 9;

            var room = _areaService.CreateArea(Room.ReadingRoom);

            _sensorFactory.RegisterWindow(room, ReadingRoom.Window, w => w.WithCenterCasement(input2.GetInput(8))); // Tilt = input2.GetInput(9) -- currently broken!

            _sensorFactory.RegisterTemperatureSensor(room, ReadingRoom.TemperatureSensor,
                                                     i2CHardwareBridge.DHT22Accessor.GetTemperatureSensor(SensorPin));

            _sensorFactory.RegisterHumiditySensor(room, ReadingRoom.HumiditySensor,
                                                  i2CHardwareBridge.DHT22Accessor.GetHumiditySensor(SensorPin));

            _actuatorFactory.RegisterLamp(room, ReadingRoom.LightCeilingMiddle, hsrel5[HSREL5Pin.GPIO0]);

            _actuatorFactory.RegisterRollerShutter(room, ReadingRoom.RollerShutter, hsrel5[HSREL5Pin.Relay4], hsrel5[HSREL5Pin.Relay3]);
            _sensorFactory.RegisterRollerShutterButtons(room, ReadingRoom.RollerShutterButtonUp, input2.GetInput(12),
                                                        ReadingRoom.RollerShutterButtonDown, input2.GetInput(11));

            _actuatorFactory.RegisterSocket(room, ReadingRoom.SocketWindow, hsrel5[HSREL5Pin.Relay0]);
            _actuatorFactory.RegisterSocket(room, ReadingRoom.SocketWallLeft, hsrel5[HSREL5Pin.Relay1]);
            _actuatorFactory.RegisterSocket(room, ReadingRoom.SocketWallRight, hsrel5[HSREL5Pin.Relay2]);

            _sensorFactory.RegisterButton(room, ReadingRoom.Button, input2.GetInput(13));

            room.GetLamp(ReadingRoom.LightCeilingMiddle).ConnectToggleActionWith(room.GetButton(ReadingRoom.Button));

            _automationFactory.RegisterRollerShutterAutomation(room, ReadingRoom.RollerShutterAutomation)
            .WithRollerShutters(room.GetRollerShutter(ReadingRoom.RollerShutter));

            room.GetRollerShutter(ReadingRoom.RollerShutter)
            .ConnectWith(room.GetButton(ReadingRoom.RollerShutterButtonUp), room.GetButton(ReadingRoom.RollerShutterButtonDown));

            _synonymService.AddSynonymsForArea(Room.ReadingRoom, "Lesezimmer", "Gästezimmer", "ReadingRoom");
        }
        public void Apply()
        {
            var hsrel5            = _ccToolsBoardService.RegisterHSREL5(InstalledDevice.ReadingRoomHSREL5.ToString(), new I2CSlaveAddress(62));
            var input2            = _deviceService.GetDevice <HSPE16InputOnly>(InstalledDevice.Input2.ToString());
            var i2CHardwareBridge = _deviceService.GetDevice <I2CHardwareBridge>();

            const int SensorPin = 9;

            var area = _areaService.RegisterArea(Room.ReadingRoom);

            _sensorFactory.RegisterWindow(area, ReadingRoom.Window, new PortBasedWindowAdapter(input2.GetInput(8))); // Tilt = input2.GetInput(9) -- currently broken!

            _sensorFactory.RegisterTemperatureSensor(area, ReadingRoom.TemperatureSensor,
                                                     i2CHardwareBridge.DHT22Accessor.GetTemperatureSensor(SensorPin));

            _sensorFactory.RegisterHumiditySensor(area, ReadingRoom.HumiditySensor,
                                                  i2CHardwareBridge.DHT22Accessor.GetHumiditySensor(SensorPin));

            _actuatorFactory.RegisterLamp(area, ReadingRoom.LightCeilingMiddle, hsrel5[HSREL5Pin.GPIO0]);

            _actuatorFactory.RegisterRollerShutter(area, ReadingRoom.RollerShutter, hsrel5[HSREL5Pin.Relay4], hsrel5[HSREL5Pin.Relay3]);
            _sensorFactory.RegisterRollerShutterButtons(area, ReadingRoom.RollerShutterButtonUp, input2.GetInput(12),
                                                        ReadingRoom.RollerShutterButtonDown, input2.GetInput(11));

            _actuatorFactory.RegisterSocket(area, ReadingRoom.SocketWindow, hsrel5[HSREL5Pin.Relay0]);
            _actuatorFactory.RegisterSocket(area, ReadingRoom.SocketWallLeft, hsrel5[HSREL5Pin.Relay1]);
            _actuatorFactory.RegisterSocket(area, ReadingRoom.SocketWallRight, hsrel5[HSREL5Pin.Relay2]);

            _sensorFactory.RegisterButton(area, ReadingRoom.Button, input2.GetInput(13));

            area.GetButton(ReadingRoom.Button).PressedShortTrigger.Attach(() => area.GetLamp(ReadingRoom.LightCeilingMiddle).TryTogglePowerState());

            _automationFactory.RegisterRollerShutterAutomation(area, ReadingRoom.RollerShutterAutomation)
            .WithRollerShutters(area.GetRollerShutter(ReadingRoom.RollerShutter));

            area.GetRollerShutter(ReadingRoom.RollerShutter)
            .ConnectWith(area.GetButton(ReadingRoom.RollerShutterButtonUp), area.GetButton(ReadingRoom.RollerShutterButtonDown));
        }
Beispiel #13
0
        public void Apply()
        {
            var hsrel5            = (HSREL5)_ccToolsBoardService.RegisterDevice(CCToolsDeviceType.HSRel5, InstalledDevice.ChildrensRoomHSREL5.ToString(), 63);
            var input0            = _deviceService.GetDevice <HSPE16InputOnly>(InstalledDevice.Input0.ToString());
            var i2CHardwareBridge = _deviceService.GetDevice <I2CHardwareBridge>();

            const int SensorPin = 7;

            var area = _areaService.RegisterArea(Room.ChildrensRoom);

            _sensorFactory.RegisterWindow(area, ChildrensRoom.Window, new PortBasedWindowAdapter(input0.GetInput(5), input0.GetInput(4)));

            _sensorFactory.RegisterTemperatureSensor(area, ChildrensRoom.TemperatureSensor,
                                                     i2CHardwareBridge.DHT22Accessor.GetTemperatureSensor(SensorPin));

            _sensorFactory.RegisterHumiditySensor(area, ChildrensRoom.HumiditySensor,
                                                  i2CHardwareBridge.DHT22Accessor.GetHumiditySensor(SensorPin));

            _actuatorFactory.RegisterSocket(area, ChildrensRoom.SocketWindow, hsrel5[HSREL5Pin.Relay0]);
            _actuatorFactory.RegisterSocket(area, ChildrensRoom.SocketWallLeft, hsrel5[HSREL5Pin.Relay1]);
            _actuatorFactory.RegisterSocket(area, ChildrensRoom.SocketWallRight, hsrel5[HSREL5Pin.Relay2]);

            _actuatorFactory.RegisterLamp(area, ChildrensRoom.LightCeilingMiddle, hsrel5[HSREL5Pin.GPIO0]);

            _sensorFactory.RegisterButton(area, ChildrensRoom.Button, input0.GetInput(0));

            _actuatorFactory.RegisterRollerShutter(area, ChildrensRoom.RollerShutter, hsrel5[HSREL5Pin.Relay4], hsrel5[HSREL5Pin.Relay3]);
            _sensorFactory.RegisterButton(area, ChildrensRoom.RollerShutterButtonUp, input0.GetInput(1));
            _sensorFactory.RegisterButton(area, ChildrensRoom.RollerShutterButtonDown, input0.GetInput(2));

            area.GetButton(ChildrensRoom.Button).CreatePressedShortTrigger(_messageBroker).Attach(() => area.GetLamp(ChildrensRoom.LightCeilingMiddle).TryTogglePowerState());

            _automationFactory.RegisterRollerShutterAutomation(area, ChildrensRoom.RollerShutterAutomation)
            .WithRollerShutters(area.GetRollerShutter(ChildrensRoom.RollerShutter));

            area.GetRollerShutter(ChildrensRoom.RollerShutter)
            .ConnectWith(area.GetButton(ChildrensRoom.RollerShutterButtonUp), area.GetButton(ChildrensRoom.RollerShutterButtonDown), _messageBroker);
        }
Beispiel #14
0
        public void Apply()
        {
            var hsrel5Stairway              = _ccToolsBoardService.RegisterHSREL5(InstalledDevice.StairwayHSREL5.ToString(), new I2CSlaveAddress(60));
            var hspe8UpperFloor             = _deviceService.GetDevice <HSPE8OutputOnly>(InstalledDevice.UpperFloorAndOfficeHSPE8.ToString());
            var hspe16FloorAndLowerBathroom = _ccToolsBoardService.RegisterHSPE16OutputOnly(InstalledDevice.LowerFloorAndLowerBathroomHSPE16.ToString(), new I2CSlaveAddress(17));

            var input1            = _deviceService.GetDevice <HSPE16InputOnly>(InstalledDevice.Input1.ToString());
            var input2            = _deviceService.GetDevice <HSPE16InputOnly>(InstalledDevice.Input2.ToString());
            var input4            = _deviceService.GetDevice <HSPE16InputOnly>(InstalledDevice.Input4.ToString());
            var i2CHardwareBridge = _deviceService.GetDevice <I2CHardwareBridge>();

            const int SensorPin = 5;

            var area = _areaService.RegisterArea(Room.Floor);

            _sensorFactory.RegisterTemperatureSensor(area, Floor.LowerFloorTemperatureSensor,
                                                     i2CHardwareBridge.DHT22Accessor.GetTemperatureSensor(SensorPin));

            _sensorFactory.RegisterHumiditySensor(area, Floor.LowerFloorHumiditySensor,
                                                  i2CHardwareBridge.DHT22Accessor.GetHumiditySensor(SensorPin));

            _sensorFactory.RegisterMotionDetector(area, Floor.StairwayMotionDetector, input2.GetInput(1));
            _sensorFactory.RegisterMotionDetector(area, Floor.StairsLowerMotionDetector, input4.GetInput(7));
            _sensorFactory.RegisterMotionDetector(area, Floor.StairsUpperMotionDetector, input4.GetInput(6));
            _sensorFactory.RegisterMotionDetector(area, Floor.LowerFloorMotionDetector, input1.GetInput(4));

            _actuatorFactory.RegisterRollerShutter(area, Floor.StairwayRollerShutter, hsrel5Stairway.GetOutput(4), hsrel5Stairway.GetOutput(3));

            _sensorFactory.RegisterButton(area, Floor.ButtonLowerFloorUpper, input1.GetInput(0));
            _sensorFactory.RegisterButton(area, Floor.ButtonLowerFloorLower, input1.GetInput(5));
            _sensorFactory.RegisterButton(area, Floor.ButtonLowerFloorAtBathroom, input1.GetInput(1));
            _sensorFactory.RegisterButton(area, Floor.ButtonLowerFloorAtKitchen, input1.GetInput(3));
            _sensorFactory.RegisterButton(area, Floor.ButtonStairsLowerUpper, input4.GetInput(5));
            _sensorFactory.RegisterButton(area, Floor.ButtonStairsLowerLower, input1.GetInput(2));
            _sensorFactory.RegisterButton(area, Floor.ButtonStairsUpper, input4.GetInput(4));
            _sensorFactory.RegisterButton(area, Floor.ButtonStairway, input1.GetInput(6));

            _actuatorFactory.RegisterLamp(area, Floor.Lamp1, hspe16FloorAndLowerBathroom.GetOutput(5).WithInvertedState());
            _actuatorFactory.RegisterLamp(area, Floor.Lamp2, hspe16FloorAndLowerBathroom.GetOutput(6).WithInvertedState());
            _actuatorFactory.RegisterLamp(area, Floor.Lamp3, hspe16FloorAndLowerBathroom.GetOutput(7).WithInvertedState());
            _actuatorFactory.RegisterLamp(area, Floor.StairwayLampCeiling, hsrel5Stairway.GetOutput(0));
            _actuatorFactory.RegisterLamp(area, Floor.StairwayLampWall, hsrel5Stairway.GetOutput(1));

            _actuatorFactory.RegisterLogicalComponent(area, Floor.CombinedStairwayLamp)
            .WithComponent(area.GetLamp(Floor.StairwayLampCeiling))
            .WithComponent(area.GetLamp(Floor.StairwayLampWall));

            SetupStairwayLamps(area);

            _actuatorFactory.RegisterLogicalComponent(area, Floor.CombinedLamps)
            .WithComponent(area.GetLamp(Floor.Lamp1))
            .WithComponent(area.GetLamp(Floor.Lamp2))
            .WithComponent(area.GetLamp(Floor.Lamp3));

            _automationFactory.RegisterTurnOnAndOffAutomation(area, Floor.CombinedLampsAutomation)
            .WithTrigger(area.GetMotionDetector(Floor.LowerFloorMotionDetector))
            .WithTrigger(area.GetButton(Floor.ButtonLowerFloorUpper).PressedShortTrigger)
            .WithTrigger(area.GetButton(Floor.ButtonLowerFloorAtBathroom).PressedShortTrigger)
            .WithTrigger(area.GetButton(Floor.ButtonLowerFloorAtKitchen).PressedShortTrigger)
            .WithTarget(area.GetComponent(Floor.CombinedLamps))
            .WithEnabledAtNight()
            .WithTurnOffIfButtonPressedWhileAlreadyOn();

            SetupStairsCeilingLamps(area, hspe8UpperFloor);
            SetupStairsLamps(area, hspe16FloorAndLowerBathroom);

            _automationFactory.RegisterRollerShutterAutomation(area, Floor.StairwayRollerShutterAutomation)
            .WithRollerShutters(area.GetRollerShutter(Floor.StairwayRollerShutter));
        }
Beispiel #15
0
        public void Apply()
        {
            var input4 = _deviceService.GetDevice <HSPE16InputOnly>(InstalledDevice.Input4.ToString());
            var input5 = _deviceService.GetDevice <HSPE16InputOnly>(InstalledDevice.Input5.ToString());

            var hsrel8 = _deviceService.GetDevice <HSREL8>(InstalledDevice.OfficeHSREL8.ToString());
            var hspe8  = _deviceService.GetDevice <HSPE8OutputOnly>(InstalledDevice.UpperFloorAndOfficeHSPE8.ToString());

            //var hsrel8 = (HSREL8)_ccToolsBoardService.RegisterDevice(CCToolsDeviceType.HSRel8, InstalledDevice.OfficeHSREL8.ToString(), 20);
            //var hspe8 = (HSPE8OutputOnly)_ccToolsBoardService.RegisterDevice(CCToolsDeviceType.HSPE8_OutputOnly, InstalledDevice.UpperFloorAndOfficeHSPE8.ToString(), 37);


            var area = _areaService.RegisterArea(Room.Office);

            //var i2CHardwareBridge = _deviceService.GetDevice<I2CHardwareBridge>();
            //const int SensorPin = 6; // ID from MQTT
            //_sensorFactory.RegisterTemperatureSensor(area, Office.TemperatureSensor, i2CHardwareBridge.DHT22Accessor.GetTemperatureSensor(SensorPin));
            //_sensorFactory.RegisterHumiditySensor(area, Office.HumiditySensor, i2CHardwareBridge.DHT22Accessor.GetHumiditySensor(SensorPin));

            _sensorFactory.RegisterWindow(area, Office.WindowLeftL, input4.GetInput(11));
            _sensorFactory.RegisterWindow(area, Office.WindowLeftR, input4.GetInput(12), input4.GetInput(10));
            _sensorFactory.RegisterWindow(area, Office.WindowRightL, input4.GetInput(8));
            _sensorFactory.RegisterWindow(area, Office.WindowRightR, input4.GetInput(9), input5.GetInput(8));

            _sensorFactory.RegisterMotionDetector(area, Office.MotionDetector, input4.GetInput(13));

            _sensorFactory.RegisterTemperatureSensor(area, Office.TemperatureSensor, new MqttBasedNumericSensorAdapter("sensors-office/temperature", _deviceMessageBroker, _logService));
            _sensorFactory.RegisterHumiditySensor(area, Office.HumiditySensor, new MqttBasedNumericSensorAdapter("sensors-office/humidity", _deviceMessageBroker, _logService));

            _actuatorFactory.RegisterLamp(area, Office.RgbLight, new RgbDeviceAdapter("kitchen-rgb/$patch/rgb", _deviceMessageBroker));

            _actuatorFactory.RegisterSocket(area, Office.SocketFrontLeft, hsrel8.GetOutput(0));
            _actuatorFactory.RegisterSocket(area, Office.SocketFrontRight, hsrel8.GetOutput(6));
            _actuatorFactory.RegisterSocket(area, Office.SocketWindowLeft, hsrel8.GetOutput(10).WithInvertedState());
            _actuatorFactory.RegisterSocket(area, Office.SocketWindowRight, hsrel8.GetOutput(11).WithInvertedState());
            _actuatorFactory.RegisterSocket(area, Office.SocketRearLeftEdge, hsrel8.GetOutput(7));
            _actuatorFactory.RegisterSocket(area, Office.SocketRearLeft, hsrel8.GetOutput(2));
            _actuatorFactory.RegisterSocket(area, Office.SocketRearRight, hsrel8.GetOutput(1));
            _actuatorFactory.RegisterSocket(area, Office.RemoteSocketDesk, _remoteSocketService.GetRemoteSocket("OFFICE_0"));

            _sensorFactory.RegisterButton(area, Office.ButtonUpperLeft, input5.GetInput(0));
            _sensorFactory.RegisterButton(area, Office.ButtonUpperRight, input4.GetInput(15));
            _sensorFactory.RegisterButton(area, Office.ButtonLowerLeft, input5.GetInput(1));
            _sensorFactory.RegisterButton(area, Office.ButtonLowerRight, input4.GetInput(14));

            _sensorFactory.RegisterButton(area, Office.ButtonEdgeLeft, new DeviceBinaryInput("office/edge/button-left", _deviceMessageBroker));
            _sensorFactory.RegisterButton(area, Office.ButtonEdgeRight, new DeviceBinaryInput("office/edge/button-right", _deviceMessageBroker));

            var stateMachine = _actuatorFactory.RegisterStateMachine(area, Office.CombinedCeilingLights, (s, a) => SetupLight(s, hsrel8, hspe8));

            stateMachine.AlternativeStateId = StateMachineStateExtensions.OffStateId;
            stateMachine.ResetStateId       = StateMachineStateExtensions.OffStateId;

            area.GetButton(Office.ButtonUpperLeft)
            .CreatePressedShortTrigger(_messageBroker)
            .Attach(() => area.GetComponent(Office.CombinedCeilingLights).TrySetState(StateMachineStateExtensions.OnStateId));

            area.GetButton(Office.ButtonUpperLeft).CreatePressedLongTrigger(_messageBroker).Attach(() =>
            {
                area.GetComponent(Office.CombinedCeilingLights).TryTurnOff();
                area.GetComponent(Office.SocketRearLeftEdge).TryTurnOff();
                area.GetComponent(Office.SocketRearLeft).TryTurnOff();
                area.GetComponent(Office.SocketFrontLeft).TryTurnOff();
            });

            area.GetButton(Office.ButtonLowerLeft)
            .CreatePressedShortTrigger(_messageBroker)
            .Attach(() => area.GetComponent(Office.CombinedCeilingLights).TrySetState("DeskOnly"));

            area.GetButton(Office.ButtonLowerRight)
            .CreatePressedShortTrigger(_messageBroker)
            .Attach(() => area.GetComponent(Office.CombinedCeilingLights).TrySetState("CouchOnly"));

            area.GetButton(Office.ButtonEdgeRight)
            .CreatePressedShortTrigger(_messageBroker)
            .Attach(() => area.GetComponent(Office.CombinedCeilingLights).TrySetState(StateMachineStateExtensions.OnStateId));

            area.GetButton(Office.ButtonEdgeLeft)
            .CreatePressedShortTrigger(_messageBroker)
            .Attach(() => area.GetComponent(Office.SocketRearRight).TryTogglePowerState());
        }
Beispiel #16
0
        public void Apply()
        {
            var hsrel5 = (HSREL5)_ccToolsBoardService.RegisterDevice(CCToolsDeviceType.HSRel5, InstalledDevice.KitchenHSREL5.ToString(), 58);
            var hspe8  = (HSPE8OutputOnly)_ccToolsBoardService.RegisterDevice(CCToolsDeviceType.HSPE8_OutputOnly, InstalledDevice.KitchenHSPE8.ToString(), 39);

            var input0            = _deviceService.GetDevice <HSPE16InputOnly>(InstalledDevice.Input0.ToString());
            var input1            = _deviceService.GetDevice <HSPE16InputOnly>(InstalledDevice.Input1.ToString());
            var input2            = _deviceService.GetDevice <HSPE16InputOnly>(InstalledDevice.Input2.ToString());
            var i2CHardwareBridge = _deviceService.GetDevice <I2CHardwareBridge>();

            const int SensorPin = 11;

            var area = _areaService.RegisterArea(Room.Kitchen);

            _sensorFactory.RegisterWindow(area, Kitchen.Window, new PortBasedWindowAdapter(input0.GetInput(6), input0.GetInput(7)));

            _sensorFactory.RegisterTemperatureSensor(area, Kitchen.TemperatureSensor,
                                                     i2CHardwareBridge.DHT22Accessor.GetTemperatureSensor(SensorPin));

            _sensorFactory.RegisterHumiditySensor(area, Kitchen.HumiditySensor,
                                                  i2CHardwareBridge.DHT22Accessor.GetHumiditySensor(SensorPin));

            _sensorFactory.RegisterMotionDetector(area, Kitchen.MotionDetector, input1.GetInput(8));

            _actuatorFactory.RegisterLamp(area, Kitchen.LightCeilingMiddle, hsrel5[HSREL5Pin.GPIO0].WithInvertedState());
            _actuatorFactory.RegisterLamp(area, Kitchen.LightCeilingWindow, hsrel5[HSREL5Pin.GPIO1].WithInvertedState());
            _actuatorFactory.RegisterLamp(area, Kitchen.LightCeilingWall, hsrel5[HSREL5Pin.GPIO2].WithInvertedState());
            _actuatorFactory.RegisterLamp(area, Kitchen.LightCeilingDoor, hspe8[HSPE8Pin.GPIO0].WithInvertedState());
            _actuatorFactory.RegisterLamp(area, Kitchen.LightCeilingPassageInner, hspe8[HSPE8Pin.GPIO1].WithInvertedState());
            _actuatorFactory.RegisterLamp(area, Kitchen.LightCeilingPassageOuter, hspe8[HSPE8Pin.GPIO2].WithInvertedState());
            _actuatorFactory.RegisterLamp(area, Kitchen.LightKitchenette, _outpostDeviceService.CreateRgbStripAdapter("RGBSK1"));

            _actuatorFactory.RegisterSocket(area, Kitchen.SocketKitchenette, hsrel5[HSREL5Pin.Relay1]); // 0?
            _actuatorFactory.RegisterSocket(area, Kitchen.SocketWall, hsrel5[HSREL5Pin.Relay2]);
            _actuatorFactory.RegisterSocket(area, Kitchen.SocketCeiling1, hspe8[HSPE8Pin.GPIO3].WithInvertedState());
            _actuatorFactory.RegisterSocket(area, Kitchen.SocketCeiling2, hspe8[HSPE8Pin.GPIO4].WithInvertedState());

            _systemEventsService.StartupCompleted += (s, e) =>
            {
                area.GetComponent(Kitchen.SocketCeiling1).TryTurnOn();
            };

            _actuatorFactory.RegisterRollerShutter(area, Kitchen.RollerShutter, hsrel5[HSREL5Pin.Relay4], hsrel5[HSREL5Pin.Relay3]);

            _sensorFactory.RegisterButton(area, Kitchen.ButtonKitchenette, input1.GetInput(11));
            _sensorFactory.RegisterButton(area, Kitchen.ButtonPassage, input1.GetInput(9));
            _sensorFactory.RegisterButton(area, Kitchen.RollerShutterButtonUp, input2.GetInput(15));
            _sensorFactory.RegisterButton(area, Kitchen.RollerShutterButtonDown, input2.GetInput(14));

            area.GetButton(Kitchen.ButtonKitchenette).CreatePressedShortTrigger(_messageBroker).Attach(() => area.GetLamp(Kitchen.LightCeilingMiddle).TryTogglePowerState());
            area.GetButton(Kitchen.ButtonPassage).CreatePressedShortTrigger(_messageBroker).Attach(() => area.GetLamp(Kitchen.LightCeilingMiddle).TryTogglePowerState());

            _automationFactory.RegisterRollerShutterAutomation(area, Kitchen.RollerShutterAutomation)
            .WithRollerShutters(area.GetRollerShutter(Kitchen.RollerShutter));

            area.GetRollerShutter(Kitchen.RollerShutter).ConnectWith(
                area.GetButton(Kitchen.RollerShutterButtonUp), area.GetButton(Kitchen.RollerShutterButtonDown), _messageBroker);

            area.GetButton(Kitchen.RollerShutterButtonUp).CreatePressedLongTrigger(_messageBroker).Attach(() =>
            {
                var light = area.GetComponent(Kitchen.LightKitchenette);
                light.TryTogglePowerState();
                light.TrySetColor(0D, 0D, 1D);
            });

            _actuatorFactory.RegisterLogicalComponent(area, Kitchen.CombinedAutomaticLights)
            .WithComponent(area.GetLamp(Kitchen.LightCeilingWall))
            .WithComponent(area.GetLamp(Kitchen.LightCeilingDoor))
            .WithComponent(area.GetLamp(Kitchen.LightCeilingWindow));

            _automationFactory.RegisterTurnOnAndOffAutomation(area, Kitchen.CombinedAutomaticLightsAutomation)
            .WithTrigger(area.GetMotionDetector(Kitchen.MotionDetector))
            .WithTarget(area.GetComponent(Kitchen.CombinedAutomaticLights))
            .WithEnabledAtNight();
        }
Beispiel #17
0
        public void Apply()
        {
            var hsrel5Stairway              = (HSREL5)_ccToolsBoardService.RegisterDevice(CCToolsDeviceType.HSRel5, InstalledDevice.StairwayHSREL5.ToString(), 60);
            var hspe8UpperFloor             = _deviceService.GetDevice <HSPE8OutputOnly>(InstalledDevice.UpperFloorAndOfficeHSPE8.ToString());
            var hspe16FloorAndLowerBathroom = (HSPE16OutputOnly)_ccToolsBoardService.RegisterDevice(CCToolsDeviceType.HSPE16_OutputOnly, InstalledDevice.LowerFloorAndLowerBathroomHSPE16.ToString(), 17);

            var input1 = _deviceService.GetDevice <HSPE16InputOnly>(InstalledDevice.Input1.ToString());
            var input2 = _deviceService.GetDevice <HSPE16InputOnly>(InstalledDevice.Input2.ToString());
            var input4 = _deviceService.GetDevice <HSPE16InputOnly>(InstalledDevice.Input4.ToString());

            var area = _areaService.RegisterArea(Room.Floor);

            _sensorFactory.RegisterTemperatureSensor(area, Floor.LowerFloorTemperatureSensor,
                                                     new MqttBasedNumericSensorAdapter("sensors-bridge/temperature/2", _deviceMessageBrokerService, _logService));

            _sensorFactory.RegisterHumiditySensor(area, Floor.LowerFloorHumiditySensor,
                                                  new MqttBasedNumericSensorAdapter("sensors-bridge/humidity/2", _deviceMessageBrokerService, _logService));

            _sensorFactory.RegisterMotionDetector(area, Floor.StairwayMotionDetector, input2.GetInput(1));
            _sensorFactory.RegisterMotionDetector(area, Floor.StairsLowerMotionDetector, input4.GetInput(7));
            _sensorFactory.RegisterMotionDetector(area, Floor.StairsUpperMotionDetector, input4.GetInput(6));
            _sensorFactory.RegisterMotionDetector(area, Floor.LowerFloorMotionDetector, input1.GetInput(4));

            _actuatorFactory.RegisterRollerShutter(area, Floor.StairwayRollerShutter, hsrel5Stairway.GetOutput(4), hsrel5Stairway.GetOutput(3));

            _sensorFactory.RegisterButton(area, Floor.ButtonLowerFloorUpper, input1.GetInput(0));
            _sensorFactory.RegisterButton(area, Floor.ButtonLowerFloorLower, input1.GetInput(5));
            _sensorFactory.RegisterButton(area, Floor.ButtonLowerFloorAtBathroom, input1.GetInput(1));
            _sensorFactory.RegisterButton(area, Floor.ButtonLowerFloorAtKitchen, input1.GetInput(3));
            _sensorFactory.RegisterButton(area, Floor.ButtonStairsLowerUpper, input4.GetInput(5));
            _sensorFactory.RegisterButton(area, Floor.ButtonStairsLowerLower, input1.GetInput(2));
            _sensorFactory.RegisterButton(area, Floor.ButtonStairsUpper, input4.GetInput(4));
            _sensorFactory.RegisterButton(area, Floor.ButtonStairway, input1.GetInput(6));

            _actuatorFactory.RegisterLamp(area, Floor.Lamp1, hspe16FloorAndLowerBathroom.GetOutput(5).WithInvertedState());
            _actuatorFactory.RegisterLamp(area, Floor.Lamp2, hspe16FloorAndLowerBathroom.GetOutput(6).WithInvertedState());
            _actuatorFactory.RegisterLamp(area, Floor.Lamp3, hspe16FloorAndLowerBathroom.GetOutput(7).WithInvertedState());
            _actuatorFactory.RegisterLamp(area, Floor.StairwayLampCeiling, hsrel5Stairway.GetOutput(0));
            _actuatorFactory.RegisterLamp(area, Floor.StairwayLampWall, hsrel5Stairway.GetOutput(1));

            _actuatorFactory.RegisterLogicalComponent(area, Floor.CombinedStairwayLamp)
            .WithComponent(area.GetLamp(Floor.StairwayLampCeiling))
            .WithComponent(area.GetLamp(Floor.StairwayLampWall));

            SetupStairwayLamps(area);

            _actuatorFactory.RegisterLogicalComponent(area, Floor.CombinedLamps)
            .WithComponent(area.GetLamp(Floor.Lamp1))
            .WithComponent(area.GetLamp(Floor.Lamp2))
            .WithComponent(area.GetLamp(Floor.Lamp3));

            _automationFactory.RegisterTurnOnAndOffAutomation(area, Floor.CombinedLampsAutomation)
            .WithTrigger(area.GetMotionDetector(Floor.LowerFloorMotionDetector))
            .WithTrigger(area.GetButton(Floor.ButtonLowerFloorUpper).CreatePressedShortTrigger(_messageBroker))
            .WithTrigger(area.GetButton(Floor.ButtonLowerFloorAtBathroom).CreatePressedShortTrigger(_messageBroker))
            .WithTrigger(area.GetButton(Floor.ButtonLowerFloorAtKitchen).CreatePressedShortTrigger(_messageBroker))
            .WithTarget(area.GetComponent(Floor.CombinedLamps))
            .WithEnabledAtNight()
            .WithTurnOffIfButtonPressedWhileAlreadyOn();

            SetupStairsCeilingLamps(area, hspe8UpperFloor);
            SetupStairsLamps(area, hspe16FloorAndLowerBathroom);

            _automationFactory.RegisterRollerShutterAutomation(area, Floor.StairwayRollerShutterAutomation)
            .WithRollerShutters(area.GetRollerShutter(Floor.StairwayRollerShutter));
        }
Beispiel #18
0
        public void Apply()
        {
            var hsrel5            = _ccToolsBoardService.RegisterHSREL5(InstalledDevice.BedroomHSREL5, new I2CSlaveAddress(38));
            var hsrel8            = _ccToolsBoardService.RegisterHSREL8(InstalledDevice.BedroomHSREL8, new I2CSlaveAddress(21));
            var input5            = _deviceService.GetDevice <HSPE16InputOnly>(InstalledDevice.Input5);
            var input4            = _deviceService.GetDevice <HSPE16InputOnly>(InstalledDevice.Input4);
            var i2CHardwareBridge = _deviceService.GetDevice <I2CHardwareBridge>();

            const int SensorPin = 6;

            var room = _areaService.CreateArea(Room.Bedroom);

            _sensorFactory.RegisterWindow(room, Bedroom.WindowLeft, w => w.WithCenterCasement(input5.GetInput(2)));
            _sensorFactory.RegisterWindow(room, Bedroom.WindowRight, w => w.WithCenterCasement(input5.GetInput(3)));

            _sensorFactory.RegisterTemperatureSensor(room, Bedroom.TemperatureSensor,
                                                     i2CHardwareBridge.DHT22Accessor.GetTemperatureSensor(SensorPin));

            _sensorFactory.RegisterHumiditySensor(room, Bedroom.HumiditySensor,
                                                  i2CHardwareBridge.DHT22Accessor.GetHumiditySensor(SensorPin));

            _sensorFactory.RegisterMotionDetector(room, Bedroom.MotionDetector, input5.GetInput(12));

            _sensorFactory.RegisterButton(room, Bedroom.ButtonWindowUpper, input5.GetInput(10));
            _sensorFactory.RegisterButton(room, Bedroom.ButtonWindowLower, input5.GetInput(13));
            _sensorFactory.RegisterButton(room, Bedroom.ButtonBedLeftInner, input4.GetInput(2));
            _sensorFactory.RegisterButton(room, Bedroom.ButtonBedLeftOuter, input4.GetInput(0));
            _sensorFactory.RegisterButton(room, Bedroom.ButtonBedRightInner, input4.GetInput(1));
            _sensorFactory.RegisterButton(room, Bedroom.ButtonBedRightOuter, input4.GetInput(3));
            _sensorFactory.RegisterButton(room, Bedroom.ButtonDoor, input5.GetInput(11));

            _sensorFactory.RegisterRollerShutterButtons(room, Bedroom.RollerShutterButtonsUpperUp, input5.GetInput(6),
                                                        Bedroom.RollerShutterButtonsUpperDown, input5.GetInput(7));

            _sensorFactory.RegisterRollerShutterButtons(room, Bedroom.RollerShutterButtonsLowerUp, input5.GetInput(4),
                                                        Bedroom.RollerShutterButtonsLowerDown, input5.GetInput(5));

            _actuatorFactory.RegisterLamp(room, Bedroom.LightCeiling, hsrel5.GetOutput(5).WithInvertedState());
            _actuatorFactory.RegisterLamp(room, Bedroom.LightCeilingWindow, hsrel5.GetOutput(6).WithInvertedState());
            _actuatorFactory.RegisterLamp(room, Bedroom.LightCeilingWall, hsrel5.GetOutput(7).WithInvertedState());
            _actuatorFactory.RegisterLamp(room, Bedroom.LampBedLeft, hsrel5.GetOutput(4));
            _actuatorFactory.RegisterLamp(room, Bedroom.LampBedRight, hsrel8.GetOutput(8).WithInvertedState());

            _actuatorFactory.RegisterSocket(room, Bedroom.SocketWindowLeft, hsrel5[HSREL5Pin.Relay0]);
            _actuatorFactory.RegisterSocket(room, Bedroom.SocketWindowRight, hsrel5[HSREL5Pin.Relay1]);
            _actuatorFactory.RegisterSocket(room, Bedroom.SocketWall, hsrel5[HSREL5Pin.Relay2]);
            _actuatorFactory.RegisterSocket(room, Bedroom.SocketWallEdge, hsrel5[HSREL5Pin.Relay3]);
            _actuatorFactory.RegisterSocket(room, Bedroom.SocketBedLeft, hsrel8.GetOutput(7));
            _actuatorFactory.RegisterSocket(room, Bedroom.SocketBedRight, hsrel8.GetOutput(9));

            _actuatorFactory.RegisterRollerShutter(room, Bedroom.RollerShutterLeft, hsrel8[HSREL8Pin.Relay6], hsrel8[HSREL8Pin.Relay5]);
            _actuatorFactory.RegisterRollerShutter(room, Bedroom.RollerShutterRight, hsrel8[HSREL8Pin.Relay3], hsrel8[HSREL8Pin.Relay4]);

            room.GetRollerShutter(Bedroom.RollerShutterLeft)
            .ConnectWith(room.GetButton(Bedroom.RollerShutterButtonsUpperUp), room.GetButton(Bedroom.RollerShutterButtonsUpperDown));

            room.GetRollerShutter(Bedroom.RollerShutterRight)
            .ConnectWith(room.GetButton(Bedroom.RollerShutterButtonsLowerUp), room.GetButton(Bedroom.RollerShutterButtonsLowerDown));

            _actuatorFactory.RegisterLogicalActuator(room, Bedroom.CombinedCeilingLights)
            .WithActuator(room.GetLamp(Bedroom.LightCeilingWall))
            .WithActuator(room.GetLamp(Bedroom.LightCeilingWindow))
            .ConnectToggleActionWith(room.GetButton(Bedroom.ButtonDoor))
            .ConnectToggleActionWith(room.GetButton(Bedroom.ButtonWindowUpper));

            room.GetButton(Bedroom.ButtonDoor).GetPressedLongTrigger().Attach(() =>
            {
                room.GetStateMachine(Bedroom.LampBedLeft).TryTurnOff();
                room.GetStateMachine(Bedroom.LampBedRight).TryTurnOff();
                room.GetStateMachine(Bedroom.CombinedCeilingLights).TryTurnOff();
            });

            _automationFactory.RegisterRollerShutterAutomation(room, Bedroom.RollerShuttersAutomation)
            .WithRollerShutters(room.GetRollerShutters())
            .WithDoNotOpenBefore(TimeSpan.FromHours(7).Add(TimeSpan.FromMinutes(15)))
            .WithCloseIfOutsideTemperatureIsGreaterThan(24)
            .WithDoNotOpenIfOutsideTemperatureIsBelowThan(3);

            _automationFactory.RegisterTurnOnAndOffAutomation(room, Bedroom.LightCeilingAutomation)
            .WithTrigger(room.GetMotionDetector(Bedroom.MotionDetector))
            .WithTarget(room.GetStateMachine(Bedroom.LightCeiling))
            .WithTurnOnIfAllRollerShuttersClosed(room.GetRollerShutter(Bedroom.RollerShutterLeft), room.GetRollerShutter(Bedroom.RollerShutterRight))
            .WithEnabledAtNight()
            .WithSkipIfAnyActuatorIsAlreadyOn(room.GetLamp(Bedroom.LampBedLeft), room.GetLamp(Bedroom.LampBedRight));

            _actuatorFactory.RegisterStateMachine(room, Bedroom.Fan, (s, r) => SetupFan(s, r, hsrel8));

            room.GetButton(Bedroom.ButtonBedLeftInner).WithPressedShortlyAction(() => room.GetLamp(Bedroom.LampBedLeft).SetNextState());
            room.GetButton(Bedroom.ButtonBedLeftInner).WithPressedLongAction(() => room.GetStateMachine(Bedroom.CombinedCeilingLights).SetNextState());
            room.GetButton(Bedroom.ButtonBedLeftOuter).WithPressedShortlyAction(() => room.GetStateMachine(Bedroom.Fan).SetNextState());
            room.GetButton(Bedroom.ButtonBedLeftOuter).WithPressedLongAction(() => room.GetStateMachine(Bedroom.Fan).TryTurnOff());

            room.GetButton(Bedroom.ButtonBedRightInner).WithPressedShortlyAction(() => room.GetLamp(Bedroom.LampBedRight).SetNextState());
            room.GetButton(Bedroom.ButtonBedRightInner).WithPressedLongAction(() => room.GetStateMachine(Bedroom.CombinedCeilingLights).SetNextState());
            room.GetButton(Bedroom.ButtonBedRightOuter).WithPressedShortlyAction(() => room.GetStateMachine(Bedroom.Fan).SetNextState());
            room.GetButton(Bedroom.ButtonBedRightOuter).WithPressedLongAction(() => room.GetStateMachine(Bedroom.Fan).TryTurnOff());

            _synonymService.AddSynonymsForArea(Room.Bedroom, "Schlafzimmer", "Bedroom");
        }
Beispiel #19
0
        public void Apply()
        {
            var input4 = _deviceService.GetDevice <HSPE16InputOnly>(InstalledDevice.Input4.ToString());
            var input5 = _deviceService.GetDevice <HSPE16InputOnly>(InstalledDevice.Input5.ToString());

            var hsrel8 = _ccToolsBoardService.RegisterHSREL8(InstalledDevice.OfficeHSREL8.ToString(), new I2CSlaveAddress(20));
            var hspe8  = _ccToolsBoardService.RegisterHSPE8OutputOnly(InstalledDevice.UpperFloorAndOfficeHSPE8.ToString(), new I2CSlaveAddress(37));

            var i2CHardwareBridge = _deviceService.GetDevice <I2CHardwareBridge>();

            const int SensorPin = 2;

            var area = _areaService.RegisterArea(Room.Office);

            _sensorFactory.RegisterWindow(area, Office.WindowLeftL, input4.GetInput(11));
            _sensorFactory.RegisterWindow(area, Office.WindowLeftR, input4.GetInput(12), input4.GetInput(10));
            _sensorFactory.RegisterWindow(area, Office.WindowRightL, input4.GetInput(8));
            _sensorFactory.RegisterWindow(area, Office.WindowRightR, input4.GetInput(9), input5.GetInput(8));

            _sensorFactory.RegisterTemperatureSensor(area, Office.TemperatureSensor, i2CHardwareBridge.DHT22Accessor.GetTemperatureSensor(SensorPin));

            _sensorFactory.RegisterHumiditySensor(area, Office.HumiditySensor,
                                                  i2CHardwareBridge.DHT22Accessor.GetHumiditySensor(SensorPin));

            _sensorFactory.RegisterMotionDetector(area, Office.MotionDetector, input4.GetInput(13));

            _actuatorFactory.RegisterSocket(area, Office.SocketFrontLeft, hsrel8.GetOutput(0));
            _actuatorFactory.RegisterSocket(area, Office.SocketFrontRight, hsrel8.GetOutput(6));
            _actuatorFactory.RegisterSocket(area, Office.SocketWindowLeft, hsrel8.GetOutput(10).WithInvertedState());
            _actuatorFactory.RegisterSocket(area, Office.SocketWindowRight, hsrel8.GetOutput(11).WithInvertedState());
            _actuatorFactory.RegisterSocket(area, Office.SocketRearLeftEdge, hsrel8.GetOutput(7));
            _actuatorFactory.RegisterSocket(area, Office.SocketRearLeft, hsrel8.GetOutput(2));
            _actuatorFactory.RegisterSocket(area, Office.SocketRearRight, hsrel8.GetOutput(1));
            _actuatorFactory.RegisterSocket(area, Office.RemoteSocketDesk, _remoteSocketService.GetRemoteSocket("OFFICE_0"));

            _sensorFactory.RegisterButton(area, Office.ButtonUpperLeft, input5.GetInput(0));
            _sensorFactory.RegisterButton(area, Office.ButtonUpperRight, input4.GetInput(15));
            _sensorFactory.RegisterButton(area, Office.ButtonLowerLeft, input5.GetInput(1));
            _sensorFactory.RegisterButton(area, Office.ButtonLowerRight, input4.GetInput(14));

            var stateMachine = _actuatorFactory.RegisterStateMachine(area, Office.CombinedCeilingLights, (s, a) => SetupLight(s, hsrel8, hspe8));

            stateMachine.AlternativeStateId = StateMachineStateExtensions.OffStateId;
            stateMachine.ResetStateId       = StateMachineStateExtensions.OffStateId;

            area.GetButton(Office.ButtonUpperLeft)
            .PressedShortTrigger
            .Attach(() => area.GetComponent(Office.CombinedCeilingLights).TrySetState(StateMachineStateExtensions.OnStateId));

            area.GetButton(Office.ButtonUpperLeft).PressedLongTrigger.Attach(() =>
            {
                area.GetComponent(Office.CombinedCeilingLights).TryTurnOff();
                area.GetComponent(Office.SocketRearLeftEdge).TryTurnOff();
                area.GetComponent(Office.SocketRearLeft).TryTurnOff();
                area.GetComponent(Office.SocketFrontLeft).TryTurnOff();
            });

            area.GetButton(Office.ButtonLowerLeft)
            .PressedShortTrigger
            .Attach(() => area.GetComponent(Office.CombinedCeilingLights).TrySetState("DeskOnly"));

            area.GetButton(Office.ButtonLowerRight)
            .PressedShortTrigger
            .Attach(() => area.GetComponent(Office.CombinedCeilingLights).TrySetState("CouchOnly"));
        }