示例#1
0
        protected override async Task ConfigureAsync()
        {
            AddDevice(new BuiltInI2CBus());

            var pi2PortController      = new Pi2PortController();
            var ccToolsBoardController = new CCToolsBoardController(this, GetDevice <II2CBus>());

            AddDevice(pi2PortController);
            AddDevice(ccToolsBoardController);

            ServiceLocator.RegisterService(
                typeof(OpenWeatherMapWeatherService),
                new OpenWeatherMapService(ApiController,
                                          ServiceLocator.GetService <IDateTimeService>(),
                                          ServiceLocator.GetService <ISchedulerService>(),
                                          ServiceLocator.GetService <ISystemInformationService>()));

            var configurationParser = new ConfigurationParser(this);

            configurationParser.RegisterConfigurationExtender(new DefaultConfigurationExtender(configurationParser, this));
            configurationParser.RegisterConfigurationExtender(new CCToolsConfigurationExtender(configurationParser, this));
            configurationParser.RegisterConfigurationExtender(new I2CHardwareBridgeConfigurationExtender(configurationParser, this));
            configurationParser.ParseConfiguration();

            InitializeAzureCloudApiEndpoint();

            var ioBoardsInterruptMonitor = new InterruptMonitor(pi2PortController.GetInput(4));

            ioBoardsInterruptMonitor.InterruptDetected += (s, e) => ccToolsBoardController.PollInputBoardStates();
            ioBoardsInterruptMonitor.Start();

            await base.ConfigureAsync();
        }
示例#2
0
        public void Setup(Controller controller, CCToolsBoardController ccToolsController)
        {
            var hsrel5 = ccToolsController.CreateHSREL5(Device.ReadingRoomHSREL5, new I2CSlaveAddress(62));
            var input2 = controller.Device <HSPE16InputOnly>(Device.Input2);

            var i2cHardwareBridge = controller.Device <I2CHardwareBridge>();

            const int SensorPin = 9;

            var readingRoom = controller.CreateArea(Room.ReadingRoom)
                              .WithTemperatureSensor(ReadingRoom.TemperatureSensor, i2cHardwareBridge.DHT22Accessor.GetTemperatureSensor(SensorPin))
                              .WithHumiditySensor(ReadingRoom.HumiditySensor, i2cHardwareBridge.DHT22Accessor.GetHumiditySensor(SensorPin))
                              .WithLamp(ReadingRoom.LightCeilingMiddle, hsrel5.GetOutput(6).WithInvertedState())
                              .WithRollerShutter(ReadingRoom.RollerShutter, hsrel5[HSREL5Pin.Relay4], hsrel5[HSREL5Pin.Relay3])
                              .WithSocket(ReadingRoom.SocketWindow, hsrel5[HSREL5Pin.Relay0])
                              .WithSocket(ReadingRoom.SocketWallLeft, hsrel5[HSREL5Pin.Relay1])
                              .WithSocket(ReadingRoom.SocketWallRight, hsrel5[HSREL5Pin.Relay2])
                              .WithButton(ReadingRoom.Button, input2.GetInput(13))
                              .WithWindow(ReadingRoom.Window, w => w.WithCenterCasement(input2.GetInput(8))) // Tilt = input2.GetInput(9) -- currently broken!
                              .WithRollerShutterButtons(ReadingRoom.RollerShutterButtons, input2.GetInput(12), input2.GetInput(11));

            readingRoom.Lamp(ReadingRoom.LightCeilingMiddle).ConnectToggleActionWith(readingRoom.Button(ReadingRoom.Button));

            readingRoom.SetupRollerShutterAutomation().WithRollerShutters(readingRoom.RollerShutter(ReadingRoom.RollerShutter));
            readingRoom.RollerShutter(ReadingRoom.RollerShutter)
            .ConnectWith(readingRoom.RollerShutterButtons(ReadingRoom.RollerShutterButtons));
        }
        protected override void Initialize()
        {
            InitializeHealthMonitor(LedGpio);

            AddDevice(new BuiltInI2CBus());

            var piPortController = new Pi2PortController();

            AddDevice(piPortController);

            var ccToolsBoardController = new CCToolsBoardController(this, GetDevice <II2CBus>());

            AddDevice(ccToolsBoardController);

            // Setup the remote switch 433Mhz sender which is attached to the I2C bus (Arduino Nano).
            AddDevice(new I2CHardwareBridge(new I2CSlaveAddress(50), GetDevice <II2CBus>(), Timer));

            RegisterService(new SynonymService());
            RegisterService(new OpenWeatherMapWeatherService(Timer, ApiController));

            SetupRoom();

            GetService <SynonymService>().TryLoadPersistedSynonyms();
            GetService <SynonymService>().RegisterDefaultComponentStateSynonyms(this);

            Timer.Tick += (s, e) =>
            {
                piPortController.PollOpenInputPorts();
                ccToolsBoardController.PollInputBoardStates();
            };

            SetupDemo();
        }
        protected override void Initialize()
        {
            InitializeHealthMonitor(22);

            var pi2PortController = new Pi2PortController();

            AddDevice(new BuiltInI2CBus(Logger));
            AddDevice(new OpenWeatherMapWeatherStation(OpenWeatherMapWeatherStation.DefaultDeviceId, Timer, HttpApiController, Logger));

            var ccToolsFactory = new CCToolsBoardController(this, Device <II2CBus>(), HttpApiController, Logger);
            var hsrt16         = ccToolsFactory.CreateHSRT16(Device.CellarHSRT16, new I2CSlaveAddress(32));

            var garden = this.CreateArea(RoomId.Garden)
                         .WithLamp(Garden.LampTerrace, hsrt16[HSRT16Pin.Relay15])
                         .WithLamp(Garden.LampGarage, hsrt16[HSRT16Pin.Relay14])
                         .WithLamp(Garden.LampTap, hsrt16[HSRT16Pin.Relay13])
                         .WithLamp(Garden.SpotlightRoof, hsrt16[HSRT16Pin.Relay12])
                         .WithLamp(Garden.LampRearArea, hsrt16[HSRT16Pin.Relay11])
                         .WithSocket(Garden.SocketPavillion, hsrt16[HSRT16Pin.Relay10])
                         // 9 = free
                         .WithLamp(Garden.LampParkingLot, new LogicalBinaryOutput().WithOutput(hsrt16[HSRT16Pin.Relay8]).WithOutput(hsrt16[HSRT16Pin.Relay6]).WithOutput(hsrt16[HSRT16Pin.Relay7]))
                         .WithButton(Garden.Button, pi2PortController.GetInput(4).WithInvertedState())
                         .WithStateMachine(Garden.StateMachine, SetupStateMachine);

            garden.StateMachine(Garden.StateMachine).ConnectMoveNextAndToggleOffWith(garden.Button(Garden.Button));

            garden.SetupConditionalOnAutomation()
            .WithActuator(garden.Lamp(Garden.LampParkingLot))
            .WithOnAtNightRange(Device <IWeatherStation>())
            .WithOffBetweenRange(TimeSpan.Parse("22:30:00"), TimeSpan.Parse("05:00:00"));

            Timer.Tick += (s, e) => { pi2PortController.PollOpenInputPorts(); };
        }
        protected override void Initialize()
        {
            InitializeHealthMonitor(LedGpio);

            var pi2PortController      = new Pi2PortController();
            var ccToolsBoardController = new CCToolsBoardController(this, GetDevice <II2CBus>());

            AddDevice(new BuiltInI2CBus());
            AddDevice(pi2PortController);
            AddDevice(ccToolsBoardController);

            RegisterService(new OpenWeatherMapWeatherService(Timer, ApiController));

            var configurationParser = new ConfigurationParser(this);

            configurationParser.RegisterConfigurationExtender(new DefaultConfigurationExtender(configurationParser, this));
            configurationParser.RegisterConfigurationExtender(new CCToolsConfigurationExtender(configurationParser, this));
            configurationParser.RegisterConfigurationExtender(new I2CHardwareBridgeConfigurationExtender(configurationParser, this));
            configurationParser.ParseConfiguration();

            InitializeAzureCloudApiEndpoint();

            var ioBoardsInterruptMonitor = new InterruptMonitor(pi2PortController.GetInput(4));

            ioBoardsInterruptMonitor.InterruptDetected += (s, e) => ccToolsBoardController.PollInputBoardStates();
            ioBoardsInterruptMonitor.StartPollingAsync();
        }
        public override void Setup()
        {
            var hsrel5 = CCToolsBoardController.CreateHSREL5(InstalledDevice.ReadingRoomHSREL5, new I2CSlaveAddress(62));
            var input2 = Controller.Device <HSPE16InputOnly>(InstalledDevice.Input2);

            var i2cHardwareBridge = Controller.GetDevice <I2CHardwareBridge>();

            const int SensorPin = 9;

            var room = Controller.CreateArea(Room.ReadingRoom)
                       .WithTemperatureSensor(ReadingRoom.TemperatureSensor, i2cHardwareBridge.DHT22Accessor.GetTemperatureSensor(SensorPin))
                       .WithHumiditySensor(ReadingRoom.HumiditySensor, i2cHardwareBridge.DHT22Accessor.GetHumiditySensor(SensorPin))
                       .WithLamp(ReadingRoom.LightCeilingMiddle, hsrel5.GetOutput(6).WithInvertedState())
                       .WithRollerShutter(ReadingRoom.RollerShutter, hsrel5[HSREL5Pin.Relay4], hsrel5[HSREL5Pin.Relay3])
                       .WithSocket(ReadingRoom.SocketWindow, hsrel5[HSREL5Pin.Relay0])
                       .WithSocket(ReadingRoom.SocketWallLeft, hsrel5[HSREL5Pin.Relay1])
                       .WithSocket(ReadingRoom.SocketWallRight, hsrel5[HSREL5Pin.Relay2])
                       .WithButton(ReadingRoom.Button, input2.GetInput(13))
                       .WithWindow(ReadingRoom.Window, w => w.WithCenterCasement(input2.GetInput(8))) // Tilt = input2.GetInput(9) -- currently broken!
                       .WithRollerShutterButtons(ReadingRoom.RollerShutterButtonUp, input2.GetInput(12), ReadingRoom.RollerShutterButtonDown, input2.GetInput(11));

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

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

            Controller.ServiceLocator.GetService <SynonymService>().AddSynonymsForArea(Room.ReadingRoom, "Lesezimmer", "Gästezimmer", "ReadingRoom");
        }
