Skip to content

Commit ab543e1

Browse files
committed
Improve
1 parent 43daac1 commit ab543e1

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

plugwise/__init__.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -189,19 +189,24 @@ async def _smile_detect(
189189
"""
190190
model: str = "Unknown"
191191
if (gateway := result.find("./gateway")) is not None:
192-
if (v_model := gateway.find("vendor_model")) is not None:
193-
model = v_model.text
192+
if (vendor_model := gateway.find("vendor_model")) is not None:
193+
model = vendor_model.text
194+
if (
195+
elec_measurement := gateway.find(
196+
"gateway_environment/electricity_consumption_tariff_structure"
197+
)
198+
) and elec_measurement.text:
199+
parts = model.split("_")
200+
if len(parts) == 2: # expecting smile_thermo
201+
model = parts[0] + parts[1] + "_power"
202+
203+
self.smile.model_id = model
204+
194205
self.smile.version = parse(gateway.find("firmware_version").text)
195206
self.smile.hw_version = gateway.find("hardware_version").text
196207
self.smile.hostname = gateway.find("hostname").text
197208
self.smile.mac_address = gateway.find("mac_address").text
198-
self.smile.model_id = gateway.find("vendor_model").text
199-
if (elec_measurement := gateway.find(
200-
"gateway_environment/electricity_consumption_tariff_structure"
201-
)) and elec_measurement.text:
202-
parts = model.split("_")
203-
if len(parts) == 3:
204-
model = parts[0] + parts[1] + "_power" + parts[2]
209+
205210
else:
206211
model = await self._smile_detect_legacy(result, dsmrmain, model)
207212

@@ -243,7 +248,7 @@ async def _smile_detect(
243248
if self.smile.type == "stretch":
244249
self._stretch_v2 = int(version_major) == 2
245250

246-
if self.smile.type == "thermostat":
251+
if self.smile.type in ("thermostat", "thermostat_power"):
247252
self._is_thermostat = True
248253
# For Adam, Anna, determine the system capabilities:
249254
# Find the connected heating/cooling device (heater_central),

0 commit comments

Comments
 (0)