Skip to content

Commit 2c97827

Browse files
committed
Continue updating
1 parent 7b4c88e commit 2c97827

File tree

1 file changed

+94
-81
lines changed

1 file changed

+94
-81
lines changed

plugwise/devices.py

Lines changed: 94 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -111,18 +111,6 @@ class SmartEnergySensors:
111111
voltage_phase_two: float | None
112112

113113

114-
@dataclass
115-
class SmartEnergyLegacyMeter:
116-
"""Legacy DSMR Energy Meter data class."""
117-
118-
available: bool
119-
dev_class: str
120-
location: str
121-
model: str
122-
name: str
123-
sensors: SmartEnergyLegacySensors
124-
vendor: str
125-
126114

127115
@dataclass
128116
class SmartEnergyLegacySensors:
@@ -144,91 +132,93 @@ class SmartEnergyLegacySensors:
144132
net_electricity_point: int
145133

146134

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

150-
active_preset: str
139+
active_preset: str | None
151140
available_schedules: list[str]
141+
climate_mode: str
142+
control_state: str
152143
dev_class: str
153144
firmware: str
154145
hardware: str
155146
location: str
156-
mode: str
157147
model: str
158-
model_id: str
159148
name: str
160-
preset_modes: list[str]
161-
select_schedule: str
149+
preset_modes: list[str] | None
150+
select_schedule: str | None
162151
sensors: AnnaSensors
163-
temperature_offset: SetpointDict
152+
temperature_offset: SetpointDict | None # not for legacy
164153
thermostat: ThermostatDict
165154
vendor: str
166155

167156

168-
class AnnaSensors(TypedDict, total=False):
157+
@dataclass
158+
class AnnaSensors:
169159
"""Anna sensors class."""
170160

171-
cooling_activation_outdoor_temperature: float
172-
cooling_deactivation_threshold: float
173161
illuminance: float
174-
setpoint: float
175-
setpoint_high: float
176-
setpoint_low: float
162+
setpoint: float | None
163+
setpoint_high: float | None
164+
setpoint_low: float | None
177165
temperature: float
178166

179167

180168
@dataclass
181169
class ThermoZone:
182170
"""Plugwise Adam ThermoZone data class."""
183171

184-
active_preset: str
172+
active_preset: str | None
185173
available_schedules: list[str]
186174
climate_mode: str
187175
control_state: str
176+
dev_class: str
177+
model: str
178+
name: str
188179
preset_modes: list[str]
189180
select_schedule: str
190181
sensors: ThermoZoneSensors
191182
thermostat: ThermostatDict
183+
thermostats: ThermostatsDict
184+
vendor: str
192185

193186

194-
class ThermoZoneSensors(TypedDict, total=False):
187+
@dataclass
188+
class ThermoZoneSensors:
195189
"""ThermoZone sensors class."""
196190

197-
electricity_consumed: float
198-
electricity_produced: float
191+
electricity_consumed: float | None # only with Plug(s) in the zone
192+
electricity_produced: float | None # only with Plug(s) in the zone
199193
temperature: float
200194

201195

202-
class AnnaAdamData(TypedDict, total=False):
196+
@dataclass
197+
class AnnaAdamData:
203198
"""Plugwise Anna-connected-to-Adam data class."""
204199

205-
available: bool
206200
dev_class: str
207-
firmware: str
208-
hardware: str
209201
location: str
210-
mode: str
211202
model: str
212203
model_id: str
213204
name: str
214205
sensors: AnnaSensors
215-
temperature_offset: SetpointDict
216206
vendor: str
217207

218208

219-
class JipLisaTomData(TypedDict, total=False):
209+
@dataclass
210+
class JipLisaTomData:
220211
"""JipLisaTomData data class.
221212
222213
Covering Plugwise Jip, Lisa and Tom/Floor devices.
223214
"""
224215

225216
available: bool
226-
binary_sensors: WirelessThermostatBinarySensors
217+
binary_sensors: WirelessThermostatBinarySensors | None # Not for AC powered Lisa/Tom
227218
dev_class: str
228219
firmware: str
229220
hardware: str
230221
location: str
231-
mode: str
232222
model: str
233223
model_id: str
234224
name: str
@@ -238,17 +228,18 @@ class JipLisaTomData(TypedDict, total=False):
238228
zigbee_mac_address: str
239229

240230

241-
class JipLisaTomSensors(TypedDict, total=False):
231+
@dataclass
232+
class JipLisaTomSensors:
242233
"""Tom sensors class."""
243234

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
235+
battery: int | None # not when AC powered, Lisa/Tom
236+
humidity: int | None # Jip only
237+
setpoint: float | None # heat or cool
238+
setpoint_high: float | None # heat_cool
239+
setpoint_low: float | None # heat_cool
249240
temperature: float
250-
temperature_difference: float
251-
valve_position: float
241+
temperature_difference: float | None # Tom only
242+
valve_position: float | None # Tom only
252243

253244

254245
@dataclass
@@ -271,17 +262,26 @@ class SetpointDict:
271262
upper_bound: float
272263

273264

274-
class ThermostatDict(TypedDict, total=False):
265+
@dataclass
266+
class ThermostatDict:
275267
"""Thermostat dict class."""
276268