示例#7
0
        public void Setup(Controller controller, CCToolsBoardController ccToolsController)
        {
            var hsrel5 = ccToolsController.CreateHSREL5(Device.ChildrensRoomHSREL5, new I2CSlaveAddress(63));
            var input0 = controller.Device <HSPE16InputOnly>(Device.Input0);

            var i2cHardwareBridge = controller.Device <I2CHardwareBridge>();

            const int SensorPin = 7;

            var childrensRoom = controller.CreateArea(Room.ChildrensRoom)
                                .WithTemperatureSensor(ChildrensRoom.TemperatureSensor, i2cHardwareBridge.DHT22Accessor.GetTemperatureSensor(SensorPin))
                                .WithHumiditySensor(ChildrensRoom.HumiditySensor, i2cHardwareBridge.DHT22Accessor.GetHumiditySensor(SensorPin))
                                .WithLamp(ChildrensRoom.LightCeilingMiddle, hsrel5[HSREL5Pin.GPIO1].WithInvertedState())
                                .WithRollerShutter(ChildrensRoom.RollerShutter, hsrel5[HSREL5Pin.Relay4], hsrel5[HSREL5Pin.Relay3])
                                .WithSocket(ChildrensRoom.SocketWindow, hsrel5[HSREL5Pin.Relay0])
                                .WithSocket(ChildrensRoom.SocketWallLeft, hsrel5[HSREL5Pin.Relay1])
                                .WithSocket(ChildrensRoom.SocketWallRight, hsrel5[HSREL5Pin.Relay2])
                                .WithButton(ChildrensRoom.Button, input0.GetInput(0))
                                .WithWindow(ChildrensRoom.Window, w => w.WithCenterCasement(input0.GetInput(5), input0.GetInput(4)))
                                .WithRollerShutterButtons(ChildrensRoom.RollerShutterButtons, input0.GetInput(1), input0.GetInput(2));

            childrensRoom.Lamp(ChildrensRoom.LightCeilingMiddle).ConnectToggleActionWith(childrensRoom.Button(ChildrensRoom.Button));

            childrensRoom.SetupRollerShutterAutomation().WithRollerShutters(childrensRoom.RollerShutter(ChildrensRoom.RollerShutter));
            childrensRoom.RollerShutter(ChildrensRoom.RollerShutter)
            .ConnectWith(childrensRoom.RollerShutterButtons(ChildrensRoom.RollerShutterButtons));
        }
        public override void Setup()
        {
            var hsrel5 = CCToolsBoardController.CreateHSREL5(InstalledDevice.ChildrensRoomHSREL5, new I2CSlaveAddress(63));
            var input0 = Controller.Device <HSPE16InputOnly>(InstalledDevice.Input0);

            var i2cHardwareBridge = Controller.GetDevice <I2CHardwareBridge>();

            const int SensorPin = 7;

            var room = Controller.CreateArea(Room.ChildrensRoom)
                       .WithTemperatureSensor(ChildrensRoom.TemperatureSensor, i2cHardwareBridge.DHT22Accessor.GetTemperatureSensor(SensorPin))
                       .WithHumiditySensor(ChildrensRoom.HumiditySensor, i2cHardwareBridge.DHT22Accessor.GetHumiditySensor(SensorPin))
                       .WithLamp(ChildrensRoom.LightCeilingMiddle, hsrel5[HSREL5Pin.GPIO1].WithInvertedState())
                       .WithRollerShutter(ChildrensRoom.RollerShutter, hsrel5[HSREL5Pin.Relay4], hsrel5[HSREL5Pin.Relay3])
                       .WithSocket(ChildrensRoom.SocketWindow, hsrel5[HSREL5Pin.Relay0])
                       .WithSocket(ChildrensRoom.SocketWallLeft, hsrel5[HSREL5Pin.Relay1])
                       .WithSocket(ChildrensRoom.SocketWallRight, hsrel5[HSREL5Pin.Relay2])
                       .WithButton(ChildrensRoom.Button, input0.GetInput(0))
                       .WithWindow(ChildrensRoom.Window, w => w.WithCenterCasement(input0.GetInput(5), input0.GetInput(4)))
                       .WithRollerShutterButtons(ChildrensRoom.RollerShutterButtonUp, input0.GetInput(1), ChildrensRoom.RollerShutterButtonDown, input0.GetInput(2));

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

            room.SetupRollerShutterAutomation().WithRollerShutters(room.GetRollerShutter(ChildrensRoom.RollerShutter));
            room.GetRollerShutter(ChildrensRoom.RollerShutter)
            .ConnectWith(room.GetButton(ChildrensRoom.RollerShutterButtonUp), room.GetButton(ChildrensRoom.RollerShutterButtonDown));

            Controller.ServiceLocator.GetService <SynonymService>().AddSynonymsForArea(Room.ChildrensRoom, "Kinderzimmer", "ChildrensRoom");
        }
示例#9
0
        protected override async Task ConfigureAsync()
        {
            AddDevice(new BuiltInI2CBus());

            var ccToolsBoardController = new CCToolsBoardController(this, GetDevice <II2CBus>());

            AddDevice(new Pi2PortController());
            AddDevice(ccToolsBoardController);
            AddDevice(new I2CHardwareBridge(new I2CSlaveAddress(50), GetDevice <II2CBus>(), ServiceLocator.GetService <ISchedulerService>()));
            AddDevice(SetupRemoteSwitchController());

            ServiceLocator.RegisterService(typeof(SynonymService), new SynonymService());
            ServiceLocator.RegisterService(typeof(OpenWeatherMapService),
                                           new OpenWeatherMapService(
                                               ApiController,
                                               ServiceLocator.GetService <IDateTimeService>(),
                                               ServiceLocator.GetService <ISchedulerService>(),
                                               ServiceLocator.GetService <ISystemInformationService>()));

            SetupTelegramBot();
            SetupTwitterClient();

            ServiceLocator.GetService <SynonymService>().TryLoadPersistedSynonyms();

            ccToolsBoardController.CreateHSPE16InputOnly(InstalledDevice.Input0, new I2CSlaveAddress(42));
            ccToolsBoardController.CreateHSPE16InputOnly(InstalledDevice.Input1, new I2CSlaveAddress(43));
            ccToolsBoardController.CreateHSPE16InputOnly(InstalledDevice.Input2, new I2CSlaveAddress(47));
            ccToolsBoardController.CreateHSPE16InputOnly(InstalledDevice.Input3, new I2CSlaveAddress(45));
            ccToolsBoardController.CreateHSPE16InputOnly(InstalledDevice.Input4, new I2CSlaveAddress(46));
            ccToolsBoardController.CreateHSPE16InputOnly(InstalledDevice.Input5, new I2CSlaveAddress(44));

            new BedroomConfiguration(this).Setup();
            new OfficeConfiguration(this).Setup();
            new UpperBathroomConfiguration(this).Setup();
            new ReadingRoomConfiguration(this).Setup();
            new ChildrensRoomRoomConfiguration(this).Setup();
            new KitchenConfiguration(this).Setup();
            new FloorConfiguration(this).Setup();
            new LowerBathroomConfiguration(this).Setup();
            new StoreroomConfiguration(this).Setup();
            new LivingRoomConfiguration(this).Setup();

            ServiceLocator.GetService <SynonymService>().RegisterDefaultComponentStateSynonyms(this);

            InitializeAzureCloudApiEndpoint();

            var ioBoardsInterruptMonitor = new InterruptMonitor(GetDevice <Pi2PortController>().GetInput(4));

            ioBoardsInterruptMonitor.InterruptDetected += (s, e) => ccToolsBoardController.PollInputBoardStates();
            ioBoardsInterruptMonitor.Start();

            await base.ConfigureAsync();
        }
