Skip to content

Commit 1c96093

Browse files
committed
Reorder, variables with a default must be after variables without
1 parent 42d4f46 commit 1c96093

File tree

1 file changed

+52
-34
lines changed

1 file changed

+52
-34
lines changed

plugwise/devices.py

Lines changed: 52 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,11 @@ class DeviceBase:
1313
Every device will have most of these data points.
1414
"""
1515

16-
available: Optional[bool] = None # not for gateway, should always be available
1716
dev_class: str
1817
firmware: str
19-
hardware: Optional[str] = None
2018
location: str
2119
mac_address: str
2220
model: str
23-
model_id: Optional[str] = None
2421
name: str
2522
vendor: str
2623

@@ -31,6 +28,8 @@ class AdamGateway(DeviceBase):
3128

3229
binary_sensors: GatewayBinarySensors
3330
gateway_modes: list[str]
31+
hardware: str
32+
model_id: str
3433
regulation_modes: list[str]
3534
select_gateway_mode: str
3635
select_regulation_mode: str
@@ -43,6 +42,8 @@ class SmileTGateway(DeviceBase):
4342
"""Plugwise Anna Smile-T Gateway data class."""
4443

4544
binary_sensors: GatewayBinarySensors
45+
hardware: str
46+
model_id: str
4647
sensors: Weather
4748

4849

@@ -58,6 +59,8 @@ class SmileP1Gateway(DeviceBase):
5859
"""Plugwise Smile P1 Gateway data class."""
5960

6061
binary_sensors: GatewayBinarySensors
62+
hardware: str
63+
model_id: str
6164

6265

6366
@dataclass
@@ -90,6 +93,7 @@ class Weather:
9093
class SmartEnergyMeter(DeviceBase):
9194
"""DSMR Energy Meter data class."""
9295

96+
available: bool
9397
sensors: SmartEnergySensors
9498

9599

@@ -105,20 +109,20 @@ class SmartEnergySensors:
105109
electricity_consumed_peak_point: int
106110
electricity_phase_one_consumed: int
107111
electricity_phase_one_produced: int
108-
electricity_phase_three_consumed: Optional[int] = None
109-
electricity_phase_three_produced: Optional[int] = None
110-
electricity_phase_two_consumed: Optional[int] = None
111-
electricity_phase_two_produced: Optional[int] = None
112112
electricity_produced_off_peak_cumulative: float
113113
electricity_produced_off_peak_interval: int
114114
electricity_produced_off_peak_point: int
115115
electricity_produced_peak_cumulative: float
116116
electricity_produced_peak_interval: int
117117
electricity_produced_peak_point: int
118-
gas_consumed_cumulative: Optional[float] = None
119-
gas_consumed_interval: Optional[float] = None
120118
net_electricity_cumulative: float
121119
net_electricity_point: int
120+
electricity_phase_three_consumed: Optional[int] = None
121+
electricity_phase_three_produced: Optional[int] = None
122+
electricity_phase_two_consumed: Optional[int] = None
123+
electricity_phase_two_produced: Optional[int] = None
124+
gas_consumed_cumulative: Optional[float] = None
125+
gas_consumed_interval: Optional[float] = None
122126
voltage_phase_one: Optional[float] = None
123127
voltage_phase_three: Optional[float] = None
124128
voltage_phase_two: Optional[float] = None
@@ -138,39 +142,40 @@ class SmartEnergyLegacySensors:
138142
electricity_produced_peak_cumulative: float
139143
electricity_produced_peak_interval: int
140144
electricity_produced_point: int
141-
gas_consumed_cumulative: Optional[float] = None
142-
gas_consumed_interval: Optional[float] = None
143145
net_electricity_cumulative: float
144146
net_electricity_point: int
147+
gas_consumed_cumulative: Optional[float] = None
148+
gas_consumed_interval: Optional[float] = None
145149

146150

147151
@dataclass
148152
class Anna(DeviceBase):
149153
"""Plugwise Anna class, also for legacy Anna."""
150154

155+
available: bool
151156
climate_mode: str
152157
control_state: str
158+
hardware: str
153159
sensors: AnnaSensors
154-
temperature_offset: Optional[SetpointDict] = None # not for legacy
155160
thermostat: ThermostatDict
161+
temperature_offset: Optional[SetpointDict] = None # not for legacy
156162

157163

158164
@dataclass
159165
class AnnaSensors:
160166
"""Anna sensors class."""
161167

162168
illuminance: float
169+
temperature: float
163170
setpoint: Optional[float] = None
164171
setpoint_high: Optional[float] = None
165172
setpoint_low: Optional[float] = None
166-
temperature: float
167173

168174

169175
@dataclass
170176
class Zone(DeviceBase):
171177
"""Plugwise climate Zone data class."""
172178

173-
active_preset: Optional[str] = None
174179
available_schedules: list[str]
175180
climate_mode: str
176181
control_state: str
@@ -181,7 +186,9 @@ class Zone(DeviceBase):
181186
thermostat: ThermostatDict
182187
thermostats: ThermostatsDict
183188
zone_profiles: list[str]
184-
189+
active_preset: Optional[str] = None
190+
hardware: Optional[str] = None
191+
model_id: Optional[str] = None
185192

186193
@dataclass
187194
class ZoneSensors:
@@ -196,6 +203,8 @@ class ZoneSensors:
196203
class AnnaAdam(DeviceBase):
197204
"""Plugwise Anna-connected-to-Adam data class."""
198205

206+
available: bool
207+
model_id: str
199208
sensors: AnnaSensors
200209

201210

@@ -206,24 +215,28 @@ class EmmaJipLisaTom(DeviceBase):
206215
Covering Plugwise Emma, Jip, Lisa and Tom/Floor devices.
207216
"""
208217

