1 """Map Z-Wave nodes and values to Home Assistant entities."""
3 from __future__
import annotations
5 from collections.abc
import Generator
6 from dataclasses
import asdict, dataclass, field
7 from enum
import StrEnum
8 from typing
import TYPE_CHECKING, Any, cast
10 from awesomeversion
import AwesomeVersion
11 from zwave_js_server.const
import (
12 CURRENT_STATE_PROPERTY,
13 CURRENT_VALUE_PROPERTY,
14 TARGET_STATE_PROPERTY,
15 TARGET_VALUE_PROPERTY,
18 from zwave_js_server.const.command_class.barrier_operator
import (
19 SIGNALING_STATE_PROPERTY,
21 from zwave_js_server.const.command_class.color_switch
import CURRENT_COLOR_PROPERTY
22 from zwave_js_server.const.command_class.humidity_control
import (
23 HUMIDITY_CONTROL_MODE_PROPERTY,
25 from zwave_js_server.const.command_class.lock
import (
26 CURRENT_MODE_PROPERTY,
30 from zwave_js_server.const.command_class.meter
import (
31 RESET_PROPERTY
as RESET_METER_PROPERTY,
34 from zwave_js_server.const.command_class.protection
import LOCAL_PROPERTY, RF_PROPERTY
35 from zwave_js_server.const.command_class.sound_switch
import (
36 DEFAULT_TONE_ID_PROPERTY,
37 DEFAULT_VOLUME_PROPERTY,
40 from zwave_js_server.const.command_class.thermostat
import (
41 THERMOSTAT_CURRENT_TEMP_PROPERTY,
42 THERMOSTAT_FAN_MODE_PROPERTY,
43 THERMOSTAT_MODE_PROPERTY,
44 THERMOSTAT_SETPOINT_PROPERTY,
46 from zwave_js_server.exceptions
import UnknownValueData
47 from zwave_js_server.model.node
import Node
as ZwaveNode
48 from zwave_js_server.model.value
import (
50 ConfigurationValueType,
58 from .const
import COVER_POSITION_PROPERTY_KEYS, COVER_TILT_PROPERTY_KEYS, LOGGER
59 from .discovery_data_template
import (
60 BaseDiscoverySchemaDataTemplate,
61 ConfigurableFanValueMappingDataTemplate,
62 CoverTiltDataTemplate,
63 DynamicCurrentTempClimateDataTemplate,
65 FixedFanValueMappingDataTemplate,
66 NumericSensorDataTemplate,
68 from .helpers
import ZwaveValueID
71 from _typeshed
import DataclassInstance
75 """Enum with all value types."""
84 """A dataclass that must have at least one input parameter that is not None."""
87 """Post dataclass initialization."""
88 if all(val
is None for val
in asdict(self).values()):
89 raise ValueError(
"At least one input parameter must not be None")
94 """Firmware version range dictionary."""
96 min: str |
None =
None
97 max: str |
None =
None
98 min_ver: AwesomeVersion |
None = field(default=
None, init=
False)
99 max_ver: AwesomeVersion |
None = field(default=
None, init=
False)
102 """Post dataclass initialization."""
105 self.
min_vermin_ver = AwesomeVersion(self.min)
107 self.
max_vermax_ver = AwesomeVersion(self.max)
112 """Info discovered from (primary) ZWave Value to create entity."""
117 primary_value: ZwaveValue
126 additional_value_ids_to_watch: set[str]
128 platform_hint: str |
None =
""
130 platform_data_template: BaseDiscoverySchemaDataTemplate |
None =
None
132 entity_registry_enabled_default: bool =
True
134 entity_category: EntityCategory |
None =
None
139 """Z-Wave Value discovery schema.
141 The Z-Wave Value must match these conditions.
142 Use the Z-Wave specifications to find out the values for these parameters:
143 https://github.com/zwave-js/specs/tree/master
147 command_class: set[int] |
None =
None
149 endpoint: set[int] |
None =
None
151 property: set[str | int] |
None =
None
153 property_name: set[str] |
None =
None
155 property_key: set[str | int |
None] |
None =
None
157 not_property_key: set[str | int |
None] |
None =
None
159 type: set[str] |
None =
None
161 readable: bool |
None =
None
163 writeable: bool |
None =
None
165 any_available_states: set[tuple[int, str]] |
None =
None
167 value: Any |
None =
None
169 stateful: bool |
None =
None
174 """Z-Wave discovery schema.
176 The Z-Wave node and it's (primary) value for an entity must match these conditions.
177 Use the Z-Wave specifications to find out the values for these parameters:
178 https://github.com/zwave-js/specs/tree/master
184 primary_value: ZWaveValueDiscoverySchema
186 hint: str |
None =
None
188 data_template: BaseDiscoverySchemaDataTemplate |
None =
None
190 manufacturer_id: set[int] |
None =
None
192 product_id: set[int] |
None =
None
194 product_type: set[int] |
None =
None
196 firmware_version_range: FirmwareVersionRange |
None =
None
198 device_class_generic: set[str] |
None =
None
200 device_class_specific: set[str] |
None =
None
203 required_values: list[ZWaveValueDiscoverySchema] |
None =
None
206 absent_values: list[ZWaveValueDiscoverySchema] |
None =
None
209 allow_multi: bool =
False
212 assumed_state: bool =
False
214 entity_registry_enabled_default: bool =
True
216 entity_category: EntityCategory |
None =
None
220 command_class={CommandClass.DOOR_LOCK},
221 property={CURRENT_MODE_PROPERTY},
222 type={ValueType.NUMBER},
226 command_class={CommandClass.SWITCH_MULTILEVEL},
227 property={CURRENT_VALUE_PROPERTY},
228 type={ValueType.NUMBER},
232 command_class={CommandClass.SWITCH_MULTILEVEL},
233 property={TARGET_VALUE_PROPERTY},
234 type={ValueType.NUMBER},
238 command_class={CommandClass.SWITCH_BINARY}, property={CURRENT_VALUE_PROPERTY}
242 command_class={CommandClass.SWITCH_COLOR},
243 property={CURRENT_COLOR_PROPERTY},
248 command_class={CommandClass.SOUND_SWITCH},
249 property={TONE_ID_PROPERTY},
250 type={ValueType.NUMBER},
254 command_class={CommandClass.WINDOW_COVERING},
255 property={CURRENT_VALUE_PROPERTY},
256 property_key=COVER_POSITION_PROPERTY_KEYS,
260 command_class={CommandClass.WINDOW_COVERING},
261 property={CURRENT_VALUE_PROPERTY},
262 property_key=COVER_TILT_PROPERTY_KEYS,
267 DISCOVERY_SCHEMAS = [
271 platform=Platform.FAN,
272 hint=
"has_fan_value_mapping",
273 manufacturer_id={0x0039},
275 product_type={0x4944},
276 primary_value=SWITCH_MULTILEVEL_CURRENT_VALUE_SCHEMA,
277 required_values=[SWITCH_MULTILEVEL_TARGET_VALUE_SCHEMA],
284 platform=Platform.FAN,
285 hint=
"has_fan_value_mapping",
286 manufacturer_id={0x0063},
288 product_type={0x4944},
289 primary_value=SWITCH_MULTILEVEL_CURRENT_VALUE_SCHEMA,
296 platform=Platform.FAN,
297 hint=
"has_fan_value_mapping",
298 manufacturer_id={0x0063},
299 product_id={0x3131, 0x3337},
300 product_type={0x4944},
301 primary_value=SWITCH_MULTILEVEL_CURRENT_VALUE_SCHEMA,
308 platform=Platform.FAN,
309 manufacturer_id={0x0063},
311 product_type={0x4944},
312 primary_value=SWITCH_MULTILEVEL_CURRENT_VALUE_SCHEMA,
316 platform=Platform.FAN,
317 hint=
"has_fan_value_mapping",
318 manufacturer_id={0x001D},
320 product_type={0x0038},
321 primary_value=SWITCH_MULTILEVEL_CURRENT_VALUE_SCHEMA,
329 platform=Platform.FAN,
330 hint=
"has_fan_value_mapping",
331 manufacturer_id={0x031E},
333 product_type={0x000E},
335 command_class={CommandClass.SWITCH_MULTILEVEL},
337 property={CURRENT_VALUE_PROPERTY},
338 type={ValueType.NUMBER},
342 presets={1:
"breeze"}, speeds=[(2, 33), (34, 66), (67, 99)]
348 platform=Platform.FAN,
349 hint=
"has_fan_value_mapping",
350 manufacturer_id={0x000C},
352 product_type={0x0203},
353 primary_value=SWITCH_MULTILEVEL_CURRENT_VALUE_SCHEMA,
356 property_=5, command_class=CommandClass.CONFIGURATION, endpoint=0
358 configuration_value_to_fan_value_mapping={
366 platform=Platform.COVER,
368 manufacturer_id={0x010F},
369 product_id={0x1000, 0x1001},
370 product_type={0x0301, 0x0302},
371 primary_value=SWITCH_MULTILEVEL_CURRENT_VALUE_SCHEMA,
375 command_class=CommandClass.MANUFACTURER_PROPRIETARY,
377 property_key=
"venetianBlindsTilt",
381 command_class=CommandClass.MANUFACTURER_PROPRIETARY,
383 property_key=
"venetianBlindsTilt",
388 command_class={CommandClass.MANUFACTURER_PROPRIETARY},
390 property_key={
"venetianBlindsTilt"},
398 platform=Platform.COVER,
400 manufacturer_id={0x010F},
401 product_id={0x1000, 0x1001},
402 product_type={0x0303},
404 command_class={CommandClass.SWITCH_MULTILEVEL},
405 property={CURRENT_VALUE_PROPERTY},
407 type={ValueType.NUMBER},
411 property_=CURRENT_VALUE_PROPERTY,
412 command_class=CommandClass.SWITCH_MULTILEVEL,
416 property_=TARGET_VALUE_PROPERTY,
417 command_class=CommandClass.SWITCH_MULTILEVEL,
423 command_class={CommandClass.CONFIGURATION},
436 platform=Platform.COVER,
438 manufacturer_id={0x010F},
439 product_id={0x1000, 0x1001},
440 product_type={0x0303},
442 command_class={CommandClass.SWITCH_MULTILEVEL},
443 property={CURRENT_VALUE_PROPERTY},
445 type={ValueType.NUMBER},
447 entity_registry_enabled_default=
False,
451 platform=Platform.COVER,
453 manufacturer_id={0x0441},
455 product_type={0x2400},
456 primary_value=SWITCH_MULTILEVEL_CURRENT_VALUE_SCHEMA,
457 required_values=[SWITCH_MULTILEVEL_TARGET_VALUE_SCHEMA],
463 platform=Platform.COVER,
465 manufacturer_id={0x0460},
467 product_type={0x0003},
469 command_class={CommandClass.SWITCH_MULTILEVEL},
470 property={CURRENT_VALUE_PROPERTY},
472 type={ValueType.NUMBER},
476 property_=CURRENT_VALUE_PROPERTY,
477 command_class=CommandClass.SWITCH_MULTILEVEL,
481 property_=TARGET_VALUE_PROPERTY,
482 command_class=CommandClass.SWITCH_MULTILEVEL,
488 command_class={CommandClass.CONFIGURATION},
501 platform=Platform.COVER,
503 manufacturer_id={0x0460},
505 product_type={0x0003},
507 command_class={CommandClass.SWITCH_MULTILEVEL},
508 property={CURRENT_VALUE_PROPERTY},
510 type={ValueType.NUMBER},
512 entity_registry_enabled_default=
False,
516 platform=Platform.COVER,
518 manufacturer_id={0x0159},
519 product_id={0x0052, 0x0053},
520 product_type={0x0003},
521 primary_value=SWITCH_MULTILEVEL_CURRENT_VALUE_SCHEMA,
525 platform=Platform.COVER,
527 manufacturer_id={0x026E},
529 product_type={0x4353},
530 primary_value=SWITCH_MULTILEVEL_CURRENT_VALUE_SCHEMA,
534 platform=Platform.COVER,
536 manufacturer_id={0x0287},
538 product_type={0x0003},
539 primary_value=SWITCH_MULTILEVEL_CURRENT_VALUE_SCHEMA,
543 platform=Platform.COVER,
545 manufacturer_id={0x007A},
547 product_type={0x8003},
549 command_class={CommandClass.SWITCH_MULTILEVEL},
550 property={CURRENT_VALUE_PROPERTY},
552 type={ValueType.NUMBER},
559 platform=Platform.COVER,
561 manufacturer_id={0x007A},
563 product_type={0x8003},
565 command_class={CommandClass.SWITCH_MULTILEVEL},
566 property={CURRENT_VALUE_PROPERTY},
568 type={ValueType.NUMBER},
571 entity_registry_enabled_default=
False,
576 platform=Platform.SELECT,
577 manufacturer_id={0x007A},
579 product_type={0x8003},
581 command_class={CommandClass.PROTECTION},
582 property={LOCAL_PROPERTY, RF_PROPERTY},
584 type={ValueType.NUMBER},
586 entity_registry_enabled_default=
False,
590 platform=Platform.COVER,
592 manufacturer_id={0x045A},
594 product_type={0x0904},
595 primary_value=SWITCH_MULTILEVEL_CURRENT_VALUE_SCHEMA,
599 platform=Platform.SWITCH,
600 manufacturer_id={0x0109},
601 product_id={0x1711, 0x1717},
602 product_type={0x2017},
603 primary_value=SWITCH_BINARY_CURRENT_VALUE_SCHEMA,
608 platform=Platform.CLIMATE,
609 hint=
"dynamic_current_temp",
610 manufacturer_id={0x019B},
612 product_type={0x0030},
614 command_class={CommandClass.THERMOSTAT_MODE},
615 property={THERMOSTAT_MODE_PROPERTY},
616 type={ValueType.NUMBER},
622 property_=THERMOSTAT_CURRENT_TEMP_PROPERTY,
623 command_class=CommandClass.SENSOR_MULTILEVEL,
628 property_=THERMOSTAT_CURRENT_TEMP_PROPERTY,
629 command_class=CommandClass.SENSOR_MULTILEVEL,
634 property_=THERMOSTAT_CURRENT_TEMP_PROPERTY,
635 command_class=CommandClass.SENSOR_MULTILEVEL,
640 property_=THERMOSTAT_CURRENT_TEMP_PROPERTY,
641 command_class=CommandClass.SENSOR_MULTILEVEL,
646 property_=THERMOSTAT_CURRENT_TEMP_PROPERTY,
647 command_class=CommandClass.SENSOR_MULTILEVEL,
658 property_=THERMOSTAT_CURRENT_TEMP_PROPERTY,
659 command_class=CommandClass.SENSOR_MULTILEVEL,
664 property_=2, command_class=CommandClass.CONFIGURATION, endpoint=0
670 platform=Platform.CLIMATE,
671 hint=
"dynamic_current_temp",
672 manufacturer_id={0x019B},
674 product_type={0x0003},
676 command_class={CommandClass.THERMOSTAT_MODE},
677 property={THERMOSTAT_MODE_PROPERTY},
678 type={ValueType.NUMBER},
684 property_=THERMOSTAT_CURRENT_TEMP_PROPERTY,
685 command_class=CommandClass.SENSOR_MULTILEVEL,
689 property_=THERMOSTAT_CURRENT_TEMP_PROPERTY,
690 command_class=CommandClass.SENSOR_MULTILEVEL,
695 property_=THERMOSTAT_CURRENT_TEMP_PROPERTY,
696 command_class=CommandClass.SENSOR_MULTILEVEL,
700 property_=THERMOSTAT_CURRENT_TEMP_PROPERTY,
701 command_class=CommandClass.SENSOR_MULTILEVEL,
706 property_=THERMOSTAT_CURRENT_TEMP_PROPERTY,
707 command_class=CommandClass.SENSOR_MULTILEVEL,
712 property_=2, command_class=CommandClass.CONFIGURATION, endpoint=0
718 platform=Platform.CLIMATE,
719 hint=
"dynamic_current_temp",
720 manufacturer_id={0x019B},
722 product_type={0x0003},
725 command_class={CommandClass.THERMOSTAT_MODE},
726 property={THERMOSTAT_MODE_PROPERTY},
727 type={ValueType.NUMBER},
733 property_=THERMOSTAT_CURRENT_TEMP_PROPERTY,
734 command_class=CommandClass.SENSOR_MULTILEVEL,
738 property_=THERMOSTAT_CURRENT_TEMP_PROPERTY,
739 command_class=CommandClass.SENSOR_MULTILEVEL,
744 property_=THERMOSTAT_CURRENT_TEMP_PROPERTY,
745 command_class=CommandClass.SENSOR_MULTILEVEL,
750 property_=2, command_class=CommandClass.CONFIGURATION, endpoint=0
756 platform=Platform.SELECT,
757 hint=
"multilevel_switch",
758 manufacturer_id={0x0084},
759 product_id={0x0107, 0x0108, 0x010B, 0x0205},
760 product_type={0x0311, 0x0313, 0x0331, 0x0341, 0x0343},
761 primary_value=SWITCH_MULTILEVEL_CURRENT_VALUE_SCHEMA,
767 99:
"Siren & Strobe FULL Alarm",
775 platform=Platform.LOCK,
776 primary_value=DOOR_LOCK_CURRENT_MODE_SCHEMA,
780 platform=Platform.SELECT,
781 primary_value=DOOR_LOCK_CURRENT_MODE_SCHEMA,
786 platform=Platform.LOCK,
788 command_class={CommandClass.LOCK},
789 property={LOCKED_PROPERTY},
790 type={ValueType.BOOLEAN},
792 absent_values=[DOOR_LOCK_CURRENT_MODE_SCHEMA],
796 platform=Platform.BINARY_SENSOR,
801 CommandClass.DOOR_LOCK,
803 property={DOOR_STATUS_PROPERTY},
804 type={ValueType.ANY},
809 platform=Platform.FAN,
810 hint=
"thermostat_fan",
812 command_class={CommandClass.THERMOSTAT_FAN_MODE},
813 property={THERMOSTAT_FAN_MODE_PROPERTY},
814 type={ValueType.NUMBER},
816 entity_registry_enabled_default=
False,
821 platform=Platform.HUMIDIFIER,
823 command_class={CommandClass.HUMIDITY_CONTROL_MODE},
824 property={HUMIDITY_CONTROL_MODE_PROPERTY},
825 type={ValueType.NUMBER},
831 platform=Platform.CLIMATE,
833 command_class={CommandClass.THERMOSTAT_MODE},
834 property={THERMOSTAT_MODE_PROPERTY},
835 type={ValueType.NUMBER},
840 platform=Platform.CLIMATE,
842 command_class={CommandClass.THERMOSTAT_SETPOINT},
843 property={THERMOSTAT_SETPOINT_PROPERTY},
844 type={ValueType.NUMBER},
848 command_class={CommandClass.THERMOSTAT_MODE},
849 property={THERMOSTAT_MODE_PROPERTY},
850 type={ValueType.NUMBER},
858 platform=Platform.BINARY_SENSOR,
860 device_class_generic={
"Binary Sensor"},
862 command_class={CommandClass.SENSOR_BINARY},
863 type={ValueType.BOOLEAN},
869 platform=Platform.BINARY_SENSOR,
872 command_class={CommandClass.SENSOR_BINARY},
873 type={ValueType.BOOLEAN},
875 entity_registry_enabled_default=
False,
878 platform=Platform.BINARY_SENSOR,
882 CommandClass.BATTERY,
883 CommandClass.SENSOR_ALARM,
885 type={ValueType.BOOLEAN},
890 platform=Platform.BINARY_SENSOR,
893 command_class={CommandClass.INDICATOR},
894 type={ValueType.BOOLEAN},
898 entity_category=EntityCategory.DIAGNOSTIC,
902 platform=Platform.SENSOR,
903 hint=
"string_sensor",
905 command_class={CommandClass.SENSOR_ALARM},
906 type={ValueType.STRING},
911 platform=Platform.SENSOR,
912 hint=
"numeric_sensor",
915 CommandClass.BATTERY,
916 CommandClass.ENERGY_PRODUCTION,
917 CommandClass.SENSOR_ALARM,
918 CommandClass.SENSOR_MULTILEVEL,
920 type={ValueType.NUMBER},
925 platform=Platform.SENSOR,
926 hint=
"numeric_sensor",
928 command_class={CommandClass.INDICATOR},
929 type={ValueType.NUMBER},
934 entity_category=EntityCategory.DIAGNOSTIC,
938 platform=Platform.SENSOR,
944 type={ValueType.NUMBER},
945 property={VALUE_PROPERTY},
951 platform=Platform.NUMBER,
953 command_class={CommandClass.INDICATOR},
954 type={ValueType.NUMBER},
955 not_property_key={3, 4, 5},
959 entity_category=EntityCategory.CONFIG,
963 platform=Platform.BUTTON,
965 command_class={CommandClass.INDICATOR},
966 type={ValueType.BOOLEAN},
970 entity_category=EntityCategory.CONFIG,
974 platform=Platform.SWITCH,
977 command_class={CommandClass.INDICATOR},
978 type={ValueType.BOOLEAN},
982 entity_category=EntityCategory.CONFIG,
987 platform=Platform.SWITCH,
988 hint=
"barrier_event_signaling_state",
990 command_class={CommandClass.BARRIER_OPERATOR},
991 property={SIGNALING_STATE_PROPERTY},
992 type={ValueType.NUMBER},
998 platform=Platform.COVER,
999 hint=
"window_covering",
1000 primary_value=WINDOW_COVERING_COVER_CURRENT_VALUE_SCHEMA,
1003 platform=Platform.COVER,
1004 hint=
"window_covering",
1005 primary_value=WINDOW_COVERING_SLAT_CURRENT_VALUE_SCHEMA,
1006 absent_values=[WINDOW_COVERING_COVER_CURRENT_VALUE_SCHEMA],
1009 platform=Platform.COVER,
1010 hint=
"multilevel_switch",
1011 device_class_generic={
"Multilevel Switch"},
1012 device_class_specific={
1013 "Motor Control Class A",
1014 "Motor Control Class B",
1015 "Motor Control Class C",
1016 "Multiposition Motor",
1018 primary_value=SWITCH_MULTILEVEL_CURRENT_VALUE_SCHEMA,
1020 WINDOW_COVERING_COVER_CURRENT_VALUE_SCHEMA,
1021 WINDOW_COVERING_SLAT_CURRENT_VALUE_SCHEMA,
1027 platform=Platform.COVER,
1028 hint=
"motorized_barrier",
1030 command_class={CommandClass.BARRIER_OPERATOR},
1031 property={CURRENT_STATE_PROPERTY},
1032 type={ValueType.NUMBER},
1036 command_class={CommandClass.BARRIER_OPERATOR},
1037 property={TARGET_STATE_PROPERTY},
1038 type={ValueType.NUMBER},
1044 platform=Platform.FAN,
1046 device_class_generic={
"Multilevel Switch"},
1047 device_class_specific={
"Fan Switch"},
1048 primary_value=SWITCH_MULTILEVEL_CURRENT_VALUE_SCHEMA,
1049 required_values=[SWITCH_MULTILEVEL_TARGET_VALUE_SCHEMA],
1054 platform=Platform.NUMBER,
1055 hint=
"Valve control",
1056 device_class_generic={
"Thermostat"},
1057 primary_value=SWITCH_MULTILEVEL_CURRENT_VALUE_SCHEMA,
1067 platform=Platform.LIGHT,
1068 primary_value=SWITCH_MULTILEVEL_CURRENT_VALUE_SCHEMA,
1073 platform=Platform.SWITCH,
1074 primary_value=SWITCH_BINARY_CURRENT_VALUE_SCHEMA,
1076 SWITCH_MULTILEVEL_CURRENT_VALUE_SCHEMA,
1077 COLOR_SWITCH_CURRENT_VALUE_SCHEMA,
1083 platform=Platform.LIGHT,
1085 primary_value=SWITCH_BINARY_CURRENT_VALUE_SCHEMA,
1086 required_values=[COLOR_SWITCH_CURRENT_VALUE_SCHEMA],
1090 platform=Platform.SWITCH,
1091 primary_value=SWITCH_BINARY_CURRENT_VALUE_SCHEMA,
1092 absent_values=[COLOR_SWITCH_CURRENT_VALUE_SCHEMA],
1096 platform=Platform.LIGHT,
1098 primary_value=COLOR_SWITCH_CURRENT_VALUE_SCHEMA,
1100 SWITCH_BINARY_CURRENT_VALUE_SCHEMA,
1101 SWITCH_MULTILEVEL_CURRENT_VALUE_SCHEMA,
1106 platform=Platform.LIGHT,
1108 command_class={CommandClass.BASIC},
1109 type={ValueType.NUMBER},
1110 property={CURRENT_VALUE_PROPERTY},
1114 command_class={CommandClass.BASIC},
1115 type={ValueType.NUMBER},
1116 property={TARGET_VALUE_PROPERTY},
1122 platform=Platform.SENSOR,
1123 hint=
"numeric_sensor",
1125 command_class={CommandClass.BASIC},
1126 type={ValueType.NUMBER},
1127 property={CURRENT_VALUE_PROPERTY},
1131 command_class={CommandClass.BASIC},
1132 type={ValueType.NUMBER},
1133 property={TARGET_VALUE_PROPERTY},
1139 platform=Platform.SIREN,
1140 primary_value=SIREN_TONE_SCHEMA,
1145 platform=Platform.SELECT,
1146 hint=
"Default tone",
1148 command_class={CommandClass.SOUND_SWITCH},
1149 property={DEFAULT_TONE_ID_PROPERTY},
1150 type={ValueType.NUMBER},
1152 required_values=[SIREN_TONE_SCHEMA],
1157 platform=Platform.NUMBER,
1160 command_class={CommandClass.SOUND_SWITCH},
1161 property={DEFAULT_VOLUME_PROPERTY},
1162 type={ValueType.NUMBER},
1164 required_values=[SIREN_TONE_SCHEMA],
1169 platform=Platform.SELECT,
1171 command_class={CommandClass.PROTECTION},
1172 property={LOCAL_PROPERTY, RF_PROPERTY},
1173 type={ValueType.NUMBER},
1179 platform=Platform.BUTTON,
1180 hint=
"notification idle",
1182 command_class={CommandClass.NOTIFICATION},
1183 type={ValueType.NUMBER},
1184 any_available_states={(0,
"idle")},
1191 platform=Platform.EVENT,
1200 platform=Platform.BUTTON,
1203 command_class={CommandClass.METER},
1204 property={RESET_METER_PROPERTY},
1205 type={ValueType.BOOLEAN},
1207 entity_category=EntityCategory.DIAGNOSTIC,
1210 platform=Platform.BINARY_SENSOR,
1211 hint=
"notification",
1214 CommandClass.NOTIFICATION,
1216 type={ValueType.NUMBER},
1224 platform=Platform.SENSOR,
1225 hint=
"notification_alarm",
1228 CommandClass.NOTIFICATION,
1230 property={
"alarmType",
"alarmLevel"},
1231 type={ValueType.NUMBER},
1233 entity_registry_enabled_default=
False,
1237 platform=Platform.SENSOR,
1238 hint=
"notification",
1241 CommandClass.NOTIFICATION,
1243 type={ValueType.NUMBER},
1250 def async_discover_node_values(
1251 node: ZwaveNode, device: DeviceEntry, discovered_value_ids: dict[str, set[str]]
1252 ) -> Generator[ZwaveDiscoveryInfo]:
1253 """Run discovery on ZWave node and return matching (primary) values."""
1254 for value
in node.values.values():
1256 if value.value_id
not in discovered_value_ids[device.id]:
1257 yield from async_discover_single_value(value, device, discovered_value_ids)
1261 def async_discover_single_value(
1262 value: ZwaveValue, device: DeviceEntry, discovered_value_ids: dict[str, set[str]]
1263 ) -> Generator[ZwaveDiscoveryInfo]:
1264 """Run discovery on a single ZWave value and return matching schema info."""
1265 for schema
in DISCOVERY_SCHEMAS:
1267 if value.value_id
in discovered_value_ids[device.id]:
1273 schema.manufacturer_id
is not None
1274 and value.node.manufacturer_id
not in schema.manufacturer_id
1277 schema.product_id
is not None
1278 and value.node.product_id
not in schema.product_id
1281 schema.product_type
is not None
1282 and value.node.product_type
not in schema.product_type
1288 if schema.firmware_version_range
is not None and (
1290 schema.firmware_version_range.min
is not None
1291 and schema.firmware_version_range.min_ver
1292 > AwesomeVersion(value.node.firmware_version)
1295 schema.firmware_version_range.max
is not None
1296 and schema.firmware_version_range.max_ver
1297 < AwesomeVersion(value.node.firmware_version)
1303 if schema.device_class_generic
and (
1304 not value.node.device_class
1306 value.node.device_class.generic.label == val
1307 for val
in schema.device_class_generic
1313 if schema.device_class_specific
and (
1314 not value.node.device_class
1316 value.node.device_class.specific.label == val
1317 for val
in schema.device_class_specific
1323 if not check_value(value, schema.primary_value):
1327 if schema.required_values
is not None and not all(
1329 check_value(val, val_scheme, primary_value=value)
1330 for val
in value.node.values.values()
1332 for val_scheme
in schema.required_values
1337 if schema.absent_values
is not None and any(
1339 check_value(val, val_scheme, primary_value=value)
1340 for val
in value.node.values.values()
1342 for val_scheme
in schema.absent_values
1347 resolved_data =
None
1348 additional_value_ids_to_watch = set()
1349 if schema.data_template:
1351 resolved_data = schema.data_template.resolve_data(value)
1352 except UnknownValueData
as err:
1354 "Discovery for value %s on device '%s' (%s) will be skipped: %s",
1356 device.name_by_user
or device.name,
1361 additional_value_ids_to_watch = schema.data_template.value_ids_to_watch(
1368 primary_value=value,
1369 assumed_state=schema.assumed_state,
1370 platform=schema.platform,
1371 platform_hint=schema.hint,
1372 platform_data_template=schema.data_template,
1373 platform_data=resolved_data,
1374 additional_value_ids_to_watch=additional_value_ids_to_watch,
1375 entity_registry_enabled_default=schema.entity_registry_enabled_default,
1376 entity_category=schema.entity_category,
1380 if not schema.allow_multi:
1381 discovered_value_ids[device.id].
add(value.value_id)
1384 discovered_value_ids[device.id].
add(value.value_id)
1386 if value.command_class == CommandClass.CONFIGURATION:
1387 yield from async_discover_single_configuration_value(
1388 cast(ConfigurationValue, value)
1393 def async_discover_single_configuration_value(
1394 value: ConfigurationValue,
1395 ) -> Generator[ZwaveDiscoveryInfo]:
1396 """Run discovery on single Z-Wave configuration value and return schema matches."""
1397 if value.metadata.writeable
and value.metadata.readable:
1398 if value.configuration_value_type == ConfigurationValueType.ENUMERATED:
1401 primary_value=value,
1402 assumed_state=
False,
1403 platform=Platform.SELECT,
1404 platform_hint=
"config_parameter",
1406 additional_value_ids_to_watch=set(),
1407 entity_registry_enabled_default=
False,
1409 elif value.configuration_value_type
in (
1410 ConfigurationValueType.RANGE,
1411 ConfigurationValueType.MANUAL_ENTRY,
1415 primary_value=value,
1416 assumed_state=
False,
1417 platform=Platform.NUMBER,
1418 platform_hint=
"config_parameter",
1420 additional_value_ids_to_watch=set(),
1421 entity_registry_enabled_default=
False,
1423 elif value.configuration_value_type == ConfigurationValueType.BOOLEAN:
1426 primary_value=value,
1427 assumed_state=
False,
1428 platform=Platform.SWITCH,
1429 platform_hint=
"config_parameter",
1431 additional_value_ids_to_watch=set(),
1432 entity_registry_enabled_default=
False,
1434 elif not value.metadata.writeable
and value.metadata.readable:
1435 if value.configuration_value_type == ConfigurationValueType.BOOLEAN:
1438 primary_value=value,
1439 assumed_state=
False,
1440 platform=Platform.BINARY_SENSOR,
1441 platform_hint=
"config_parameter",
1443 additional_value_ids_to_watch=set(),
1444 entity_registry_enabled_default=
False,
1449 primary_value=value,
1450 assumed_state=
False,
1451 platform=Platform.SENSOR,
1452 platform_hint=
"config_parameter",
1454 additional_value_ids_to_watch=set(),
1455 entity_registry_enabled_default=
False,
1462 schema: ZWaveValueDiscoverySchema,
1463 primary_value: ZwaveValue |
None =
None,
1465 """Check if value matches scheme."""
1468 schema.command_class
is not None
1469 and value.command_class
not in schema.command_class
1473 if schema.endpoint
is not None and value.endpoint
not in schema.endpoint:
1478 schema.endpoint
is None
1479 and primary_value
is not None
1480 and value.endpoint != primary_value.endpoint
1484 if schema.property
is not None and value.property_
not in schema.property:
1488 schema.property_name
is not None
1489 and value.property_name
not in schema.property_name
1494 schema.property_key
is not None
1495 and value.property_key
not in schema.property_key
1500 schema.not_property_key
is not None
1501 and value.property_key
in schema.not_property_key
1505 if schema.type
is not None and value.metadata.type
not in schema.type:
1508 if schema.readable
is not None and value.metadata.readable != schema.readable:
1511 if schema.writeable
is not None and value.metadata.writeable != schema.writeable:
1515 schema.any_available_states
is not None
1516 and value.metadata.states
is not None
1518 str(key)
in value.metadata.states
and value.metadata.states[
str(key)] == val
1519 for key, val
in schema.any_available_states
1524 if schema.value
is not None and value.value
not in schema.value:
1527 if schema.stateful
is not None and value.metadata.stateful != schema.stateful:
None __post_init__(DataclassInstance self)
bool add(self, _T matcher)