示例#10
0
        public override void Setup()
        {
            var hsrel5 = CCToolsBoardController.CreateHSREL5(InstalledDevice.KitchenHSREL5, new I2CSlaveAddress(58));
            var hspe8  = CCToolsBoardController.CreateHSPE8OutputOnly(InstalledDevice.KitchenHSPE8, new I2CSlaveAddress(39));

            var input0 = Controller.Device <HSPE16InputOnly>(InstalledDevice.Input0);
            var input1 = Controller.Device <HSPE16InputOnly>(InstalledDevice.Input1);
            var input2 = Controller.Device <HSPE16InputOnly>(InstalledDevice.Input2);

            var i2cHardwareBridge = Controller.GetDevice <I2CHardwareBridge>();

            const int SensorPin = 11;

            var room = Controller.CreateArea(Room.Kitchen)
                       .WithTemperatureSensor(Kitchen.TemperatureSensor, i2cHardwareBridge.DHT22Accessor.GetTemperatureSensor(SensorPin))
                       .WithHumiditySensor(Kitchen.HumiditySensor, i2cHardwareBridge.DHT22Accessor.GetHumiditySensor(SensorPin))
                       .WithMotionDetector(Kitchen.MotionDetector, input1.GetInput(8))
                       .WithLamp(Kitchen.LightCeilingMiddle, hsrel5.GetOutput(5).WithInvertedState())
                       .WithLamp(Kitchen.LightCeilingWindow, hsrel5.GetOutput(6).WithInvertedState())
                       .WithLamp(Kitchen.LightCeilingWall, hsrel5.GetOutput(7).WithInvertedState())
                       .WithLamp(Kitchen.LightCeilingDoor, hspe8.GetOutput(0).WithInvertedState())
                       .WithLamp(Kitchen.LightCeilingPassageInner, hspe8.GetOutput(1).WithInvertedState())
                       .WithLamp(Kitchen.LightCeilingPassageOuter, hspe8.GetOutput(2).WithInvertedState())
                       .WithSocket(Kitchen.SocketWall, hsrel5.GetOutput(2))
                       .WithRollerShutter(Kitchen.RollerShutter, hsrel5.GetOutput(4), hsrel5.GetOutput(3))
                       .WithButton(Kitchen.ButtonKitchenette, input1.GetInput(11))
                       .WithButton(Kitchen.ButtonPassage, input1.GetInput(9))
                       .WithRollerShutterButtons(Kitchen.RollerShutterButtonUp, input2.GetInput(15), Kitchen.RollerShutterButtonDown, input2.GetInput(14))
                       .WithWindow(Kitchen.Window, w => w.WithCenterCasement(input0.GetInput(6), input0.GetInput(7)));

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

            room.SetupRollerShutterAutomation().WithRollerShutters(room.GetRollerShutter(Kitchen.RollerShutter));

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

            room.CombineActuators(Kitchen.CombinedAutomaticLights)
            .WithActuator(room.GetLamp(Kitchen.LightCeilingWall))
            .WithActuator(room.GetLamp(Kitchen.LightCeilingDoor))
            .WithActuator(room.GetLamp(Kitchen.LightCeilingWindow));

            room.SetupTurnOnAndOffAutomation()
            .WithTrigger(room.GetMotionDetector(Kitchen.MotionDetector))
            .WithTarget(room.GetActuator(Kitchen.CombinedAutomaticLights))
            .WithEnabledAtNight(Controller.GetService <IDaylightService>());

            Controller.GetService <SynonymService>().AddSynonymsForArea(Room.Kitchen, "Küche", "Kitchen");
        }
示例#11
0
        protected override void Initialize()
        {
            InitializeHealthMonitor(22);

            var pi2PortController = new Pi2PortController();

            AddDevice(new BuiltInI2CBus(Logger));
            AddDevice(new I2CHardwareBridge(new DeviceId("HB"), new I2CSlaveAddress(50), Device <II2CBus>(), Timer));
            AddDevice(new OpenWeatherMapWeatherStation(OpenWeatherMapWeatherStation.DefaultDeviceId, Timer, HttpApiController, Logger));

            var ccToolsBoardController = new CCToolsBoardController(this, Device <II2CBus>(), HttpApiController, Logger);

            var configurationParser = new ConfigurationParser(this);

            configurationParser.RegisterConfigurationExtender(new CCToolsConfigurationExtender(configurationParser, this));
            configurationParser.ParseConfiguration();

            ccToolsBoardController.CreateHSPE16InputOnly(Main.Device.Input0, new I2CSlaveAddress(42));
            ccToolsBoardController.CreateHSPE16InputOnly(Main.Device.Input1, new I2CSlaveAddress(43));
            ccToolsBoardController.CreateHSPE16InputOnly(Main.Device.Input2, new I2CSlaveAddress(47));
            ccToolsBoardController.CreateHSPE16InputOnly(Main.Device.Input3, new I2CSlaveAddress(45));
            ccToolsBoardController.CreateHSPE16InputOnly(Main.Device.Input4, new I2CSlaveAddress(46));
            ccToolsBoardController.CreateHSPE16InputOnly(Main.Device.Input5, new I2CSlaveAddress(44));

            RemoteSocketController remoteSwitchController = SetupRemoteSwitchController();

            new BedroomConfiguration(this, ccToolsBoardController).Setup();
            new OfficeConfiguration().Setup(this, ccToolsBoardController, remoteSwitchController);
            new UpperBathroomConfiguration(this, ccToolsBoardController).Setup();
            new ReadingRoomConfiguration().Setup(this, ccToolsBoardController);
            new ChildrensRoomRoomConfiguration().Setup(this, ccToolsBoardController);
            new KitchenConfiguration().Setup(this, ccToolsBoardController);
            new FloorConfiguration().Setup(this, ccToolsBoardController);
            new LowerBathroomConfiguration().Setup(this);
            new StoreroomConfiguration().Setup(this, ccToolsBoardController);
            new LivingRoomConfiguration().Setup(this, ccToolsBoardController);

            //AttachAzureEventHubPublisher(home);

            var localCsvFileWriter = new CsvHistory(Logger, HttpApiController);

            localCsvFileWriter.ConnectActuators(this);
            localCsvFileWriter.ExposeToApi(HttpApiController);

            var ioBoardsInterruptMonitor = new InterruptMonitor(pi2PortController.GetInput(4), Logger);

            ioBoardsInterruptMonitor.InterruptDetected += (s, e) => ccToolsBoardController.PollInputBoardStates();
            ioBoardsInterruptMonitor.StartPollingAsync();
        }
示例#12
0
        public override void Setup()
        {
            var hsrel8 = CCToolsBoardController.CreateHSREL8(InstalledDevice.LivingRoomHSREL8, new I2CSlaveAddress(18));
            var hsrel5 = CCToolsBoardController.CreateHSREL5(InstalledDevice.LivingRoomHSREL5, new I2CSlaveAddress(57));

            var input0 = Controller.Device <HSPE16InputOnly>(InstalledDevice.Input0);
            var input1 = Controller.Device <HSPE16InputOnly>(InstalledDevice.Input1);

            var i2cHardwareBridge = Controller.GetDevice <I2CHardwareBridge>();

            const int SensorPin = 12;

            var room = Controller.CreateArea(Room.LivingRoom)
                       .WithTemperatureSensor(LivingRoom.TemperatureSensor, i2cHardwareBridge.DHT22Accessor.GetTemperatureSensor(SensorPin))
                       .WithHumiditySensor(LivingRoom.HumiditySensor, i2cHardwareBridge.DHT22Accessor.GetHumiditySensor(SensorPin))
                       .WithLamp(LivingRoom.LampCouch, hsrel8.GetOutput(8).WithInvertedState())
                       .WithLamp(LivingRoom.LampDiningTable, hsrel8.GetOutput(9).WithInvertedState())
                       .WithSocket(LivingRoom.SocketWindowLeftLower, hsrel8.GetOutput(1))
                       .WithSocket(LivingRoom.SocketWindowMiddleLower, hsrel8.GetOutput(2))
                       .WithSocket(LivingRoom.SocketWindowRightLower, hsrel8.GetOutput(3))
                       .WithSocket(LivingRoom.SocketWindowLeftUpper, hsrel8.GetOutput(5))
                       .WithSocket(LivingRoom.SocketWindowRightUpper, hsrel8.GetOutput(7))

                       .WithSocket(LivingRoom.SocketWallRightEdgeRight, hsrel8.GetOutput(4))

                       .WithSocket(LivingRoom.SocketWallLeftEdgeLeft, hsrel8.GetOutput(0))

                       .WithButton(LivingRoom.ButtonUpper, input0.GetInput(15))
                       .WithButton(LivingRoom.ButtonMiddle, input0.GetInput(14))
                       .WithButton(LivingRoom.ButtonLower, input0.GetInput(13))
                       .WithButton(LivingRoom.ButtonPassage, input1.GetInput(10))
                       .WithWindow(LivingRoom.WindowLeft,
                                   w => w.WithLeftCasement(input0.GetInput(10), input0.GetInput(11)).WithRightCasement(input0.GetInput(9), input0.GetInput(8)))
                       .WithWindow(LivingRoom.WindowRight,
                                   w => w.WithLeftCasement(input1.GetInput(14), input1.GetInput(15)).WithRightCasement(input1.GetInput(13), input1.GetInput(12)));

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

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

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

            Controller.ServiceLocator.GetService <SynonymService>().AddSynonymsForArea(Room.LivingRoom, "Wohnzimmer", "LivingRoom");
        }
        public UpperBathroomConfiguration(Controller controller, CCToolsBoardController ccToolsController)
        {
            if (controller == null)
            {
                throw new ArgumentNullException(nameof(controller));
            }
            if (ccToolsController == null)
            {
                throw new ArgumentNullException(nameof(ccToolsController));
            }

            _controller = controller;

            _hsrel5 = ccToolsController.CreateHSREL5(Device.UpperBathroomHSREL5, new I2CSlaveAddress(61));
            _input5 = controller.Device <HSPE16InputOnly>(Device.Input5);
        }