209-
binary_sensors: Optional[WirelessThermostatBinarySensors] = (
210-
None # Not for AC powered Lisa/Tom
211-
)
218+
available: bool
219+
hardware: str
220+
model_id: str
212221
sensors: EmmaJipLisaTomSensors
213222
temperature_offset: SetpointDict
214223
zigbee_mac_address: str
215224

225+
binary_sensors: Optional[WirelessThermostatBinarySensors] = (
226+
None # Not for AC powered Lisa/Tom
227+
)
228+
216229

217230
@dataclass
218231
class EmmaJipLisaTomSensors:
219232
"""Emma-Jip_lisa-Tom sensors class."""
220233

234+
temperature: float
221235
battery: Optional[int] = None # not when AC powered, Lisa/Tom
222236
humidity: Optional[int] = None # Emma and Jip only
223237
setpoint: Optional[float] = None # heat or cool
224238
setpoint_high: Optional[float] = None # heat_cool
225239
setpoint_low: Optional[float] = None # heat_cool
226-
temperature: float
227240
temperature_difference: Optional[float] = None # Tom only
228241
valve_position: Optional[float] = None # Tom only
229242

@@ -254,10 +267,10 @@ class ThermostatDict:
254267

255268
lower_bound: float
256269
resolution: float
270+
upper_bound: float
257271
setpoint: Optional[float] = None # heat or cool
258272
setpoint_high: Optional[float] = None # heat_cool
259273
setpoint_low: Optional[float] = None # heat_cool
260-
upper_bound: float
261274

262275

263276
@dataclass
@@ -272,6 +285,7 @@ class ThermostatsDict:
272285
class OnOff(DeviceBase):
273286
"""On-off climate device class."""
274287

288+
available: bool
275289
binary_sensors: OnOffBinarySensors
276290
sensors: OnOffSensors
277291

@@ -287,72 +301,77 @@ class OnOffBinarySensors:
287301
class OnOffSensors:
288302
"""Heater-central sensors class."""
289303

