File tree Expand file tree Collapse file tree 3 files changed +27
-2
lines changed Expand file tree Collapse file tree 3 files changed +27
-2
lines changed Original file line number Diff line number Diff line change 4
4
import itertools
5
5
6
6
import zigpy .quirks
7
- from zigpy .quirks .v2 import QuirksV2RegistryEntry
7
+ from zigpy .quirks .v2 import (
8
+ EntityPlatform ,
9
+ EntityType ,
10
+ QuirksV2RegistryEntry ,
11
+ ZCLEnumMetadata ,
12
+ )
8
13
9
14
import zhaquirks
10
15
@@ -70,3 +75,21 @@ def test_manufacturer_model_metadata_unique() -> None:
70
75
assert len (quirk_locations ) == 1 , (
71
76
f"Manufacturer-model pair '{ manufacturer } ' '{ model } ' is shared by multiple quirks: { quirk_locations } "
72
77
)
78
+
79
+
80
+ def test_enum_sensor_category () -> None :
81
+ """Ensure enum metadata with sensor entity platform has valid entity category."""
82
+ for quirk in ALL_QUIRK_V2_CLASSES :
83
+ for entity_metadata in quirk .entity_metadata :
84
+ if (
85
+ isinstance (entity_metadata , ZCLEnumMetadata )
86
+ and entity_metadata .entity_platform is EntityPlatform .SENSOR
87
+ ):
88
+ assert entity_metadata .entity_type in (
89
+ EntityType .STANDARD ,
90
+ EntityType .DIAGNOSTIC ,
91
+ ), (
92
+ f"Enum sensor '{ entity_metadata .translation_key } ' in "
93
+ f"{ quirk .quirk_file } :{ quirk .quirk_file_line } "
94
+ f"has invalid entity type '{ entity_metadata .entity_type } '"
95
+ )
Original file line number Diff line number Diff line change 1
1
"""Tuya illuminance sensors."""
2
2
3
- from zigpy .quirks .v2 import EntityPlatform
3
+ from zigpy .quirks .v2 import EntityPlatform , EntityType
4
4
from zigpy .types import t
5
5
6
6
from zhaquirks .tuya .builder import TuyaQuirkBuilder
@@ -23,6 +23,7 @@ class BrightnessLevel(t.enum8):
23
23
dp_id = 1 ,
24
24
attribute_name = "brightness_level" ,
25
25
enum_class = BrightnessLevel ,
26
+ entity_type = EntityType .STANDARD ,
26
27
entity_platform = EntityPlatform .SENSOR ,
27
28
translation_key = "brightness_level" ,
28
29
fallback_name = "Brightness level" ,
Original file line number Diff line number Diff line change @@ -510,6 +510,7 @@ class GiexIrrigationStatus(t.enum8):
510
510
dp_id = 3 ,
511
511
attribute_name = "valve_status" ,
512
512
enum_class = TuyaValveStatus ,
513
+ entity_type = EntityType .STANDARD ,
513
514
entity_platform = EntityPlatform .SENSOR ,
514
515
translation_key = "valve_status" ,
515
516
fallback_name = "Valve status" ,
You can’t perform that action at this time.
0 commit comments