33from __future__ import annotations
44
55from dataclasses import dataclass
6+ from typing import Optional
67
78
89@dataclass
@@ -13,14 +14,14 @@ class DeviceBase:
1314 """
1415
1516
16- available : bool | None # not for gateway, should always be available
17+ available : Optional [ bool ] = None # not for gateway, should always be available
1718 dev_class : str
1819 firmware : str
19- hardware : str | None
20+ hardware : Optional [ str ] = None
2021 location : str
2122 mac_address : str
2223 model : str
23- model_id : str | None
24+ model_id : Optional [ str ] = None
2425 name : str
2526 vendor : str
2627
@@ -83,7 +84,7 @@ class GatewayBinarySensors:
8384class Weather :
8485 """Gateway weather sensor class."""
8586
86- outdoor_temperature : float | None # None when not available
87+ outdoor_temperature : Optional [ float ] = None # None when not available
8788
8889
8990@dataclass
@@ -105,23 +106,23 @@ class SmartEnergySensors:
105106 electricity_consumed_peak_point : int
106107 electricity_phase_one_consumed : int
107108 electricity_phase_one_produced : int
108- electricity_phase_three_consumed : int | None
109- electricity_phase_three_produced : int | None
110- electricity_phase_two_consumed : int | None
111- electricity_phase_two_produced : int | None
109+ electricity_phase_three_consumed : Optional [ int ] = None
110+ electricity_phase_three_produced : Optional [ int ] = None
111+ electricity_phase_two_consumed : Optional [ int ] = None
112+ electricity_phase_two_produced : Optional [ int ] = None
112113 electricity_produced_off_peak_cumulative : float
113114 electricity_produced_off_peak_interval : int
114115 electricity_produced_off_peak_point : int
115116 electricity_produced_peak_cumulative : float
116117 electricity_produced_peak_interval : int
117118 electricity_produced_peak_point : int
118- gas_consumed_cumulative : float | None
119- gas_consumed_interval : float | None
119+ gas_consumed_cumulative : Optional [ float ] = None
120+ gas_consumed_interval : Optional [ float ] = None
120121 net_electricity_cumulative : float
121122 net_electricity_point : int
122- voltage_phase_one : float | None
123- voltage_phase_three : float | None
124- voltage_phase_two : float | None
123+ voltage_phase_one : Optional [ float ] = None
124+ voltage_phase_three : Optional [ float ] = None
125+ voltage_phase_two : Optional [ float ] = None
125126
126127
127128@dataclass
@@ -138,8 +139,8 @@ class SmartEnergyLegacySensors:
138139 electricity_produced_peak_cumulative : float
139140 electricity_produced_peak_interval : int
140141 electricity_produced_point : int
141- gas_consumed_cumulative : float | None
142- gas_consumed_interval : float | None
142+ gas_consumed_cumulative : Optional [ float ] = None
143+ gas_consumed_interval : Optional [ float ] = None
143144 net_electricity_cumulative : float
144145 net_electricity_point : int
145146
@@ -151,7 +152,7 @@ class Anna(DeviceBase):
151152 climate_mode : str
152153 control_state : str
153154 sensors : AnnaSensors
154- temperature_offset : SetpointDict | None # not for legacy
155+ temperature_offset : Optional [ SetpointDict ] = None # not for legacy
155156 thermostat : ThermostatDict
156157
157158
@@ -160,17 +161,17 @@ class AnnaSensors:
160161 """Anna sensors class."""
161162
162163 illuminance : float
163- setpoint : float | None
164- setpoint_high : float | None
165- setpoint_low : float | None
164+ setpoint : Optional [ float ] = None
165+ setpoint_high : Optional [ float ] = None
166+ setpoint_low : Optional [ float ] = None
166167 temperature : float
167168
168169
169170@dataclass
170171class Zone (DeviceBase ):
171172 """Plugwise climate Zone data class."""
172173
173- active_preset : str | None
174+ active_preset : Optional [ str ] = None
174175 available_schedules : list [str ]
175176 climate_mode : str
176177 control_state : str
@@ -187,9 +188,9 @@ class Zone(DeviceBase):
187188class ZoneSensors :
188189 """ Climate Zone sensors class."""
189190
190- electricity_consumed : float | None
191- electricity_produced : float | None
192- temperature : float | None
191+ electricity_consumed : Optional [ float ] = None
192+ electricity_produced : Optional [ float ] = None
193+ temperature : Optional [ float ] = None
193194
194195
195196@dataclass
@@ -207,7 +208,7 @@ class EmmaJipLisaTomData(DeviceBase):
207208 """
208209
209210 binary_sensors : (
210- WirelessThermostatBinarySensors | None
211+ Optional [ WirelessThermostatBinarySensors ] = None
211212 ) # Not for AC powered Lisa/Tom
212213 sensors : JipLisaTomSensors
213214 temperature_offset : SetpointDict
@@ -218,14 +219,14 @@ class EmmaJipLisaTomData(DeviceBase):
218219class EmmaJipLisaTomSensors :
219220 """Emma-Jip_lisa-Tom sensors class."""
220221
221- battery : int | None # not when AC powered, Lisa/Tom
222- humidity : int | None # Emma and Jip only
223- setpoint : float | None # heat or cool
224- setpoint_high : float | None # heat_cool
225- setpoint_low : float | None # heat_cool
222+ battery : Optional [ int ] = None # not when AC powered, Lisa/Tom
223+ humidity : Optional [ int ] = None # Emma and Jip only
224+ setpoint : Optional [ float ] = None # heat or cool
225+ setpoint_high : Optional [ float ] = None # heat_cool
226+ setpoint_low : Optional [ float ] = None # heat_cool
226227 temperature : float
227- temperature_difference : float | None # Tom only
228- valve_position : float | None # Tom only
228+ temperature_difference : Optional [ float ] = None # Tom only
229+ valve_position : Optional [ float ] = None # Tom only
229230
230231
231232@dataclass
@@ -254,9 +255,9 @@ class ThermostatDict:
254255
255256 lower_bound : float
256257 resolution : float
257- setpoint : float | None # heat or cool
258- setpoint_high : float | None # heat_cool
259- setpoint_low : float | None # heat_cool
258+ setpoint : Optional [ float ] = None # heat or cool
259+ setpoint_high : Optional [ float ] = None # heat_cool
260+ setpoint_low : Optional [ float ] = None # heat_cool
260261 upper_bound : float
261262
262263
@@ -287,8 +288,8 @@ class OpOffBinarySensors:
287288class OnOffSensors :
288289 """Heater-central sensors class."""
289290
290- intended_boiler_temperature : float | None
291- modulation_level : float | None
291+ intended_boiler_temperature : Optional [ float ] = None
292+ modulation_level : Optional [ float ] = None
292293 water_temperature : float
293294
294295
@@ -297,8 +298,8 @@ class OpenTherm(DeviceBase):
297298 """OpenTherm climate device class."""
298299
299300 binary_sensors : OpenThermBinarySensors
300- maximum_boiler_temperature : SetpointDict | None
301- max_dhw_temperature : SetpointDict | None
301+ maximum_boiler_temperature : Optional [ SetpointDict ] = None
302+ max_dhw_temperature : Optional [ SetpointDict ] = None
302303 sensors : OpenThermSensors
303304 switches : OpenThermSwitches
304305
@@ -307,42 +308,42 @@ class OpenTherm(DeviceBase):
307308class OpenThermBinarySensors :
308309 """OpenTherm binary_sensors class."""
309310
310- compressor_state : bool | None
311- cooling_enabled : bool | None
312- cooling_state : bool | None
311+ compressor_state : Optional [ lbool ] = None
312+ cooling_enabled : Optional [ bool ] = None
313+ cooling_state : Optional [ bool ] = None
313314 dhw_state : bool
314- flame_state : bool | None
315+ flame_state : Optional [ bool ] = None
315316 heating_state : bool
316- secondary_boiler_state : bool | None
317+ secondary_boiler_state : Optional [ bool ] = None
317318
318319
319320@dataclass
320321class OpenThermSensors :
321322 """OpenTherm sensors class."""
322323
323- dhw_temperature : float | None
324- domestic_hot_water_setpoint : float | None
325- intended_boiler_temperature : float | None
326- modulation_level : float | None
327- outdoor_air_temperature : float | None
324+ dhw_temperature : Optional [ float ] = None
325+ domestic_hot_water_setpoint : Optional [ float ] = None
326+ intended_boiler_temperature : Optional [ float ] = None
327+ modulation_level : Optional [ float ] = None
328+ outdoor_air_temperature : Optional [ float ] = None
328329 return_temperature : float
329- water_pressure : float | None
330+ water_pressure : Optional [ float ] = None
330331 water_temperature : float
331332
332333
333334@dataclass
334335class OpenThermSwitches :
335336 """OpenTherm switches class."""
336337
337- cooling_ena_switch : bool | None
338+ cooling_ena_switch : Optional [ bool ] = None
338339 dhw_cm_switch : bool
339340
340341
341342@dataclass
342343class PlugData (DeviceBase ):
343344 """Plug data class covering Plugwise Adam/Stretch and Aqara Plugs, and generic ZigBee type Switches."""
344345
345- sensors : PlugSensors | None
346+ sensors : Optional [ PlugSensors ] = None
346347 switches : PlugSwitches
347348 zigbee_mac_address : str
348349
@@ -351,17 +352,17 @@ class PlugData(DeviceBase):
351352class PlugSensors :
352353 """Plug sensors class."""
353354
354- electricity_consumed : float | None # why None?
355+ electricity_consumed : Optional [ float ] = None # Not present for Aqara Plug
355356 electricity_consumed_interval : float
356- electricity_produced : float | None
357- electricity_produced_interval : float | None
357+ electricity_produced : Optional [ float ] = None
358+ electricity_produced_interval : Optional [ float ] = None
358359
359360
360361@dataclass
361362class PlugSwitches :
362363 """Plug switches class."""
363364
364- lock : bool | None
365+ lock : Optional [ bool ] = None
365366 relay : bool
366367
367368##################################################
0 commit comments