@@ -786,36 +786,42 @@ def _update_anna_cooling(self, dev_id: str, data: DeviceZoneData) -> None:
786786
787787 Support added for Techneco Elga and Thercon Loria/Thermastage.
788788 """
789- if dev_id == self ._heater_id :
790- # Anna+Elga: base cooling_state on the elga-status-code
791- if "elga_status_code" in data :
792- if data ["thermostat_supports_cooling" ]:
793- # Techneco Elga has cooling-capability
794- self ._cooling_present = True
795- data ["model" ] = "Generic heater/cooler"
796- self ._cooling_enabled = data ["elga_status_code" ] in (8 , 9 )
797- data ["binary_sensors" ]["cooling_state" ] = self ._cooling_active = (
798- data ["elga_status_code" ] == 8
799- )
800- # Elga has no cooling-switch
801- if "cooling_ena_switch" in data ["switches" ]:
802- data ["switches" ].pop ("cooling_ena_switch" )
803- self ._count -= 1
789+ if dev_id != self ._heater_id :
790+ return
791+
792+ if "elga_status_code" in data :
793+ self ._update_elga_cooling (data )
794+ elif self ._cooling_present and "cooling_state" in data ["binary_sensors" ]:
795+ self ._update_loria_cooling (data )
796+
797+ self ._cleanup_data (data )
804798
805- data .pop ("elga_status_code" , None )
799+ def _update_elga_cooling (self , data : DeviceZoneData ) -> None :
800+ """# Anna+Elga: base cooling_state on the elga-status-code."""
801+ if data ["thermostat_supports_cooling" ]:
802+ # Techneco Elga has cooling-capability
803+ self ._cooling_present = True
804+ data ["model" ] = "Generic heater/cooler"
805+ self ._cooling_enabled = data ["elga_status_code" ] in (8 , 9 )
806+ data ["binary_sensors" ]["cooling_state" ] = self ._cooling_active = (
807+ data ["elga_status_code" ] == 8
808+ )
809+ # Elga has no cooling-switch
810+ if "cooling_ena_switch" in data ["switches" ]:
811+ data ["switches" ].pop ("cooling_ena_switch" )
806812 self ._count -= 1
807813
808- # Loria/Thermastage: cooling-related is based on cooling_state
809- # and modulation_level
810- elif self ._cooling_present and "cooling_state" in data ["binary_sensors" ]:
811- self ._cooling_enabled = data ["binary_sensors" ]["cooling_state" ]
812- self ._cooling_active = data ["sensors" ]["modulation_level" ] == 100
813- # For Loria the above does not work (pw-beta issue #301)
814- if "cooling_ena_switch" in data ["switches" ]:
815- self ._cooling_enabled = data ["switches" ]["cooling_ena_switch" ]
816- self ._cooling_active = data ["binary_sensors" ]["cooling_state" ]
814+ data .pop ("elga_status_code" , None )
815+ self ._count -= 1
817816
818- self ._cleanup_data (data )
817+ def _update_loria_cooling (self , data : DeviceZoneData ) -> None :
818+ """Loria/Thermastage: base cooling-related on cooling_state and modulation_level."""
819+ self ._cooling_enabled = data ["binary_sensors" ]["cooling_state" ]
820+ self ._cooling_active = data ["sensors" ]["modulation_level" ] == 100
821+ # For Loria the above does not work (pw-beta issue #301)
822+ if "cooling_ena_switch" in data ["switches" ]:
823+ self ._cooling_enabled = data ["switches" ]["cooling_ena_switch" ]
824+ self ._cooling_active = data ["binary_sensors" ]["cooling_state" ]
819825
820826 def _cleanup_data (self , data : DeviceZoneData ) -> None :
821827 """Helper-function for _get_measurement_data().
@@ -860,15 +866,11 @@ def _scan_thermostats(self) -> None:
860866
861867 for loc_id , loc_data in list (self ._thermo_locs .items ()):
862868 if loc_data ["primary_prio" ] != 0 :
863- self .zone_data .update (
864- {
865- loc_id : {
866- "dev_class" : "climate" ,
867- "name" : loc_data ["name" ],
868- "thermostats" : {"primary" : loc_data ["primary" ], "secondary" : loc_data ["secondary" ]}
869- }
870- }
871- )
869+ self .zone_data [loc_id ] = {
870+ "dev_class" : "climate" ,
871+ "name" : loc_data ["name" ],
872+ "thermostats" : {"primary" : loc_data ["primary" ], "secondary" : loc_data ["secondary" ]}
873+ }
872874 self ._count += 3
873875
874876 def _match_locations (self ) -> dict [str , ThermoLoc ]:
0 commit comments