Skip to content

Commit 9bdfd38

Browse files
committed
Continue updating
1 parent 7b4c88e commit 9bdfd38

File tree

1 file changed

+83
-67
lines changed

1 file changed

+83
-67
lines changed

plugwise/devices.py

Lines changed: 83 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -144,91 +144,93 @@ class SmartEnergyLegacySensors:
144144
net_electricity_point: int
145145

146146

147-
class AnnaData(TypedDict, total=False):
148-
"""Plugwise Anna data class."""
147+
@dataclass
148+
class AnnaData:
149+
"""Plugwise Anna data class, also for legacy Anna."""
149150

150-
active_preset: str
151+
active_preset: str | None
151152
available_schedules: list[str]
153+
climate_mode: str
154+
control_state: str
152155
dev_class: str
153156
firmware: str
154157
hardware: str
155158
location: str
156-
mode: str
157159
model: str
158-
model_id: str
159160
name: str
160-
preset_modes: list[str]
161-
select_schedule: str
161+
preset_modes: list[str] | None
162+
select_schedule: str | None
162163
sensors: AnnaSensors
163-
temperature_offset: SetpointDict
164+
temperature_offset: SetpointDict | None # not for legacy
164165
thermostat: ThermostatDict
165166
vendor: str
166167

167168

168-
class AnnaSensors(TypedDict, total=False):
169+
@dataclass
170+
class AnnaSensors:
169171
"""Anna sensors class."""
170172

171-
cooling_activation_outdoor_temperature: float
172-
cooling_deactivation_threshold: float
173173
illuminance: float
174-
setpoint: float
175-
setpoint_high: float
176-
setpoint_low: float
174+
setpoint: float | None
175+
setpoint_high: float | None
176+
setpoint_low: float | None
177177
temperature: float
178178

179179

180180
@dataclass
181181
class ThermoZone:
182182
"""Plugwise Adam ThermoZone data class."""
183183

184-
active_preset: str
184+
active_preset: str | None
185185
available_schedules: list[str]
186186
climate_mode: str
187187
control_state: str
188+
dev_class: str
189+
model: str
190+
name: str
188191
preset_modes: list[str]
189192
select_schedule: str
190193
sensors: ThermoZoneSensors
191194
thermostat: ThermostatDict
195+
thermostats: ThermostatsDict
196+
vendor: str
192197

193198

194-
class ThermoZoneSensors(TypedDict, total=False):
199+
@dataclass
200+
class ThermoZoneSensors:
195201
"""ThermoZone sensors class."""
196202

197-
electricity_consumed: float
198-
electricity_produced: float
203+
electricity_consumed: float | None # only with Plug(s) in the zone
204+
electricity_produced: float | None # only with Plug(s) in the zone
199205
temperature: float
200206

201207

202-
class AnnaAdamData(TypedDict, total=False):
208+
@dataclass
209+
class AnnaAdamData:
203210
"""Plugwise Anna-connected-to-Adam data class."""
204211

205-
available: bool
206212
dev_class: str
207-
firmware: str
208-
hardware: str
209213
location: str
210-
mode: str
211214
model: str
212215
model_id: str
213216
name: str
214217
sensors: AnnaSensors
215-
temperature_offset: SetpointDict
216218
vendor: str
217219

218220

219-
class JipLisaTomData(TypedDict, total=False):
221+
@dataclass
222+
class JipLisaTomData:
220223
"""JipLisaTomData data class.
221224
222225
Covering Plugwise Jip, Lisa and Tom/Floor devices.
223226
"""
224227

225228
available: bool
226-
binary_sensors: WirelessThermostatBinarySensors
229+
binary_sensors: WirelessThermostatBinarySensors | None # Not for AC powered Lisa/Tom
227230
dev_class: str
228231
firmware: str
229232
hardware: str
230233
location: str
231-
mode: str
232234
model: str
233235
model_id: str
234236
name: str
@@ -238,17 +240,18 @@ class JipLisaTomData(TypedDict, total=False):
238240
zigbee_mac_address: str
239241

240242

241-
class JipLisaTomSensors(TypedDict, total=False):
243+
@dataclass
244+
class JipLisaTomSensors:
242245
"""Tom sensors class."""
243246

244-
battery: int
245-
humidity: int # Jip only
246-
setpoint: float # heat or cool
247-
setpoint_high: float # heat_cool
248-
setpoint_low: float # heat_cool
247+
battery: int | None # not when AC powered, Lisa/Tom
248+
humidity: int | None # Jip only
249+
setpoint: float | None # heat or cool
250+
setpoint_high: float | None # heat_cool
251+
setpoint_low: float | None # heat_cool
249252
temperature: float
250-
temperature_difference: float
251-
valve_position: float
253+
temperature_difference: float | None # Tom only
254+
valve_position: float | None # Tom only
252255