277269
lower_bound: float
278270
resolution: float
279-
setpoint: float # heat or cool
280-
setpoint_high: float # heat_cool
281-
setpoint_low: float # heat_cool
271+
setpoint: float | None # heat or cool
272+
setpoint_high: float | None # heat_cool
273+
setpoint_low: float| None # heat_cool
282274
upper_bound: float
283275

284276

277+
@dataclass
278+
class ThermostatsDict:
279+
"""Thermostats dict class."""
280+
281+
primary: list[str]
282+
secondary: list[str]
283+
284+
285285
@dataclass
286286
class OnOffTherm:
287287
"""On-off heater/cooler device class."""
@@ -293,68 +293,72 @@ class OnOffTherm:
293293
name: str
294294

295295

296-
class OpenTherm(TypedDict, total=False):
296+
@dataclass
297+
class OpenTherm:
297298
"""OpenTherm heater/cooler device class."""
298299

299300
available: str
300301
binary_sensors: HeaterCentralBinarySensors
301302
dev_class: str
302303
location: str
303-
maximum_boiler_temperature: SetpointDict
304-
max_dhw_temperature: SetpointDict
304+
maximum_boiler_temperature: SetpointDict | None
305+
max_dhw_temperature: SetpointDict | None
305306
model: str
306-
model_id: str
307+
model_id: str | None
307308
name: str
308309
sensors: HeaterCentralSensors
309310
switches: HeaterCentralSwitches
310311
vendor: str
311312

312313

313-
class HeaterCentralBinarySensors(TypedDict, total=False):
314+
@dataclass
315+
class HeaterCentralBinarySensors:
314316
"""Heater-central binary_sensors class."""
315317

316-
compressor_state: bool
317-
cooling_enabled: bool
318-
cooling_state: bool
318+
compressor_state: bool | None
319+
cooling_enabled: bool | None
320+
cooling_state: bool | None
319321
dhw_state: bool
320322
flame_state: bool
321323
heating_state: bool
322-
secondary_boiler_state: bool
324+
secondary_boiler_state: bool | None
323325

324326

325-
class HeaterCentralSensors(TypedDict, total=False):
327+
@dataclass
328+
class HeaterCentralSensors:
326329
"""Heater-central sensors class."""
327330

328-
dhw_temperature: float
329-
domestic_hot_water_setpoint: float
330-
intended_boiler_temperature: float
331-
modulation_level: float
332-
outdoor_air_temperature: float
331+
dhw_temperature: float | None
332+
domestic_hot_water_setpoint: float | None
333+
intended_boiler_temperature: float | None
334+
modulation_level: float | None
335+
outdoor_air_temperature: float | None
333336
return_temperature: float
334-
water_pressure: float
337+
water_pressure: float | None
335338
water_temperature: float
336339

337340

338-
class HeaterCentralSwitches(TypedDict, total=False):
341+
@dataclass
342+
class HeaterCentralSwitches:
339343
"""Heater-central switches class."""
340344

341-
cooling_ena_switch: bool
345+
cooling_ena_switch: bool | None
342346
dhw_cm_switch: bool
343347

344348

345349
@dataclass
346350
class PlugData:
347-
"""Plug data class."""
351+
"""Plug data class covering Plugwise Adam/Stretch and Aqara Plugs, and generic ZigBee type Switches."""
348352

349-
available: bool
353+
available: bool | None
350354
dev_class: str
351-
firmware: str
352-
# hardware: str
355+
firmware: str | None
356+
hardware: str | None
353357
location: str
354-
model: str
358+
model: str | None
355359
model_id: str
356360
name: str
357-
sensors: PlugSensors
361+
sensors: PlugSensors | None
358362
switches: PlugSwitches
359363
vendor: str
360364
zigbee_mac_address: str
@@ -364,29 +368,30 @@ class PlugData:
364368
class PlugSensors:
365369
"""Plug sensors class."""
366370

367-
electricity_consumed: float
371+
electricity_consumed: float | None
368372
electricity_consumed_interval: float
369-
electricity_produced: float
370-
electricity_produced_interval: float
373+
electricity_produced: float | None
374+
electricity_produced_interval: float | None
371375

372376

373377
@dataclass
374-
class PlugSwitches(TypedDict, total=False):
378+
class PlugSwitches:
375379
"""Plug switches class."""
376380

377-
lock: bool
381+
lock: bool | None
378382
relay: bool
379383

380384

381385
class PlugwiseP1:
382386
"""Plugwise P1 data class."""
383387

384-
data: dict[str, SmileP1Gateway | SmartEnergyMeter]
388+
data: dict[str, SmileP1Gateway | SmartEnergyMeter | SmartEnergyLegacySensors]
385389

386390

387391
class Anna(SmileThermostatGateway, AnnaData, OnOffTherm, OpenTherm):
388392
"""Plugwise Anna data class."""
389393

394+
data: dict[str, SmileThermostatGateway | OnOffTherm | OpenTherm | AnnaData]
390395

391396
class Adam(
392397
AdamGateway,
@@ -398,3 +403,11 @@ class Adam(
398403
OpenTherm,
399404
):
400405
"""Plugwise Anna data class."""
406+
407+
data: dict[str, AdamGateway | OnOffTherm | OpenTherm | AnnaAdamData | JipLisaTomData | ThermoZone | PlugData]
408+
409+
410+
class Stretch:
411+
"""Plugwise Stretch data class."""
412+
413+
data: dict[str, StretchGateway | PlugData]

0 commit comments

Comments
 (0)