Пример #1
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");
        }
Пример #2
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();
            });
        }
Пример #3
0
        public void Apply()
        {
            var hsrel8LowerHeatingValves = _ccToolsBoardService.RegisterHSREL8(InstalledDevice.LowerHeatingValvesHSREL8, new I2CSlaveAddress(16));
            var hsrel5UpperHeatingValves = _ccToolsBoardService.RegisterHSREL5(InstalledDevice.UpperHeatingValvesHSREL5, new I2CSlaveAddress(56));

            var hsrel5Stairway = _deviceService.GetDevice <HSREL5>(InstalledDevice.StairwayHSREL5);
            var input3         = _deviceService.GetDevice <HSPE16InputOnly>(InstalledDevice.Input3);

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

            _actuatorFactory.RegisterLamp(room, Storeroom.LightCeiling, hsrel5Stairway[HSREL5Pin.GPIO1]);

            _sensorFactory.RegisterMotionDetector(room, Storeroom.MotionDetector, input3.GetInput(12));
            _sensorFactory.RegisterMotionDetector(room, Storeroom.MotionDetectorCatLitterBox, input3.GetInput(11).WithInvertedState());

            _actuatorFactory.RegisterSocket(room, Storeroom.CatLitterBoxFan, hsrel5Stairway[HSREL5Pin.GPIO2]);
            _actuatorFactory.RegisterSocket(room, Storeroom.CirculatingPump, hsrel5UpperHeatingValves[HSREL5Pin.Relay3]);

            _automationFactory.RegisterTurnOnAndOffAutomation(room, Storeroom.LightCeilingAutomation)
            .WithTrigger(room.GetMotionDetector(Storeroom.MotionDetector))
            .WithTarget(room.GetLamp(Storeroom.LightCeiling));

            _automationFactory.RegisterTurnOnAndOffAutomation(room, Storeroom.CatLitterBoxFan)
            .WithTrigger(room.GetMotionDetector(Storeroom.MotionDetectorCatLitterBox))
            .WithTarget(room.GetSocket(Storeroom.CatLitterBoxFan));

            // Both relays are used for water source selection (True+True = Lowerr, False+False = Upper)
            // Second relays is with capacitor. Disable second with delay before disable first one.
            hsrel5UpperHeatingValves[HSREL5Pin.GPIO0].Write(BinaryState.Low);
            hsrel5UpperHeatingValves[HSREL5Pin.GPIO1].Write(BinaryState.Low);

            _automationFactory.RegisterTurnOnAndOffAutomation(room, Storeroom.CirculatingPumpAutomation)
            .WithTrigger(_areaService.GetArea(Room.Kitchen).GetMotionDetector(KitchenConfiguration.Kitchen.MotionDetector))
            .WithTrigger(_areaService.GetArea(Room.LowerBathroom).GetMotionDetector(LowerBathroomConfiguration.LowerBathroom.MotionDetector))
            .WithTarget(room.GetSocket(Storeroom.CirculatingPump))
            .WithPauseAfterEveryTurnOn(TimeSpan.FromHours(1))
            .WithEnabledAtDay();

            _catLitterBoxTwitterSender =
                new CatLitterBoxTwitterSender(_timerService, _twitterClientService).WithTrigger(
                    room.GetMotionDetector(Storeroom.MotionDetectorCatLitterBox));

            _synonymService.AddSynonymsForArea(Room.Storeroom, "Abstellkammer", "Storeroom");
        }
Пример #4
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");
        }