示例#14
0
        public void Setup(Controller controller, CCToolsBoardController ccToolsController, RemoteSocketController remoteSwitchController)
        {
            var hsrel8 = ccToolsController.CreateHSREL8(Device.OfficeHSREL8, new I2CSlaveAddress(20));
            var hspe8  = ccToolsController.CreateHSPE8OutputOnly(Device.UpperFloorAndOfficeHSPE8, new I2CSlaveAddress(37));
            var input4 = controller.Device <HSPE16InputOnly>(Device.Input4);
            var input5 = controller.Device <HSPE16InputOnly>(Device.Input5);

            const int SensorPin = 2;

            var i2cHardwareBridge = controller.Device <I2CHardwareBridge>();

            var office = controller.CreateArea(Room.Office)
                         .WithMotionDetector(Office.MotionDetector, input4.GetInput(13))
                         .WithTemperatureSensor(Office.TemperatureSensor, i2cHardwareBridge.DHT22Accessor.GetTemperatureSensor(SensorPin))
                         .WithHumiditySensor(Office.HumiditySensor, i2cHardwareBridge.DHT22Accessor.GetHumiditySensor(SensorPin))
                         .WithLamp(Office.LightCeilingFrontRight, hsrel8.GetOutput(8).WithInvertedState())
                         .WithLamp(Office.LightCeilingFrontMiddle, hspe8.GetOutput(2).WithInvertedState())
                         .WithLamp(Office.LightCeilingFrontLeft, hspe8.GetOutput(0).WithInvertedState())
                         .WithLamp(Office.LightCeilingMiddleRight, hsrel8.GetOutput(9).WithInvertedState())
                         .WithLamp(Office.LightCeilingMiddleMiddle, hspe8.GetOutput(3).WithInvertedState())
                         .WithLamp(Office.LightCeilingMiddleLeft, hspe8.GetOutput(1).WithInvertedState())
                         .WithLamp(Office.LightCeilingRearRight, hsrel8.GetOutput(12).WithInvertedState())
                         .WithLamp(Office.LightCeilingRearLeft, hsrel8.GetOutput(13).WithInvertedState())
                         .WithSocket(Office.SocketFrontLeft, hsrel8.GetOutput(0))
                         .WithSocket(Office.SocketFrontRight, hsrel8.GetOutput(6))
                         .WithSocket(Office.SocketWindowLeft, hsrel8.GetOutput(10).WithInvertedState())
                         .WithSocket(Office.SocketWindowRight, hsrel8.GetOutput(11).WithInvertedState())
                         .WithSocket(Office.SocketRearLeftEdge, hsrel8.GetOutput(7))
                         .WithSocket(Office.SocketRearLeft, hsrel8.GetOutput(2))
                         .WithSocket(Office.SocketRearRight, hsrel8.GetOutput(1))
                         .WithButton(Office.ButtonUpperLeft, input5.GetInput(0))
                         .WithButton(Office.ButtonLowerLeft, input5.GetInput(1))
                         .WithButton(Office.ButtonLowerRight, input4.GetInput(14))
                         .WithButton(Office.ButtonUpperRight, input4.GetInput(15))
                         .WithWindow(Office.WindowLeft, w => w.WithLeftCasement(input4.GetInput(11)).WithRightCasement(input4.GetInput(12), input4.GetInput(10)))
                         .WithWindow(Office.WindowRight, w => w.WithLeftCasement(input4.GetInput(8)).WithRightCasement(input4.GetInput(9), input5.GetInput(8)))
                         .WithSocket(Office.RemoteSocketDesk, remoteSwitchController.GetOutput(0))
                         .WithStateMachine(Office.CombinedCeilingLights, SetupLight);

            office.Button(Office.ButtonUpperLeft).WithLongAction(() =>
            {
                office.StateMachine(Office.CombinedCeilingLights).TurnOff();
                office.Socket(Office.SocketRearLeftEdge).TurnOff();
                office.Socket(Office.SocketRearLeft).TurnOff();
                office.Socket(Office.SocketFrontLeft).TurnOff();
            });
        }
        public void Setup(Controller controller, CCToolsBoardController ccToolsController)
        {
            var hsrel5 = ccToolsController.CreateHSREL5(Device.KitchenHSREL5, new I2CSlaveAddress(58));
            var hspe8  = ccToolsController.CreateHSPE8OutputOnly(Device.KitchenHSPE8, new I2CSlaveAddress(39));

            var input0 = controller.Device <HSPE16InputOnly>(Device.Input0);
            var input1 = controller.Device <HSPE16InputOnly>(Device.Input1);
            var input2 = controller.Device <HSPE16InputOnly>(Device.Input2);

            var i2cHardwareBridge = controller.Device <I2CHardwareBridge>();

            const int SensorPin = 11;

            var kitchen = controller.CreateArea(Room.Kitchen)
                          .WithTemperatureSensor(Kitchen.TemperatureSensor, i2cHardwareBridge.DHT22Accessor.GetTemperatureSensor(SensorPin))
                          .WithHumiditySensor(Kitchen.HumiditySensor, i2cHardwareBridge.DHT22Accessor.GetHumiditySensor(SensorPin))
                          .WithMotionDetector(Kitchen.MotionDetector, input1.GetInput(8))
                          .WithLamp(Kitchen.LightCeilingMiddle, hsrel5.GetOutput(5).WithInvertedState())
                          .WithLamp(Kitchen.LightCeilingWindow, hsrel5.GetOutput(6).WithInvertedState())
                          .WithLamp(Kitchen.LightCeilingWall, hsrel5.GetOutput(7).WithInvertedState())
                          .WithLamp(Kitchen.LightCeilingDoor, hspe8.GetOutput(0).WithInvertedState())
                          .WithLamp(Kitchen.LightCeilingPassageInner, hspe8.GetOutput(1).WithInvertedState())
                          .WithLamp(Kitchen.LightCeilingPassageOuter, hspe8.GetOutput(2).WithInvertedState())
                          .WithSocket(Kitchen.SocketWall, hsrel5.GetOutput(2))
                          .WithRollerShutter(Kitchen.RollerShutter, hsrel5.GetOutput(4), hsrel5.GetOutput(3))
                          .WithButton(Kitchen.ButtonKitchenette, input1.GetInput(11))
                          .WithButton(Kitchen.ButtonPassage, input1.GetInput(9))
                          .WithRollerShutterButtons(Kitchen.RollerShutterButtons, input2.GetInput(15), input2.GetInput(14))
                          .WithWindow(Kitchen.Window, w => w.WithCenterCasement(input0.GetInput(6), input0.GetInput(7)));

            kitchen.Lamp(Kitchen.LightCeilingMiddle).ConnectToggleActionWith(kitchen.Button(Kitchen.ButtonKitchenette));
            kitchen.Lamp(Kitchen.LightCeilingMiddle).ConnectToggleActionWith(kitchen.Button(Kitchen.ButtonPassage));

            kitchen.SetupRollerShutterAutomation().WithRollerShutters(kitchen.RollerShutter(Kitchen.RollerShutter));
            kitchen.RollerShutter(Kitchen.RollerShutter).ConnectWith(kitchen.RollerShutterButtons(Kitchen.RollerShutterButtons));

            kitchen.CombineActuators(Kitchen.CombinedAutomaticLights)
            .WithActuator(kitchen.Lamp(Kitchen.LightCeilingWall))
            .WithActuator(kitchen.Lamp(Kitchen.LightCeilingDoor))
            .WithActuator(kitchen.Lamp(Kitchen.LightCeilingWindow));

            kitchen.SetupTurnOnAndOffAutomation()
            .WithTrigger(kitchen.MotionDetector(Kitchen.MotionDetector))
            .WithTarget(kitchen.BinaryStateOutput(Kitchen.CombinedAutomaticLights))
            .WithEnabledAtNight(controller.Device <IWeatherStation>());
        }
        public void Setup(Controller controller, CCToolsBoardController ccToolsController)
        {
            var hsrel8 = ccToolsController.CreateHSREL8(Device.LivingRoomHSREL8, new I2CSlaveAddress(18));
            var hsrel5 = ccToolsController.CreateHSREL5(Device.LivingRoomHSREL5, new I2CSlaveAddress(57));

            var input0 = controller.Device <HSPE16InputOnly>(Device.Input0);
            var input1 = controller.Device <HSPE16InputOnly>(Device.Input1);

            var i2cHardwareBridge = controller.Device <I2CHardwareBridge>();

            const int SensorPin = 12;

            var livingRoom = controller.CreateArea(Room.LivingRoom)
                             .WithTemperatureSensor(LivingRoom.TemperatureSensor, i2cHardwareBridge.DHT22Accessor.GetTemperatureSensor(SensorPin))
                             .WithHumiditySensor(LivingRoom.HumiditySensor, i2cHardwareBridge.DHT22Accessor.GetHumiditySensor(SensorPin))
                             .WithLamp(LivingRoom.LampCouch, hsrel8.GetOutput(8).WithInvertedState())
                             .WithLamp(LivingRoom.LampDiningTable, hsrel8.GetOutput(9).WithInvertedState())
                             .WithSocket(LivingRoom.SocketWindowLeftLower, hsrel8.GetOutput(1))
                             .WithSocket(LivingRoom.SocketWindowMiddleLower, hsrel8.GetOutput(2))
                             .WithSocket(LivingRoom.SocketWindowRightLower, hsrel8.GetOutput(3))
                             .WithSocket(LivingRoom.SocketWindowLeftUpper, hsrel8.GetOutput(5))
                             .WithSocket(LivingRoom.SocketWindowRightUpper, hsrel8.GetOutput(7))

                             .WithSocket(LivingRoom.SocketWallRightEdgeRight, hsrel8.GetOutput(4))

                             .WithSocket(LivingRoom.SocketWallLeftEdgeLeft, hsrel8.GetOutput(0))

                             .WithButton(LivingRoom.ButtonUpper, input0.GetInput(15))
                             .WithButton(LivingRoom.ButtonMiddle, input0.GetInput(14))
                             .WithButton(LivingRoom.ButtonLower, input0.GetInput(13))
                             .WithButton(LivingRoom.ButtonPassage, input1.GetInput(10))
                             .WithWindow(LivingRoom.WindowLeft,
                                         w => w.WithLeftCasement(input0.GetInput(10), input0.GetInput(11)).WithRightCasement(input0.GetInput(9), input0.GetInput(8)))
                             .WithWindow(LivingRoom.WindowRight,
                                         w => w.WithLeftCasement(input1.GetInput(14), input1.GetInput(15)).WithRightCasement(input1.GetInput(13), input1.GetInput(12)));

            livingRoom.Lamp(LivingRoom.LampDiningTable)
            .ConnectToggleActionWith(livingRoom.Button(LivingRoom.ButtonUpper))
            .ConnectToggleActionWith(livingRoom.Button(LivingRoom.ButtonPassage));

            livingRoom.Lamp(LivingRoom.LampCouch).
            ConnectToggleActionWith(livingRoom.Button(LivingRoom.ButtonMiddle));

            livingRoom.Socket(LivingRoom.SocketWallRightEdgeRight).
            ConnectToggleActionWith(livingRoom.Button(LivingRoom.ButtonLower));
        }
