11"""Plugwise Climate component for Home Assistant."""
22
33import logging
4- from typing import Dict
54from Plugwise_Smile .Smile import Smile
65
76from homeassistant .components .climate import ClimateEntity
@@ -84,6 +83,7 @@ def __init__(self, api, coordinator, name, dev_id, loc_id, model, min_temp, max_
8483 super ().__init__ (api , coordinator )
8584
8685 self ._api = api
86+ self ._gateway_id = self ._api .gateway_id
8787 self ._name = name
8888 self ._dev_id = dev_id
8989 self ._loc_id = loc_id
@@ -96,9 +96,9 @@ def __init__(self, api, coordinator, name, dev_id, loc_id, model, min_temp, max_
9696 self ._preset_mode = None
9797 self ._presets = None
9898 self ._presets_list = None
99- self ._boiler_state = None
10099 self ._heating_state = None
101100 self ._cooling_state = None
101+ self ._compressor_state = None
102102 self ._dhw_state = None
103103 self ._hvac_mode = None
104104 self ._schema_names = None
@@ -109,48 +109,23 @@ def __init__(self, api, coordinator, name, dev_id, loc_id, model, min_temp, max_
109109 self ._schedule_temp = None
110110 self ._hvac_mode = None
111111 self ._single_thermostat = self ._api .single_master_thermostat ()
112+ self ._icon = THERMOSTAT_ICON
112113 self ._unique_id = f"cl-{ dev_id } -{ self ._name } "
113114
114115 @property
115116 def hvac_action (self ):
116117 """Return the current action."""
117118 if self ._single_thermostat :
118- if self ._heating_state or self . _boiler_state :
119+ if self ._heating_state :
119120 return CURRENT_HVAC_HEAT
120121 if self ._cooling_state :
121122 return CURRENT_HVAC_COOL
122123 return CURRENT_HVAC_IDLE
123- if self ._heating_state is not None or self . _boiler_state is not None :
124+ if self ._heating_state is not None :
124125 if self ._setpoint > self ._temperature :
125126 return CURRENT_HVAC_HEAT
126127 return CURRENT_HVAC_IDLE
127128
128- @property
129- def name (self ):
130- """Return the name of the thermostat, if any."""
131- return self ._name
132-
133- @property
134- def device_info (self ) -> Dict [str , any ]:
135- """Return the device information."""
136-
137- device_information = {
138- "identifiers" : {(DOMAIN , self ._dev_id )},
139- "name" : self ._name ,
140- "manufacturer" : "Plugwise" ,
141- "model" : self ._model .replace ("_" , " " ).title (),
142- }
143-
144- if self ._dev_id != self ._api .gateway_id :
145- device_information ["via_device" ] = (DOMAIN , self ._api .gateway_id )
146-
147- return device_information
148-
149- @property
150- def icon (self ):
151- """Return the icon to use in the frontend."""
152- return THERMOSTAT_ICON
153-
154129 @property
155130 def supported_features (self ):
156131 """Return the list of supported features."""
@@ -174,8 +149,8 @@ def preset_modes(self):
174149 @property
175150 def hvac_modes (self ):
176151 """Return the available hvac modes list."""
177- if self ._heating_state is not None or self . _boiler_state is not None :
178- if self ._cooling_state is not None :
152+ if self ._heating_state is not None :
153+ if self ._compressor_state is not None :
179154 return HVAC_MODES_HEAT_COOL
180155 return HVAC_MODES_HEAT_ONLY
181156
@@ -300,21 +275,18 @@ def _process_data(self):
300275 _LOGGER .error ("Received no heater_central_data for device %s." , self ._name )
301276 else :
302277 _LOGGER .debug ("Heater_central_data collected from Plugwise API" )
303- if "boiler_state" in heater_central_data :
304- if heater_central_data ["boiler_state" ] is not None :
305- self ._boiler_state = heater_central_data ["boiler_state" ]
306- if "heating_state" in heater_central_data :
307- if heater_central_data ["heating_state" ] is not None :
308- self ._heating_state = heater_central_data ["heating_state" ]
309- if "cooling_state" in heater_central_data :
310- if heater_central_data ["cooling_state" ] is not None :
311- self ._cooling_state = heater_central_data ["cooling_state" ]
278+ if heater_central_data .get ("heating_state" ) is not None :
279+ self ._heating_state = heater_central_data ["heating_state" ]
280+ if heater_central_data .get ("cooling_state" ) is not None :
281+ self ._cooling_state = heater_central_data ["cooling_state" ]
282+ if heater_central_data .get ("compressor_state" ) is not None :
283+ self ._compressor_state = heater_central_data ["compressor_state" ]
312284
313285 if self ._schema_status :
314286 self ._hvac_mode = HVAC_MODE_AUTO
315- elif self ._heating_state is not None or self . _boiler_state is not None :
287+ elif self ._heating_state is not None :
316288 self ._hvac_mode = HVAC_MODE_HEAT
317- if self ._cooling_state is not None :
289+ if self ._compressor_state is not None :
318290 self ._hvac_mode = HVAC_MODE_HEAT_COOL
319291
320292 self .async_write_ha_state ()
0 commit comments