3131 SYSTEM ,
3232 THERMOSTAT_CLASSES ,
3333)
34- from .exceptions import ConnectionFailedError , InvalidXMLError , UnsupportedDeviceError
34+ from .exceptions import (
35+ ConnectionFailedError ,
36+ InvalidSetupError ,
37+ InvalidXMLError ,
38+ UnsupportedDeviceError ,
39+ )
3540from .helper import SmileComm , SmileHelper , update_helper
3641
3742
@@ -108,9 +113,7 @@ def _device_data_switching_group(
108113 if member_data .get ("relay" ):
109114 counter += 1
110115
111- device_data ["relay" ] = True
112- if counter == 0 :
113- device_data ["relay" ] = False
116+ device_data ["relay" ] = counter != 0
114117
115118 return device_data
116119
@@ -124,9 +127,7 @@ def _device_data_adam(
124127 # Indicate heating_state based on valves being open in case of city-provided heating
125128 if details .get ("class" ) == "heater_central" :
126129 if self ._on_off_device and self ._heating_valves () is not None :
127- device_data ["heating_state" ] = True
128- if self ._heating_valves () == 0 :
129- device_data ["heating_state" ] = False
130+ device_data ["heating_state" ] = self ._heating_valves () != 0
130131
131132 return device_data
132133
@@ -156,21 +157,30 @@ def _device_data_climate(
156157 device_data ["last_used" ] = last_active
157158 device_data ["schedule_temperature" ] = sched_setpoint
158159
159- # Operation mode: auto, heat, cool
160- device_data ["mode" ] = "auto"
161- schedule_status = False
162- if sel_schema != "None" :
163- schedule_status = True
164- if not schedule_status :
165- device_data ["mode" ] = "heat"
166- if self ._heater_id is not None :
167- if self .cooling_active :
168- device_data ["mode" ] = "cool"
169-
170160 # Control_state, only for Adam master thermostats
171161 if ctrl_state := self ._control_state (loc_id ):
172162 device_data ["control_state" ] = ctrl_state
173163
164+ # Anna: indicate possible active heating/cooling operation-mode
165+ # Actual ongoing heating/cooling is shown via heating_state/cooling_state
166+ if "cooling_activation_outdoor_temperature" in device_data :
167+ self ._cooling_present = True
168+ if not self .cooling_active and self ._outdoor_temp > device_data .get (
169+ "cooling_activation_outdoor_temperature"
170+ ):
171+ self .cooling_active = True
172+ if self .cooling_active and self ._outdoor_temp < device_data .get (
173+ "cooling_deactivation_threshold"
174+ ):
175+ self .cooling_active = False
176+
177+ # Operation mode: auto, heat, cool
178+ device_data ["mode" ] = "auto"
179+ if sel_schema == "None" :
180+ device_data ["mode" ] = "heat"
181+ if self ._heater_id is not None and self .cooling_active :
182+ device_data ["mode" ] = "cool"
183+
174184 return device_data
175185
176186 def _get_device_data (self , dev_id : str ) -> dict [str , Any ]:
@@ -242,14 +252,18 @@ async def connect(self) -> bool:
242252 """Connect to Plugwise device and determine its name, type and version."""
243253 result = await self ._request (DOMAIN_OBJECTS )
244254 vendor_names : list [etree ] = result .findall ("./module/vendor_name" )
255+ vendor_models : list [etree ] = result .findall ("./module/vendor_model" )
256+ # Work-around for Stretch fv 2.7.18
245257 if not vendor_names :
246- # Work-around for Stretch fv 2.7.18
247258 result = await self ._request (MODULES )
248259 vendor_names = result .findall ("./module/vendor_name" )
249260
250261 names : list [str ] = []
262+ models : list [str ] = []
251263 for name in vendor_names :
252264 names .append (name .text )
265+ for model in vendor_models :
266+ models .append (model .text )
253267
254268 dsmrmain = result .find ("./module/protocols/dsmrmain" )
255269 if "Plugwise" not in names :
@@ -262,6 +276,14 @@ async def connect(self) -> bool:
262276 )
263277 raise ConnectionFailedError
264278
279+ # Check if Anna is connected to an Adam
280+ if "159.2" in models :
281+ LOGGER .error (
282+ "Your Anna is connected to an Adam, make \
283+ sure to only add the Adam as integration." ,
284+ )
285+ raise InvalidSetupError
286+
265287 # Determine smile specifics
266288 await self ._smile_detect (result , dsmrmain )
267289
@@ -372,8 +394,7 @@ async def _smile_detect(self, result: etree, dsmrmain: etree) -> None:
372394 self ._stretch_v2 = self .smile_version [1 ].major == 2
373395 self ._stretch_v3 = self .smile_version [1 ].major == 3
374396
375- if self .smile_type == "thermostat" :
376- self ._is_thermostat = True
397+ self ._is_thermostat = self .smile_type == "thermostat"
377398
378399 async def _full_update_device (self ) -> None :
379400 """Perform a first fetch of all XML data, needed for initialization."""
0 commit comments