@@ -36,8 +36,7 @@ def __init__(
3636 """Initialize Scan Device."""
3737 super ().__init__ (mac , address , controller , loaded_callback )
3838 self ._switch_subscription : Callable [[], None ] | None = None
39- self ._switch_group_1 = SwitchGroup ()
40- self ._switch_group_2 = SwitchGroup ()
39+ self ._switch = SwitchGroup ()
4140
4241 async def load (self ) -> bool :
4342 """Load and activate Switch node features."""
@@ -55,8 +54,7 @@ async def load(self) -> bool:
5554 NodeFeature .BATTERY ,
5655 NodeFeature .INFO ,
5756 NodeFeature .PING ,
58- NodeFeature .SWITCH_GROUP_1 ,
59- NodeFeature .SWITCH_GROUP_2 ,
57+ NodeFeature .SWITCH ,
6058 ),
6159 )
6260 if await self .initialize ():
@@ -91,7 +89,7 @@ async def unload(self) -> None:
9189 @raise_not_loaded
9290 def switch (self ) -> bool :
9391 """Current state of switch."""
94- return bool (self ._switch_group_1 .state )
92+ return bool (self ._switch .state )
9593
9694 # endregion
9795
@@ -118,22 +116,13 @@ async def _switch_state_update(
118116 self .name ,
119117 switch_state ,
120118 )
121- if switch_group == 1 :
122- self ._switch_group_1 .state = switch_state
123- self ._switch_group_1 .group = switch_group
124- self ._switch_group_1 .timestampe = timestamp
119+ self ._switch .state = switch_state
120+ self ._switch .group = switch_group
121+ self ._switch .timestampe = timestamp
125122
126- await self .publish_feature_update_to_subscribers (
127- NodeFeature .SWITCH_GROUP_1 , self ._switch_group_1
128- )
129- elif switch_group == 2 :
130- self ._switch_group_2 .state = switch_state
131- self ._switch_group_2 .group = switch_group
132- self ._switch_group_2 .timestampe = timestamp
133-
134- await self .publish_feature_update_to_subscribers (
135- NodeFeature .SWITCH_GROUP_2 , self ._switch_group_2
136- )
123+ await self .publish_feature_update_to_subscribers (
124+ NodeFeature .SWITCH , self ._switch
125+ )
137126
138127 @raise_not_loaded
139128 async def get_state (self , features : tuple [NodeFeature ]) -> dict [NodeFeature , Any ]:
@@ -152,10 +141,8 @@ async def get_state(self, features: tuple[NodeFeature]) -> dict[NodeFeature, Any
152141 )
153142
154143 match feature :
155- case NodeFeature .SWITCH_GROUP_1 :
156- states [NodeFeature .SWITCH_GROUP_1 ] = self ._switch_group_1
157- case NodeFeature .SWITCH_GROUP_2 :
158- states [NodeFeature .SWITCH_GROUP_2 ] = self ._switch_group_2
144+ case NodeFeature .SWITCH :
145+ states [NodeFeature .SWITCH ] = self ._switch
159146 case _:
160147 state_result = await super ().get_state ((feature ,))
161148 states [feature ] = state_result [feature ]
0 commit comments