@@ -22,6 +22,7 @@ namespace HA4IoT.Controller.Main.Main.Rooms
2222{
2323 internal class KitchenConfiguration
2424 {
25+ private readonly ISystemEventsService _systemEventsService ;
2526 private readonly IAreaRegistryService _areaService ;
2627 private readonly IDeviceRegistryService _deviceService ;
2728 private readonly CCToolsDeviceService _ccToolsBoardService ;
@@ -57,10 +58,14 @@ public enum Kitchen
5758 SocketWall ,
5859 SocketKitchenette ,
5960
61+ SocketCeiling1 , // Über Hängeschrank
62+ SocketCeiling2 , // Bei Dunsabzug
63+
6064 Window
6165 }
6266
6367 public KitchenConfiguration (
68+ ISystemEventsService systemEventsService ,
6469 IAreaRegistryService areaService ,
6570 IDeviceRegistryService deviceService ,
6671 CCToolsDeviceService ccToolsDeviceService ,
@@ -69,6 +74,7 @@ public KitchenConfiguration(
6974 ActuatorFactory actuatorFactory ,
7075 SensorFactory sensorFactory )
7176 {
77+ _systemEventsService = systemEventsService ?? throw new ArgumentNullException ( nameof ( systemEventsService ) ) ;
7278 _areaService = areaService ?? throw new ArgumentNullException ( nameof ( areaService ) ) ;
7379 _deviceService = deviceService ?? throw new ArgumentNullException ( nameof ( deviceService ) ) ;
7480 _ccToolsBoardService = ccToolsDeviceService ?? throw new ArgumentNullException ( nameof ( ccToolsDeviceService ) ) ;
@@ -102,18 +108,26 @@ public void Apply()
102108
103109 _sensorFactory . RegisterMotionDetector ( area , Kitchen . MotionDetector , input1 . GetInput ( 8 ) ) ;
104110
105- var rgb = _outpostDeviceService . GetRgbAdapter ( "RGBSK1" ) ;
111+ _actuatorFactory . RegisterLamp ( area , Kitchen . LightCeilingMiddle , hsrel5 [ HSREL5Pin . GPIO0 ] . WithInvertedState ( ) ) ;
112+ _actuatorFactory . RegisterLamp ( area , Kitchen . LightCeilingWindow , hsrel5 [ HSREL5Pin . GPIO1 ] . WithInvertedState ( ) ) ;
113+ _actuatorFactory . RegisterLamp ( area , Kitchen . LightCeilingWall , hsrel5 [ HSREL5Pin . GPIO2 ] . WithInvertedState ( ) ) ;
114+ _actuatorFactory . RegisterLamp ( area , Kitchen . LightCeilingDoor , hspe8 [ HSPE8Pin . GPIO0 ] . WithInvertedState ( ) ) ;
115+ _actuatorFactory . RegisterLamp ( area , Kitchen . LightCeilingPassageInner , hspe8 [ HSPE8Pin . GPIO1 ] . WithInvertedState ( ) ) ;
116+ _actuatorFactory . RegisterLamp ( area , Kitchen . LightCeilingPassageOuter , hspe8 [ HSPE8Pin . GPIO2 ] . WithInvertedState ( ) ) ;
117+ _actuatorFactory . RegisterLamp ( area , Kitchen . LightKitchenette , _outpostDeviceService . GetRgbAdapter ( "RGBSK1" ) ) ;
118+
119+ _actuatorFactory . RegisterSocket ( area , Kitchen . SocketKitchenette , hsrel5 [ HSREL5Pin . Relay1 ] ) ; // 0?
120+ _actuatorFactory . RegisterSocket ( area , Kitchen . SocketWall , hsrel5 [ HSREL5Pin . Relay2 ] ) ;
121+ _actuatorFactory . RegisterSocket ( area , Kitchen . SocketCeiling1 , hspe8 [ HSPE8Pin . GPIO3 ] . WithInvertedState ( ) ) ;
122+ _actuatorFactory . RegisterSocket ( area , Kitchen . SocketCeiling2 , hspe8 [ HSPE8Pin . GPIO4 ] . WithInvertedState ( ) ) ;
123+
124+ _systemEventsService . StartupCompleted += ( s , e ) =>
125+ {
126+ area . GetComponent ( Kitchen . SocketCeiling1 ) . TryTurnOn ( ) ;
127+ } ;
106128
107- _actuatorFactory . RegisterLamp ( area , Kitchen . LightCeilingPassageOuter , hspe8 . GetOutput ( 2 ) . WithInvertedState ( ) ) ;
108- _actuatorFactory . RegisterLamp ( area , Kitchen . LightCeilingMiddle , hsrel5 . GetOutput ( 5 ) . WithInvertedState ( ) ) ;
109- _actuatorFactory . RegisterLamp ( area , Kitchen . LightCeilingWindow , hsrel5 . GetOutput ( 6 ) . WithInvertedState ( ) ) ;
110- _actuatorFactory . RegisterLamp ( area , Kitchen . LightCeilingWall , hsrel5 . GetOutput ( 7 ) . WithInvertedState ( ) ) ;
111- _actuatorFactory . RegisterLamp ( area , Kitchen . LightCeilingDoor , hspe8 . GetOutput ( 0 ) . WithInvertedState ( ) ) ;
112- _actuatorFactory . RegisterLamp ( area , Kitchen . LightCeilingPassageInner , hspe8 . GetOutput ( 1 ) . WithInvertedState ( ) ) ;
113- _actuatorFactory . RegisterLamp ( area , Kitchen . LightKitchenette , rgb ) ;
129+ _actuatorFactory . RegisterRollerShutter ( area , Kitchen . RollerShutter , hsrel5 [ HSREL5Pin . Relay4 ] , hsrel5 [ HSREL5Pin . Relay3 ] ) ;
114130
115- _actuatorFactory . RegisterSocket ( area , Kitchen . SocketWall , hsrel5 . GetOutput ( 2 ) ) ;
116- _actuatorFactory . RegisterRollerShutter ( area , Kitchen . RollerShutter , hsrel5 . GetOutput ( 4 ) , hsrel5 . GetOutput ( 3 ) ) ;
117131 _sensorFactory . RegisterButton ( area , Kitchen . ButtonKitchenette , input1 . GetInput ( 11 ) ) ;
118132 _sensorFactory . RegisterButton ( area , Kitchen . ButtonPassage , input1 . GetInput ( 9 ) ) ;
119133 _sensorFactory . RegisterRollerShutterButtons ( area , Kitchen . RollerShutterButtonUp , input2 . GetInput ( 15 ) ,
@@ -128,7 +142,12 @@ public void Apply()
128142 area . GetRollerShutter ( Kitchen . RollerShutter ) . ConnectWith (
129143 area . GetButton ( Kitchen . RollerShutterButtonUp ) , area . GetButton ( Kitchen . RollerShutterButtonDown ) ) ;
130144
131- area . GetButton ( Kitchen . RollerShutterButtonUp ) . PressedLongTrigger . Attach ( ( ) => area . GetComponent ( Kitchen . LightKitchenette ) . TryTogglePowerState ( ) ) ;
145+ area . GetButton ( Kitchen . RollerShutterButtonUp ) . PressedLongTrigger . Attach ( ( ) =>
146+ {
147+ var light = area . GetComponent ( Kitchen . LightKitchenette ) ;
148+ light . TryTogglePowerState ( ) ;
149+ light . TrySetColor ( 0D , 0D , 1D ) ;
150+ } ) ;
132151
133152 _actuatorFactory . RegisterLogicalComponent ( area , Kitchen . CombinedAutomaticLights )
134153 . WithComponent ( area . GetLamp ( Kitchen . LightCeilingWall ) )
0 commit comments