@@ -688,22 +688,30 @@ def _get_actuator_functionalities(
688688 act_item = cast (ActuatorType , item )
689689 data [act_item ] = temp_dict
690690
691+ def _get_actuator_mode (self , appliance : etree , entity_id : str , key : str ) -> str | None :
692+ """Helper-function for _get_regulation_mode and _get_gateway_mode.
693+
694+ Collect the requested gateway mode.
695+ """
696+ if not (self .smile (ADAM ) and entity_id == self .gateway_id ):
697+ return None
698+
699+ if (search := search_actuator_functionalities (appliance , key )) is not None :
700+ return str (search .find ("mode" ).text )
701+
702+ return None
703+
691704 def _get_regulation_mode (
692705 self , appliance : etree , entity_id : str , data : GwEntityData
693706 ) -> None :
694707 """Helper-function for _get_measurement_data().
695708
696709 Adam: collect the gateway regulation_mode.
697710 """
698- if not (self .smile (ADAM ) and entity_id == self .gateway_id ):
699- return
700-
701- if (search := search_actuator_functionalities (
702- appliance , "regulation_mode_control_functionality"
703- )) is not None :
704- data ["select_regulation_mode" ] = search .find ("mode" ).text
711+ if (mode := self ._get_actuator_mode (appliance , entity_id , "regulation_mode_control_functionality" )) is not None :
712+ data ["select_regulation_mode" ] = mode
705713 self ._count += 1
706- self ._cooling_enabled = data [ "select_regulation_mode" ] == "cooling"
714+ self ._cooling_enabled = mode == "cooling"
707715
708716 def _get_gateway_mode (
709717 self , appliance : etree , entity_id : str , data : GwEntityData
@@ -712,13 +720,8 @@ def _get_gateway_mode(
712720
713721 Adam: collect the gateway mode.
714722 """
715- if not (self .smile (ADAM ) and entity_id == self .gateway_id ):
716- return
717-
718- if (search := search_actuator_functionalities (
719- appliance , "gateway_mode_control_functionality"
720- )) is not None :
721- data ["select_gateway_mode" ] = search .find ("mode" ).text
723+ if (mode := self ._get_actuator_mode (appliance , entity_id , "gateway_mode_control_functionality" )) is not None :
724+ data ["select_gateway_mode" ] = mode
722725 self ._count += 1
723726
724727 def _get_gateway_outdoor_temp (self , entity_id : str , data : GwEntityData ) -> None :
0 commit comments