304+
water_temperature: float
290305
intended_boiler_temperature: Optional[float] = None
291306
modulation_level: Optional[float] = None
292-
water_temperature: float
293307

294308

295309
@dataclass
296310
class OpenTherm(DeviceBase):
297311
"""OpenTherm climate device class."""
298312

313+
available: bool
299314
binary_sensors: OpenThermBinarySensors
300-
maximum_boiler_temperature: Optional[SetpointDict] = None
301-
max_dhw_temperature: Optional[SetpointDict] = None
302315
sensors: OpenThermSensors
303316
switches: OpenThermSwitches
317+
maximum_boiler_temperature: Optional[SetpointDict] = None
318+
max_dhw_temperature: Optional[SetpointDict] = None
319+
model_id: Optional[str] = None
304320

305321

306322
@dataclass
307323
class OpenThermBinarySensors:
308324
"""OpenTherm binary_sensors class."""
309325

326+
dhw_state: bool
327+
heating_state: bool
310328
compressor_state: Optional[bool] = None
311329
cooling_enabled: Optional[bool] = None
312330
cooling_state: Optional[bool] = None
313-
dhw_state: bool
314331
flame_state: Optional[bool] = None
315-
heating_state: bool
316332
secondary_boiler_state: Optional[bool] = None
317333

318334

319335
@dataclass
320336
class OpenThermSensors:
321337
"""OpenTherm sensors class."""
322338

339+
return_temperature: float
340+
water_temperature: float
323341
dhw_temperature: Optional[float] = None
324342
domestic_hot_water_setpoint: Optional[float] = None
325343
intended_boiler_temperature: Optional[float] = None
326344
modulation_level: Optional[float] = None
327345
outdoor_air_temperature: Optional[float] = None
328-
return_temperature: float
329346
water_pressure: Optional[float] = None
330-
water_temperature: float
331347

332348

333349
@dataclass
334350
class OpenThermSwitches:
335351
"""OpenTherm switches class."""
336352

337-
cooling_ena_switch: Optional[bool] = None
338353
dhw_cm_switch: bool
354+
cooling_ena_switch: Optional[bool] = None
339355

340356

341357
@dataclass
342-
class PlugData(DeviceBase):
358+
class Plug(DeviceBase):
343359
"""Plug data class covering Plugwise Adam/Stretch and Aqara Plugs, and generic ZigBee type Switches."""
344360

345-
sensors: Optional[PlugSensors] = None
361+
available: bool
346362
switches: PlugSwitches
347363
zigbee_mac_address: str
364+
sensors: Optional[PlugSensors] = None
365+
hardware: Optional[str] = None
366+
model_id: Optional[str] = None
348367

349368

350369
@dataclass
351370
class PlugSensors:
352371
"""Plug sensors class."""
353372

354-
electricity_consumed: Optional[float] = None # Not present for Aqara Plug
355373
electricity_consumed_interval: float
374+
electricity_consumed: Optional[float] = None # Not present for Aqara Plug
356375
electricity_produced: Optional[float] = None
357376
electricity_produced_interval: Optional[float] = None
358377

@@ -361,9 +380,8 @@ class PlugSensors:
361380
class PlugSwitches:
362381
"""Plug switches class."""
363382

364-
lock: Optional[bool] = None
365383
relay: bool
366-
384+
lock: Optional[bool] = None
367385

368386
##################################################
369387
class PlugwiseData:
@@ -419,7 +437,7 @@ class PlugwiseData:
419437
adam: AdamGateway
420438
smile_t: SmileTGateway
421439
smile_t_legacy: SmileTLegacyGateway
422-
smile_t_p1: SmileTGatewayGateway
440+
smile_t_p1: SmileTGateway
423441
smile_p1: SmileP1Gateway
424442
smile_p1_legacy: SmileP1LegacyGateway
425443
stretch: StretchGateway

0 commit comments

Comments
 (0)