示例#17
0
        public override void Setup()
        {
            var hsrel8LowerHeatingValves = CCToolsBoardController.CreateHSREL8(InstalledDevice.LowerHeatingValvesHSREL8, new I2CSlaveAddress(16));
            var hsrel5UpperHeatingValves = CCToolsBoardController.CreateHSREL5(InstalledDevice.UpperHeatingValvesHSREL5, new I2CSlaveAddress(56));

            var hsrel5Stairway = Controller.Device <HSREL5>(InstalledDevice.StairwayHSREL5);
            var input3         = Controller.Device <HSPE16InputOnly>(InstalledDevice.Input3);

            var storeroom = Controller.CreateArea(Room.Storeroom)
                            .WithMotionDetector(Storeroom.MotionDetector, input3.GetInput(12))
                            .WithMotionDetector(Storeroom.MotionDetectorCatLitterBox, input3.GetInput(11).WithInvertedState())
                            .WithLamp(Storeroom.LightCeiling, hsrel5Stairway.GetOutput(7).WithInvertedState())
                            .WithSocket(Storeroom.CatLitterBoxFan, hsrel8LowerHeatingValves.GetOutput(15));

            storeroom.SetupTurnOnAndOffAutomation()
            .WithTrigger(storeroom.GetMotionDetector(Storeroom.MotionDetector))
            .WithTarget(storeroom.GetLamp(Storeroom.LightCeiling))
            .WithOnDuration(TimeSpan.FromMinutes(1));

            storeroom.SetupTurnOnAndOffAutomation()
            .WithTrigger(storeroom.GetMotionDetector(Storeroom.MotionDetectorCatLitterBox))
            .WithTarget(storeroom.Socket(Storeroom.CatLitterBoxFan))
            .WithOnDuration(TimeSpan.FromMinutes(2));

            storeroom.WithSocket(Storeroom.CirculatingPump, hsrel5UpperHeatingValves.GetOutput(3));

            // TODO: Create RoomIdFactory like ActuatorIdFactory.
            storeroom.SetupTurnOnAndOffAutomation()
            .WithTrigger(Controller.GetArea(new AreaId(Room.Kitchen.ToString())).GetMotionDetector(KitchenConfiguration.Kitchen.MotionDetector))
            .WithTrigger(Controller.GetArea(new AreaId(Room.LowerBathroom.ToString())).GetMotionDetector(LowerBathroomConfiguration.LowerBathroom.MotionDetector))
            .WithTarget(storeroom.Socket(Storeroom.CirculatingPump))
            .WithPauseAfterEveryTurnOn(TimeSpan.FromHours(1))
            .WithOnDuration(TimeSpan.FromMinutes(1))
            .WithEnabledAtDay(Controller.GetService <IDaylightService>());

            _catLitterBoxTwitterSender =
                new CatLitterBoxTwitterSender(Controller.Timer).WithTrigger(
                    storeroom.GetMotionDetector(Storeroom.MotionDetectorCatLitterBox));

            Controller.GetService <SynonymService>().AddSynonymsForArea(Room.Storeroom, "Abstellkammer", "Storeroom");
        }
示例#18
0
        public override void Setup()
        {
            var hsrel8 = CCToolsBoardController.CreateHSREL8(InstalledDevice.OfficeHSREL8, new I2CSlaveAddress(20));
            var hspe8  = CCToolsBoardController.CreateHSPE8OutputOnly(InstalledDevice.UpperFloorAndOfficeHSPE8, new I2CSlaveAddress(37));
            var input4 = Controller.Device <HSPE16InputOnly>(InstalledDevice.Input4);
            var input5 = Controller.Device <HSPE16InputOnly>(InstalledDevice.Input5);

            const int SensorPin = 2;

            var i2cHardwareBridge = Controller.GetDevice <I2CHardwareBridge>();

            var room = Controller.CreateArea(Room.Office)
                       .WithMotionDetector(Office.MotionDetector, input4.GetInput(13))
                       .WithTemperatureSensor(Office.TemperatureSensor, i2cHardwareBridge.DHT22Accessor.GetTemperatureSensor(SensorPin))
                       .WithHumiditySensor(Office.HumiditySensor, i2cHardwareBridge.DHT22Accessor.GetHumiditySensor(SensorPin))
                       .WithSocket(Office.SocketFrontLeft, hsrel8.GetOutput(0))
                       .WithSocket(Office.SocketFrontRight, hsrel8.GetOutput(6))
                       .WithSocket(Office.SocketWindowLeft, hsrel8.GetOutput(10).WithInvertedState())
                       .WithSocket(Office.SocketWindowRight, hsrel8.GetOutput(11).WithInvertedState())
                       .WithSocket(Office.SocketRearLeftEdge, hsrel8.GetOutput(7))
                       .WithSocket(Office.SocketRearLeft, hsrel8.GetOutput(2))
                       .WithSocket(Office.SocketRearRight, hsrel8.GetOutput(1))
                       .WithButton(Office.ButtonUpperLeft, input5.GetInput(0))
                       .WithButton(Office.ButtonLowerLeft, input5.GetInput(1))
                       .WithButton(Office.ButtonLowerRight, input4.GetInput(14))
                       .WithButton(Office.ButtonUpperRight, input4.GetInput(15))
                       .WithWindow(Office.WindowLeft, w => w.WithLeftCasement(input4.GetInput(11)).WithRightCasement(input4.GetInput(12), input4.GetInput(10)))
                       .WithWindow(Office.WindowRight, w => w.WithLeftCasement(input4.GetInput(8)).WithRightCasement(input4.GetInput(9), input5.GetInput(8)))
                       .WithSocket(Office.RemoteSocketDesk, RemoteSocketController.GetOutput(0))
                       .WithStateMachine(Office.CombinedCeilingLights, (s, a) => SetupLight(s, hsrel8, hspe8, a));

            room.GetButton(Office.ButtonUpperLeft).GetPressedLongTrigger().Attach(() =>
            {
                room.GetStateMachine(Office.CombinedCeilingLights).TryTurnOff();
                room.Socket(Office.SocketRearLeftEdge).TryTurnOff();
                room.Socket(Office.SocketRearLeft).TryTurnOff();
                room.Socket(Office.SocketFrontLeft).TryTurnOff();
            });
        }
        public override void Setup()
        {
            var hsrel5 = CCToolsBoardController.CreateHSREL5(InstalledDevice.UpperBathroomHSREL5, new I2CSlaveAddress(61));
            var input5 = Controller.Device <HSPE16InputOnly>(InstalledDevice.Input5);

            const int SensorPin = 4;

            var i2cHardwareBridge = Controller.GetDevice <I2CHardwareBridge>();

            var room = Controller.CreateArea(Room.UpperBathroom)
                       .WithTemperatureSensor(UpperBathroom.TemperatureSensor, i2cHardwareBridge.DHT22Accessor.GetTemperatureSensor(SensorPin))
                       .WithHumiditySensor(UpperBathroom.HumiditySensor, i2cHardwareBridge.DHT22Accessor.GetHumiditySensor(SensorPin))
                       .WithMotionDetector(UpperBathroom.MotionDetector, input5.GetInput(15))
                       .WithLamp(UpperBathroom.LightCeilingDoor, hsrel5.GetOutput(0))
                       .WithLamp(UpperBathroom.LightCeilingEdge, hsrel5.GetOutput(1))
                       .WithLamp(UpperBathroom.LightCeilingMirrorCabinet, hsrel5.GetOutput(2))
                       .WithLamp(UpperBathroom.LampMirrorCabinet, hsrel5.GetOutput(3))
                       .WithStateMachine(UpperBathroom.Fan, (s, r) => SetupFan(s, r, hsrel5));

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

            room.SetupTurnOnAndOffAutomation()
            .WithTrigger(room.GetMotionDetector(UpperBathroom.MotionDetector))
            .WithTarget(combinedLights)
            .WithOnDuration(TimeSpan.FromMinutes(8));

            new BathroomFanAutomation(AutomationIdFactory.CreateIdFrom <BathroomFanAutomation>(room), Controller.Timer)
            .WithTrigger(room.GetMotionDetector(UpperBathroom.MotionDetector))
            .WithSlowDuration(TimeSpan.FromMinutes(8))
            .WithFastDuration(TimeSpan.FromMinutes(12))
            .WithActuator(room.GetStateMachine(UpperBathroom.Fan));

            Controller.GetService <SynonymService>().AddSynonymsForArea(Room.UpperBathroom, "BadOben", "UpperBathroom");
        }
