public void Setup()
        {
            const int SensorPin = 4;

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

            var bathroom = _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, SetupFan);

            var combinedLights =
                bathroom.CombineActuators(UpperBathroom.CombinedCeilingLights)
                .WithActuator(bathroom.Lamp(UpperBathroom.LightCeilingDoor))
                .WithActuator(bathroom.Lamp(UpperBathroom.LightCeilingEdge))
                .WithActuator(bathroom.Lamp(UpperBathroom.LightCeilingMirrorCabinet))
                .WithActuator(bathroom.Lamp(UpperBathroom.LampMirrorCabinet));

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

            new BathroomFanAutomation(AutomationIdFactory.CreateIdFrom <BathroomFanAutomation>(bathroom), _controller.Timer)
            .WithTrigger(bathroom.MotionDetector(UpperBathroom.MotionDetector))
            .WithSlowDuration(TimeSpan.FromMinutes(8))
            .WithFastDuration(TimeSpan.FromMinutes(12))
            .WithActuator(bathroom.StateMachine(UpperBathroom.Fan));
        }
        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");
        }