Skip to content

Commit 31c8ade

Browse files
committed
clean up with constants and exceptions
1 parent d909482 commit 31c8ade

File tree

20 files changed

+96
-56
lines changed

20 files changed

+96
-56
lines changed

zha/application/platforms/alarm_control_panel/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
)
2323
from zha.application.platforms.model import EntityState
2424
from zha.application.registries import PLATFORM_ENTITIES
25+
from zha.websocket.const import MODEL_CLASS_NAME
2526
from zha.zigbee.cluster_handlers.const import (
2627
CLUSTER_HANDLER_IAS_ACE,
2728
CLUSTER_HANDLER_STATE_CHANGED,
@@ -114,7 +115,7 @@ def __init__(
114115
def info_object(self) -> AlarmControlPanelEntityInfo:
115116
"""Return a representation of the alarm control panel."""
116117
return AlarmControlPanelEntityInfo(
117-
**super().info_object.model_dump(exclude=["model_class_name"]),
118+
**super().info_object.model_dump(exclude=[MODEL_CLASS_NAME]),
118119
code_arm_required=self.code_arm_required,
119120
code_format=self.code_format,
120121
supported_features=self.supported_features,

zha/application/platforms/binary_sensor/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from zha.application.platforms.helpers import validate_device_class
2222
from zha.application.platforms.model import EntityState
2323
from zha.application.registries import PLATFORM_ENTITIES
24+
from zha.websocket.const import MODEL_CLASS_NAME
2425
from zha.zigbee.cluster_handlers.const import (
2526
CLUSTER_HANDLER_ACCELEROMETER,
2627
CLUSTER_HANDLER_ATTRIBUTE_UPDATED,
@@ -97,7 +98,7 @@ def _init_from_quirks_metadata(self, entity_metadata: BinarySensorMetadata) -> N
9798
def info_object(self) -> BinarySensorEntityInfo:
9899
"""Return a representation of the binary sensor."""
99100
return BinarySensorEntityInfo(
100-
**super().info_object.model_dump(exclude=["model_class_name"]),
101+
**super().info_object.model_dump(exclude=[MODEL_CLASS_NAME]),
101102
attribute_name=self._attribute_name,
102103
)
103104

zha/application/platforms/button/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from zha.application.platforms.const import EntityCategory
2222
from zha.application.platforms.model import EntityState
2323
from zha.application.registries import PLATFORM_ENTITIES
24+
from zha.websocket.const import MODEL_CLASS_NAME
2425
from zha.zigbee.cluster_handlers.const import CLUSTER_HANDLER_IDENTIFY
2526

2627
if TYPE_CHECKING:
@@ -81,7 +82,7 @@ def _init_from_quirks_metadata(
8182
def info_object(self) -> CommandButtonEntityInfo:
8283
"""Return a representation of the button."""
8384
return CommandButtonEntityInfo(
84-
**super().info_object.model_dump(exclude=["model_class_name"]),
85+
**super().info_object.model_dump(exclude=[MODEL_CLASS_NAME]),
8586
command=self._command_name,
8687
args=self._args,
8788
kwargs=self._kwargs,
@@ -176,7 +177,7 @@ def _init_from_quirks_metadata(
176177
def info_object(self) -> WriteAttributeButtonEntityInfo:
177178
"""Return a representation of the button."""
178179
return WriteAttributeButtonEntityInfo(
179-
**super().info_object.model_dump(exclude=["model_class_name"]),
180+
**super().info_object.model_dump(exclude=[MODEL_CLASS_NAME]),
180181
attribute_name=self._attribute_name,
181182
attribute_value=self._attribute_value,
182183
)

zha/application/platforms/climate/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
from zha.application.registries import PLATFORM_ENTITIES
4545
from zha.decorators import periodic
4646
from zha.units import UnitOfTemperature
47+
from zha.websocket.const import MODEL_CLASS_NAME
4748
from zha.zigbee.cluster_handlers.const import (
4849
CLUSTER_HANDLER_ATTRIBUTE_UPDATED,
4950
CLUSTER_HANDLER_FAN,
@@ -223,7 +224,7 @@ def __init__(
223224
def info_object(self) -> ThermostatEntityInfo:
224225
"""Return a representation of the thermostat."""
225226
return ThermostatEntityInfo(
226-
**super().info_object.model_dump(exclude=["model_class_name"]),
227+
**super().info_object.model_dump(exclude=[MODEL_CLASS_NAME]),
227228
max_temp=self.max_temp,
228229
min_temp=self.min_temp,
229230
supported_features=self.supported_features,

zha/application/platforms/cover/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
)
3535
from zha.application.registries import PLATFORM_ENTITIES
3636
from zha.exceptions import ZHAException
37+
from zha.websocket.const import MODEL_CLASS_NAME
3738
from zha.zigbee.cluster_handlers.closures import WindowCoveringClusterHandler
3839
from zha.zigbee.cluster_handlers.const import (
3940
CLUSTER_HANDLER_ATTRIBUTE_UPDATED,
@@ -167,7 +168,7 @@ def supported_features(self) -> CoverEntityFeature:
167168
def info_object(self) -> CoverEntityInfo:
168169
"""Return the info object for this entity."""
169170
return CoverEntityInfo(
170-
**super().info_object.model_dump(exclude=["model_class_name"]),
171+
**super().info_object.model_dump(exclude=[MODEL_CLASS_NAME]),
171172
supported_features=self.supported_features,
172173
)
173174

@@ -485,7 +486,7 @@ def __init__(
485486
def info_object(self) -> ShadeEntityInfo:
486487
"""Return the info object for this entity."""
487488
return ShadeEntityInfo(
488-
**super().info_object.model_dump(exclude=["model_class_name"]),
489+
**super().info_object.model_dump(exclude=[MODEL_CLASS_NAME]),
489490
supported_features=self.supported_features,
490491
)
491492

zha/application/platforms/device_tracker/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from zha.application.platforms.sensor import Battery
2020
from zha.application.registries import PLATFORM_ENTITIES
2121
from zha.decorators import periodic
22+
from zha.websocket.const import MODEL_CLASS_NAME
2223
from zha.zigbee.cluster_handlers.const import (
2324
CLUSTER_HANDLER_ATTRIBUTE_UPDATED,
2425
CLUSTER_HANDLER_POWER_CONFIGURATION,
@@ -104,7 +105,7 @@ def __init__(
104105
def info_object(self) -> DeviceTrackerEntityInfo:
105106
"""Return a representation of the device tracker."""
106107
return DeviceTrackerEntityInfo(
107-
**super().info_object.model_dump(exclude=["model_class_name"])
108+
**super().info_object.model_dump(exclude=[MODEL_CLASS_NAME])
108109
)
109110

110111
@property

zha/application/platforms/fan/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
)
4040
from zha.application.platforms.fan.model import FanEntityInfo, FanState
4141
from zha.application.registries import PLATFORM_ENTITIES
42+
from zha.websocket.const import MODEL_CLASS_NAME
4243
from zha.zigbee.cluster_handlers import wrap_zigpy_exceptions
4344
from zha.zigbee.cluster_handlers.const import (
4445
CLUSTER_HANDLER_ATTRIBUTE_UPDATED,
@@ -282,7 +283,7 @@ def __init__(
282283
def info_object(self) -> FanEntityInfo:
283284
"""Return a representation of the binary sensor."""
284285
return FanEntityInfo(
285-
**super().info_object.model_dump(exclude=["model_class_name"]),
286+
**super().info_object.model_dump(exclude=[MODEL_CLASS_NAME]),
286287
preset_modes=self.preset_modes,
287288
supported_features=self.supported_features,
288289
speed_count=self.speed_count,
@@ -352,7 +353,7 @@ def __init__(self, group: Group):
352353
def info_object(self) -> FanEntityInfo:
353354
"""Return a representation of the binary sensor."""
354355
return FanEntityInfo(
355-
**super().info_object.model_dump(exclude=["model_class_name"]),
356+
**super().info_object.model_dump(exclude=[MODEL_CLASS_NAME]),
356357
preset_modes=self.preset_modes,
357358
supported_features=self.supported_features,
358359
speed_count=self.speed_count,

zha/application/platforms/light/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
from zha.application.registries import PLATFORM_ENTITIES
6565
from zha.debounce import Debouncer
6666
from zha.decorators import periodic
67+
from zha.websocket.const import MODEL_CLASS_NAME
6768
from zha.zigbee.cluster_handlers.const import (
6869
CLUSTER_HANDLER_ATTRIBUTE_UPDATED,
6970
CLUSTER_HANDLER_COLOR,
@@ -778,7 +779,7 @@ def __init__(
778779
def info_object(self) -> LightEntityInfo:
779780
"""Return a representation of the select."""
780781
return LightEntityInfo(
781-
**super().info_object.model_dump(exclude=["model_class_name"]),
782+
**super().info_object.model_dump(exclude=[MODEL_CLASS_NAME]),
782783
effect_list=self.effect_list,
783784
supported_features=self.supported_features,
784785
min_mireds=self.min_mireds,
@@ -1148,7 +1149,7 @@ def __init__(self, group: Group):
11481149
def info_object(self) -> LightEntityInfo:
11491150
"""Return a representation of the select."""
11501151
return LightEntityInfo(
1151-
**super().info_object.model_dump(exclude=["model_class_name"]),
1152+
**super().info_object.model_dump(exclude=[MODEL_CLASS_NAME]),
11521153
effect_list=self.effect_list,
11531154
supported_features=self.supported_features,
11541155
min_mireds=self.min_mireds,

zha/application/platforms/lock/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
)
1919
from zha.application.platforms.lock.model import LockEntityInfo, LockState
2020
from zha.application.registries import PLATFORM_ENTITIES
21+
from zha.websocket.const import MODEL_CLASS_NAME
2122
from zha.zigbee.cluster_handlers.const import (
2223
CLUSTER_HANDLER_ATTRIBUTE_UPDATED,
2324
CLUSTER_HANDLER_DOORLOCK,
@@ -97,7 +98,7 @@ def __init__(
9798
def info_object(self) -> LockEntityInfo:
9899
"""Return a representation of the lock."""
99100
return LockEntityInfo(
100-
**super().info_object.model_dump(exclude=["model_class_name"])
101+
**super().info_object.model_dump(exclude=[MODEL_CLASS_NAME])
101102
)
102103

103104
@property

zha/application/platforms/number/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
)
3030
from zha.application.registries import PLATFORM_ENTITIES
3131
from zha.units import UnitOfMass, UnitOfTemperature, UnitOfTime, validate_unit
32+
from zha.websocket.const import MODEL_CLASS_NAME
3233
from zha.zigbee.cluster_handlers.const import (
3334
CLUSTER_HANDLER_ANALOG_OUTPUT,
3435
CLUSTER_HANDLER_ATTRIBUTE_UPDATED,
@@ -131,7 +132,7 @@ def __init__(
131132
def info_object(self) -> NumberEntityInfo:
132133
"""Return a representation of the number entity."""
133134
return NumberEntityInfo(
134-
**super().info_object.model_dump(exclude=["model_class_name"]),
135+
**super().info_object.model_dump(exclude=[MODEL_CLASS_NAME]),
135136
engineering_units=self._analog_output_cluster_handler.engineering_units,
136137
application_type=self._analog_output_cluster_handler.application_type,
137138
min_value=self.native_min_value,
@@ -310,7 +311,7 @@ def _init_from_quirks_metadata(self, entity_metadata: NumberMetadata) -> None:
310311
def info_object(self) -> NumberConfigurationEntityInfo:
311312
"""Return a representation of the number entity."""
312313
return NumberConfigurationEntityInfo(
313-
**super().info_object.model_dump(exclude=["model_class_name"]),
314+
**super().info_object.model_dump(exclude=[MODEL_CLASS_NAME]),
314315
min_value=self._attr_native_min_value,
315316
max_value=self._attr_native_max_value,
316317
step=self._attr_native_step,

0 commit comments

Comments
 (0)