示例#20
0
        protected override async Task ConfigureAsync()
        {
            var pi2PortController = new Pi2PortController();

            AddDevice(new BuiltInI2CBus());

            ServiceLocator.RegisterService(typeof(OpenWeatherMapWeatherService),
                                           new OpenWeatherMapService(ApiController,
                                                                     ServiceLocator.GetService <IDateTimeService>(),
                                                                     ServiceLocator.GetService <ISchedulerService>(),
                                                                     ServiceLocator.GetService <ISystemInformationService>()));

            var ccToolsFactory = new CCToolsBoardController(this, GetDevice <II2CBus>());
            var hsrt16         = ccToolsFactory.CreateHSRT16(Device.CellarHSRT16, new I2CSlaveAddress(32));

            var garden = this.CreateArea(RoomId.Garden)
                         .WithLamp(Garden.LampTerrace, hsrt16[HSRT16Pin.Relay15])
                         .WithLamp(Garden.LampGarage, hsrt16[HSRT16Pin.Relay14])
                         .WithLamp(Garden.LampTap, hsrt16[HSRT16Pin.Relay13])
                         .WithLamp(Garden.SpotlightRoof, hsrt16[HSRT16Pin.Relay12])
                         .WithLamp(Garden.LampRearArea, hsrt16[HSRT16Pin.Relay11])
                         .WithSocket(Garden.SocketPavillion, hsrt16[HSRT16Pin.Relay10])
                         // 9 = free
                         .WithLamp(Garden.LampParkingLot, new LogicalBinaryOutput().WithOutput(hsrt16[HSRT16Pin.Relay8]).WithOutput(hsrt16[HSRT16Pin.Relay6]).WithOutput(hsrt16[HSRT16Pin.Relay7]))
                         .WithButton(Garden.Button, pi2PortController.GetInput(4).WithInvertedState())
                         .WithStateMachine(Garden.StateMachine, SetupStateMachine);

            garden.GetStateMachine(Garden.StateMachine).ConnectMoveNextAndToggleOffWith(garden.GetButton(Garden.Button));

            garden.SetupConditionalOnAutomation()
            .WithActuator(garden.GetLamp(Garden.LampParkingLot))
            .WithOnAtNightRange()
            .WithOffBetweenRange(TimeSpan.Parse("22:30:00"), TimeSpan.Parse("05:00:00"));

            Timer.Tick += (s, e) => { pi2PortController.PollOpenInputPorts(); };

            await base.ConfigureAsync();
        }
示例#21
0
        protected override async Task ConfigureAsync()
        {
            AddDevice(new BuiltInI2CBus());

            var piPortController = new Pi2PortController();

            AddDevice(piPortController);

            var ccToolsBoardController = new CCToolsBoardController(this, GetDevice <II2CBus>());

            AddDevice(ccToolsBoardController);

            // Setup the remote switch 433Mhz sender which is attached to the I2C bus (Arduino Nano).
            AddDevice(new I2CHardwareBridge(new I2CSlaveAddress(50), GetDevice <II2CBus>(), ServiceLocator.GetService <ISchedulerService>()));

            ServiceLocator.RegisterService(typeof(SynonymService), new SynonymService());
            ServiceLocator.RegisterService(typeof(OpenWeatherMapService),
                                           new OpenWeatherMapService(ApiController,
                                                                     ServiceLocator.GetService <IDateTimeService>(),
                                                                     ServiceLocator.GetService <ISchedulerService>(),
                                                                     ServiceLocator.GetService <ISystemInformationService>()));

            SetupRoom();

            ServiceLocator.GetService <SynonymService>().TryLoadPersistedSynonyms();
            ServiceLocator.GetService <SynonymService>().RegisterDefaultComponentStateSynonyms(this);

            Timer.Tick += (s, e) =>
            {
                piPortController.PollOpenInputPorts();
                ccToolsBoardController.PollInputBoardStates();
            };

            SetupDemo();

            await base.ConfigureAsync();
        }