253256

254257
@dataclass
@@ -271,17 +274,26 @@ class SetpointDict:
271274
upper_bound: float
272275

273276

274-
class ThermostatDict(TypedDict, total=False):
277+
@dataclass
278+
class ThermostatDict:
275279
"""Thermostat dict class."""
276280

277281
lower_bound: float
278282
resolution: float
279-
setpoint: float # heat or cool
280-
setpoint_high: float # heat_cool
281-
setpoint_low: float # heat_cool
283+
setpoint: float | None # heat or cool
284+
setpoint_high: float | None # heat_cool
285+
setpoint_low: float| None # heat_cool
282286
upper_bound: float
283287

284288

289+
@dataclass
290+
class ThermostatsDict:
291+
"""Thermostats dict class."""
292+
293+
primary: list[str]
294+
secondary: list[str]
295+
296+
285297
@dataclass
286298
class OnOffTherm:
287299
"""On-off heater/cooler device class."""
@@ -293,68 +305,72 @@ class OnOffTherm:
293305
name: str
294306

295307

296-
class OpenTherm(TypedDict, total=False):
308+
@dataclass
309+
class OpenTherm:
297310
"""OpenTherm heater/cooler device class."""
298311

299312
available: str
300313
binary_sensors: HeaterCentralBinarySensors
301314
dev_class: str
302315
location: str
303-
maximum_boiler_temperature: SetpointDict
304-
max_dhw_temperature: SetpointDict
316+
maximum_boiler_temperature: SetpointDict | None
317+
max_dhw_temperature: SetpointDict | None
305318
model: str
306-
model_id: str
319+
model_id: str | None
307320
name: str
308321
sensors: HeaterCentralSensors
309322
switches: HeaterCentralSwitches
310323
vendor: str
311324

312325

313-
class HeaterCentralBinarySensors(TypedDict, total=False):
326+
@dataclass
327+
class HeaterCentralBinarySensors:
314328
"""Heater-central binary_sensors class."""
315329

316-
compressor_state: bool
317-
cooling_enabled: bool
318-
cooling_state: bool
330+
compressor_state: bool | None
331+
cooling_enabled: bool | None
332+
cooling_state: bool | None
319333
dhw_state: bool
320334
flame_state: bool
321335
heating_state: bool
322-
secondary_boiler_state: bool
336+
secondary_boiler_state: bool | None
323337

324338

325-
class HeaterCentralSensors(TypedDict, total=False):
339+
@dataclass
340+
class HeaterCentralSensors:
326341
"""Heater-central sensors class."""
327342

328-
dhw_temperature: float
329-
domestic_hot_water_setpoint: float
330-
intended_boiler_temperature: float
331-
modulation_level: float
332-
outdoor_air_temperature: float
343+
dhw_temperature: float | None
344+
domestic_hot_water_setpoint: float | None
345+
intended_boiler_temperature: float | None
346+
modulation_level: float | None
347+
outdoor_air_temperature: float | None
333348
return_temperature: float
334-
water_pressure: float
349+
water_pressure: float | None
335350
water_temperature: float
336351

337352

338-
class HeaterCentralSwitches(TypedDict, total=False):
353+
@dataclass
354+
class HeaterCentralSwitches:
339355
"""Heater-central switches class."""
340356

341-
cooling_ena_switch: bool
357+
cooling_ena_switch: bool | None
342358
dhw_cm_switch: bool
343359

344360

345361
@dataclass
346362
class PlugData:
347-
"""Plug data class."""
363+
"""Plug data class covering Plugwise Adam/Stretch and Aqara Plugs, and generic ZigBee type Switches."""
348364

349-
available: bool
365+
available: bool | None
350366
dev_class: str
351-
firmware: str
352-
# hardware: str
367+
firmware: str | None
368+
hardware: str | None
353369
location: str
354-
model: str
370+
model: str | None
355371
model_id: str
356372
name: str
357-
sensors: PlugSensors
373+
sensors: PlugSensors | None
358374
switches: PlugSwitches
359375
vendor: str
360376
zigbee_mac_address: str
@@ -364,17 +380,17 @@ class PlugData:
364380
class PlugSensors:
365381
"""Plug sensors class."""
366382

367-
electricity_consumed: float
383+
electricity_consumed: float | None
368384
electricity_consumed_interval: float
369-
electricity_produced: float
370-
electricity_produced_interval: float
385+
electricity_produced: float | None
386+
electricity_produced_interval: float | None
371387

372388

373389
@dataclass
374390
class PlugSwitches(TypedDict, total=False):
375391
"""Plug switches class."""
376392

377-
lock: bool
393+
lock: bool | None
378394
relay: bool
379395

380396

0 commit comments

Comments
 (0)