示例#22
0
        protected override void Initialize()
        {
            // Setup the health monitor which tracks the average time and let an LED blink if everything is healthy.
            InitializeHealthMonitor(LedGpio);

            // Setup the controller which provides ports from the GPIOs of the Pi2.
            var pi2PortController = new Pi2PortController();

            // Setup the wrapper for I2C bus access.
            var i2CBus = new BuiltInI2CBus(Logger);

            // Setup the controller which creates ports for IO boards from CCTools (or based on PCF8574/MAX7311/PCA9555D).
            var ccToolsBoardController = new CCToolsBoardController(this, i2CBus, HttpApiController, Logger);
            var hspe16 = ccToolsBoardController.CreateHSPE16InputOnly(InstalledDevice.HSPE16, new I2CSlaveAddress(41));
            var hsrel8 = ccToolsBoardController.CreateHSREL8(InstalledDevice.HSRel8, new I2CSlaveAddress(40));
            var hsrel5 = ccToolsBoardController.CreateHSREL5(InstalledDevice.HSRel5, new I2CSlaveAddress(56));

            // Setup the remote switch 433Mhz sender which is attached to the I2C bus (Arduino Nano).
            var i2CHardwareBridge  = new I2CHardwareBridge(new DeviceId("HB"), new I2CSlaveAddress(50), i2CBus, Timer);
            var remoteSwitchSender = new LPD433MHzSignalSender(i2CHardwareBridge, I2CHardwareBridge433MHzSenderPin, HttpApiController);

            // Setup the controller which creates ports for wireless sockets (433Mhz).
            var ic = new IntertechnoCodeSequenceProvider();
            var remoteSwitchController = new RemoteSocketController(new DeviceId("RemoteSocketController"), remoteSwitchSender, Timer)
                                         .WithRemoteSocket(0, ic.GetSequence(IntertechnoSystemCode.A, IntertechnoUnitCode.Unit1, RemoteSocketCommand.TurnOn), ic.GetSequence(IntertechnoSystemCode.A, IntertechnoUnitCode.Unit1, RemoteSocketCommand.TurnOff));

            // Setup the weather station which provides sunrise and sunset information.
            AddDevice(new OpenWeatherMapWeatherStation(OpenWeatherMapWeatherStation.DefaultDeviceId, Timer, HttpApiController, Logger));

            // Add the example area with the example actuators.
            var area = this.CreateArea(Room.ExampleRoom)
                       .WithTemperatureSensor(ExampleRoom.TemperatureSensor, i2CHardwareBridge.DHT22Accessor.GetTemperatureSensor(5))
                       .WithHumiditySensor(ExampleRoom.HumiditySensor, i2CHardwareBridge.DHT22Accessor.GetHumiditySensor(5))
                       .WithMotionDetector(ExampleRoom.MotionDetector, hspe16.GetInput(8))
                       .WithWindow(ExampleRoom.Window, w => w.WithCenterCasement(hspe16.GetInput(0)))
                       .WithLamp(ExampleRoom.Lamp1, remoteSwitchController.GetOutput(0))
                       .WithSocket(ExampleRoom.Socket1, hsrel5.GetOutput(0))
                       .WithSocket(ExampleRoom.Socket2, hsrel5.GetOutput(4))
                       .WithSocket(ExampleRoom.BathroomFan, hsrel5.GetOutput(3))
                       .WithLamp(ExampleRoom.Lamp2, hsrel8.GetOutput(0))
                       .WithLamp(ExampleRoom.Lamp3, hsrel8.GetOutput(1))
                       .WithLamp(ExampleRoom.Lamp4, hsrel8.GetOutput(2))
                       .WithLamp(ExampleRoom.Lamp5, hsrel8.GetOutput(3))
                       .WithLamp(ExampleRoom.Lamp6, hsrel8.GetOutput(4))
                       .WithButton(ExampleRoom.Button1, hspe16.GetInput(1))
                       .WithButton(ExampleRoom.Button2, hspe16.GetInput(2))
                       .WithVirtualButtonGroup(ExampleRoom.LedStripRemote, g => SetupLEDStripRemote(i2CHardwareBridge, g))
                       .WithStateMachine(ExampleRoom.CeilingFan, (sm, r) => SetupCeilingFan(sm));

            area.Lamp(ExampleRoom.Lamp5).ConnectToggleActionWith(area.Button(ExampleRoom.Button1));
            area.Lamp(ExampleRoom.Lamp6).ConnectToggleActionWith(area.Button(ExampleRoom.Button1), ButtonPressedDuration.Long);
            area.StateMachine(ExampleRoom.CeilingFan).ConnectMoveNextAndToggleOffWith(area.Button(ExampleRoom.Button2));

            SetupHumidityDependingOutput(area.HumiditySensor(ExampleRoom.HumiditySensor), hsrel8.GetOutput(5));

            area.SetupTurnOnAndOffAutomation()
            .WithTrigger(area.MotionDetector(ExampleRoom.MotionDetector))
            .WithTarget(area.BinaryStateOutput(ExampleRoom.BathroomFan))
            .WithTarget(area.BinaryStateOutput(ExampleRoom.Lamp2))
            .WithOnDuration(TimeSpan.FromSeconds(10));

            Timer.Tick += (s, e) =>
            {
                pi2PortController.PollOpenInputPorts();
                ccToolsBoardController.PollInputBoardStates();
            };
        }
示例#23
0
        public override void Setup()
        {
            var hsrel5 = CCToolsBoardController.CreateHSREL5(InstalledDevice.BedroomHSREL5, new I2CSlaveAddress(38));
            var hsrel8 = CCToolsBoardController.CreateHSREL8(InstalledDevice.BedroomHSREL8, new I2CSlaveAddress(21));
            var input5 = Controller.Device <HSPE16InputOnly>(InstalledDevice.Input5);
            var input4 = Controller.Device <HSPE16InputOnly>(InstalledDevice.Input4);

            var       i2cHardwareBridge = Controller.GetDevice <I2CHardwareBridge>();
            const int SensorPin         = 6;

            var room = Controller.CreateArea(Room.Bedroom)
                       .WithTemperatureSensor(Bedroom.TemperatureSensor, i2cHardwareBridge.DHT22Accessor.GetTemperatureSensor(SensorPin))
                       .WithHumiditySensor(Bedroom.HumiditySensor, i2cHardwareBridge.DHT22Accessor.GetHumiditySensor(SensorPin))
                       .WithMotionDetector(Bedroom.MotionDetector, input5.GetInput(12))
                       .WithLamp(Bedroom.LightCeiling, hsrel5.GetOutput(5).WithInvertedState())
                       .WithLamp(Bedroom.LightCeilingWindow, hsrel5.GetOutput(6).WithInvertedState())
                       .WithLamp(Bedroom.LightCeilingWall, hsrel5.GetOutput(7).WithInvertedState())
                       .WithSocket(Bedroom.SocketWindowLeft, hsrel5.GetOutput(0))
                       .WithSocket(Bedroom.SocketWindowRight, hsrel5.GetOutput(1))
                       .WithSocket(Bedroom.SocketWall, hsrel5.GetOutput(2))
                       .WithSocket(Bedroom.SocketWallEdge, hsrel5.GetOutput(3))
                       .WithSocket(Bedroom.SocketBedLeft, hsrel8.GetOutput(7))
                       .WithSocket(Bedroom.SocketBedRight, hsrel8.GetOutput(9))
                       .WithLamp(Bedroom.LampBedLeft, hsrel5.GetOutput(4))
                       .WithLamp(Bedroom.LampBedRight, hsrel8.GetOutput(8).WithInvertedState())
                       .WithButton(Bedroom.ButtonDoor, input5.GetInput(11))
                       .WithButton(Bedroom.ButtonWindowUpper, input5.GetInput(10))
                       .WithButton(Bedroom.ButtonWindowLower, input5.GetInput(13))
                       .WithButton(Bedroom.ButtonBedLeftInner, input4.GetInput(2))
                       .WithButton(Bedroom.ButtonBedLeftOuter, input4.GetInput(0))
                       .WithButton(Bedroom.ButtonBedRightInner, input4.GetInput(1))
                       .WithButton(Bedroom.ButtonBedRightOuter, input4.GetInput(3))
                       .WithRollerShutter(Bedroom.RollerShutterLeft, hsrel8.GetOutput(6), hsrel8.GetOutput(5))
                       .WithRollerShutter(Bedroom.RollerShutterRight, hsrel8.GetOutput(3), hsrel8.GetOutput(4))
                       .WithRollerShutterButtons(Bedroom.RollerShutterButtonsUpperUp, input5.GetInput(6), Bedroom.RollerShutterButtonsUpperDown, input5.GetInput(7))
                       .WithRollerShutterButtons(Bedroom.RollerShutterButtonsLowerUp, input5.GetInput(4), Bedroom.RollerShutterButtonsLowerDown, input5.GetInput(5))
                       .WithWindow(Bedroom.WindowLeft, w => w.WithCenterCasement(input5.GetInput(2)))
                       .WithWindow(Bedroom.WindowRight, w => w.WithCenterCasement(input5.GetInput(3)));

            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));

            room.CombineActuators(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();
            });

            room.SetupRollerShutterAutomation()
            .WithRollerShutters(room.GetRollerShutters())
            .WithDoNotOpenBefore(TimeSpan.FromHours(7).Add(TimeSpan.FromMinutes(15)))
            .WithCloseIfOutsideTemperatureIsGreaterThan(24)
            .WithDoNotOpenIfOutsideTemperatureIsBelowThan(3);

            room.SetupTurnOnAndOffAutomation()
            .WithTrigger(room.GetMotionDetector(Bedroom.MotionDetector))
            .WithTarget(room.GetStateMachine(Bedroom.LightCeiling))
            .WithOnDuration(TimeSpan.FromSeconds(15))
            .WithTurnOnIfAllRollerShuttersClosed(room.GetRollerShutter(Bedroom.RollerShutterLeft), room.GetRollerShutter(Bedroom.RollerShutterRight))
            .WithEnabledAtNight(Controller.ServiceLocator.GetService <IDaylightService>())
            .WithSkipIfAnyActuatorIsAlreadyOn(room.GetLamp(Bedroom.LampBedLeft), room.GetLamp(Bedroom.LampBedRight));

            room.WithStateMachine(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());

            Controller.ServiceLocator.GetService <SynonymService>().AddSynonymsForArea(Room.Bedroom, "Schlafzimmer", "Bedroom");
        }
示例#24
0
        public override void Setup()
        {
            var hsrel5Stairway              = CCToolsBoardController.CreateHSREL5(InstalledDevice.StairwayHSREL5, new I2CSlaveAddress(60));
            var hspe8UpperFloor             = Controller.Device <HSPE8OutputOnly>(InstalledDevice.UpperFloorAndOfficeHSPE8);
            var hspe16FloorAndLowerBathroom = CCToolsBoardController.CreateHSPE16OutputOnly(InstalledDevice.LowerFloorAndLowerBathroomHSPE16, new I2CSlaveAddress(17));

            var input1 = Controller.Device <HSPE16InputOnly>(InstalledDevice.Input1);
            var input2 = Controller.Device <HSPE16InputOnly>(InstalledDevice.Input2);
            var input4 = Controller.Device <HSPE16InputOnly>(InstalledDevice.Input4);

            var i2cHardwareBridge = Controller.GetDevice <I2CHardwareBridge>();

            const int SensorPin = 5;

            var room = Controller.CreateArea(Room.Floor)
                       .WithMotionDetector(Floor.StairwayMotionDetector, input2.GetInput(1))
                       .WithMotionDetector(Floor.StairsLowerMotionDetector, input4.GetInput(7))
                       .WithMotionDetector(Floor.StairsUpperMotionDetector, input4.GetInput(6))
                       .WithMotionDetector(Floor.LowerFloorMotionDetector, input1.GetInput(4))
                       .WithTemperatureSensor(Floor.LowerFloorTemperatureSensor, i2cHardwareBridge.DHT22Accessor.GetTemperatureSensor(SensorPin))
                       .WithHumiditySensor(Floor.LowerFloorHumiditySensor, i2cHardwareBridge.DHT22Accessor.GetHumiditySensor(SensorPin))
                       .WithLamp(Floor.Lamp1, hspe16FloorAndLowerBathroom.GetOutput(5).WithInvertedState())
                       .WithLamp(Floor.Lamp2, hspe16FloorAndLowerBathroom.GetOutput(6).WithInvertedState())
                       .WithLamp(Floor.Lamp3, hspe16FloorAndLowerBathroom.GetOutput(7).WithInvertedState())
                       .WithLamp(Floor.StairwayLampCeiling, hsrel5Stairway.GetOutput(0))
                       .WithLamp(Floor.StairwayLampWall, hsrel5Stairway.GetOutput(1))
                       .WithRollerShutter(Floor.StairwayRollerShutter, hsrel5Stairway.GetOutput(4), hsrel5Stairway.GetOutput(3))
                       .WithButton(Floor.ButtonLowerFloorUpper, input1.GetInput(0))
                       .WithButton(Floor.ButtonLowerFloorLower, input1.GetInput(5))
                       .WithButton(Floor.ButtonLowerFloorAtBathroom, input1.GetInput(1))
                       .WithButton(Floor.ButtonLowerFloorAtKitchen, input1.GetInput(3))
                       .WithButton(Floor.ButtonStairsLowerUpper, input4.GetInput(5))
                       .WithButton(Floor.ButtonStairsLowerLower, input1.GetInput(2))
                       .WithButton(Floor.ButtonStairsUpper, input4.GetInput(4))
                       .WithButton(Floor.ButtonStairway, input1.GetInput(6));

            room.CombineActuators(Floor.CombinedStairwayLamp)
            .WithActuator(room.GetLamp(Floor.StairwayLampCeiling))
            .WithActuator(room.GetLamp(Floor.StairwayLampWall));

            SetupStairwayLamps(room);

            room.CombineActuators(Floor.CombinedLamps)
            .WithActuator(room.GetLamp(Floor.Lamp1))
            .WithActuator(room.GetLamp(Floor.Lamp2))
            .WithActuator(room.GetLamp(Floor.Lamp3));

            room.SetupTurnOnAndOffAutomation()
            .WithTrigger(room.GetMotionDetector(Floor.LowerFloorMotionDetector))
            .WithTrigger(room.GetButton(Floor.ButtonLowerFloorUpper).GetPressedShortlyTrigger())
            .WithTrigger(room.GetButton(Floor.ButtonLowerFloorAtBathroom).GetPressedShortlyTrigger())
            .WithTrigger(room.GetButton(Floor.ButtonLowerFloorAtKitchen).GetPressedShortlyTrigger())
            .WithTarget(room.GetActuator(Floor.CombinedLamps))
            .WithEnabledAtNight(Controller.ServiceLocator.GetService <IDaylightService>())
            .WithTurnOffIfButtonPressedWhileAlreadyOn()
            .WithOnDuration(TimeSpan.FromSeconds(20));

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

            room.SetupRollerShutterAutomation().WithRollerShutters(room.GetRollerShutter(Floor.StairwayRollerShutter));

            Controller.ServiceLocator.GetService <SynonymService>().AddSynonymsForArea(Room.Floor, "Flur", "Floor");
        }
        public void Setup(Controller controller, CCToolsBoardController ccToolsController)
        {
            var hsrel5Stairway              = ccToolsController.CreateHSREL5(Device.StairwayHSREL5, new I2CSlaveAddress(60));
            var hspe8UpperFloor             = controller.Device <HSPE8OutputOnly>(Device.UpperFloorAndOfficeHSPE8);
            var hspe16FloorAndLowerBathroom = ccToolsController.CreateHSPE16OutputOnly(Device.LowerFloorAndLowerBathroomHSPE16, new I2CSlaveAddress(17));

            var input1 = controller.Device <HSPE16InputOnly>(Device.Input1);
            var input2 = controller.Device <HSPE16InputOnly>(Device.Input2);
            var input4 = controller.Device <HSPE16InputOnly>(Device.Input4);

            var i2cHardwareBridge = controller.Device <I2CHardwareBridge>();

            const int SensorPin = 5;

            var floor = controller.CreateArea(Room.Floor)
                        .WithMotionDetector(Floor.StairwayMotionDetector, input2.GetInput(1))
                        .WithMotionDetector(Floor.StairsLowerMotionDetector, input4.GetInput(7))
                        .WithMotionDetector(Floor.StairsUpperMotionDetector, input4.GetInput(6))
                        .WithMotionDetector(Floor.LowerFloorMotionDetector, input1.GetInput(4))
                        .WithTemperatureSensor(Floor.LowerFloorTemperatureSensor, i2cHardwareBridge.DHT22Accessor.GetTemperatureSensor(SensorPin))
                        .WithHumiditySensor(Floor.LowerFloorHumiditySensor, i2cHardwareBridge.DHT22Accessor.GetHumiditySensor(SensorPin))
                        .WithLamp(Floor.Lamp1, hspe16FloorAndLowerBathroom.GetOutput(5).WithInvertedState())
                        .WithLamp(Floor.Lamp2, hspe16FloorAndLowerBathroom.GetOutput(6).WithInvertedState())
                        .WithLamp(Floor.Lamp3, hspe16FloorAndLowerBathroom.GetOutput(7).WithInvertedState())
                        .WithLamp(Floor.StairwayLampCeiling, hsrel5Stairway.GetOutput(0))
                        .WithLamp(Floor.StairwayLampWall, hsrel5Stairway.GetOutput(1))
                        .WithRollerShutter(Floor.StairwayRollerShutter, hsrel5Stairway.GetOutput(4), hsrel5Stairway.GetOutput(3))
                        .WithButton(Floor.ButtonLowerFloorUpper, input1.GetInput(0))
                        .WithButton(Floor.ButtonLowerFloorLower, input1.GetInput(5))
                        .WithButton(Floor.ButtonLowerFloorAtBathroom, input1.GetInput(1))
                        .WithButton(Floor.ButtonLowerFloorAtKitchen, input1.GetInput(3))
                        .WithButton(Floor.ButtonStairsLowerUpper, input4.GetInput(5))
                        .WithButton(Floor.ButtonStairsLowerLower, input1.GetInput(2))
                        .WithButton(Floor.ButtonStairsUpper, input4.GetInput(4))
                        .WithButton(Floor.ButtonStairway, input1.GetInput(6));

            floor.CombineActuators(Floor.CombinedStairwayLamp)
            .WithActuator(floor.Lamp(Floor.StairwayLampCeiling))
            .WithActuator(floor.Lamp(Floor.StairwayLampWall));

            floor.SetupTurnOnAndOffAutomation()
            .WithTrigger(floor.MotionDetector(Floor.StairwayMotionDetector))
            .WithTrigger(floor.Button(Floor.ButtonStairway).GetPressedShortlyTrigger())
            .WithTarget(floor.BinaryStateOutput(Floor.CombinedStairwayLamp))
            .WithEnabledAtNight(controller.Device <IWeatherStation>())
            .WithOnDuration(TimeSpan.FromSeconds(30));

            floor.CombineActuators(Floor.CombinedLamps)
            .WithActuator(floor.Lamp(Floor.Lamp1))
            .WithActuator(floor.Lamp(Floor.Lamp2))
            .WithActuator(floor.Lamp(Floor.Lamp3));

            floor.SetupTurnOnAndOffAutomation()
            .WithTrigger(floor.MotionDetector(Floor.LowerFloorMotionDetector))
            .WithTrigger(floor.Button(Floor.ButtonLowerFloorUpper).GetPressedShortlyTrigger())
            .WithTrigger(floor.Button(Floor.ButtonLowerFloorAtBathroom).GetPressedShortlyTrigger())
            .WithTrigger(floor.Button(Floor.ButtonLowerFloorAtKitchen).GetPressedShortlyTrigger())
            .WithTarget(floor.BinaryStateOutput(Floor.CombinedLamps))
            .WithEnabledAtNight(controller.Device <IWeatherStation>())
            .WithTurnOffIfButtonPressedWhileAlreadyOn()
            .WithOnDuration(TimeSpan.FromSeconds(20));

            SetupStairsCeilingLamps(floor, hspe8UpperFloor);
            SetupStairsLamps(floor, controller.Device <IWeatherStation>(), hspe16FloorAndLowerBathroom);

            floor.SetupRollerShutterAutomation().WithRollerShutters(floor.RollerShutter(Floor.StairwayRollerShutter));
        }