diff --git a/majordom_zigbee/controller.py b/majordom_zigbee/controller.py index dc1cb58..79fdbae 100644 --- a/majordom_zigbee/controller.py +++ b/majordom_zigbee/controller.py @@ -80,6 +80,8 @@ # In practice, reading too many attributes at once keeps the serial line busy # long enough to trigger NCP ACK timeouts. _MAX_ATTRS_PER_REQUEST = 25 +# Upper bound of one fetch: a sleeping device answers nothing, each cluster read then waits out its own timeout +_FETCH_TIMEOUT = 60 def _log_task_exception(task: asyncio.Task[Any]): @@ -174,7 +176,7 @@ def _zb_path( parts: list[str] = [] if device is not None: model = zbdevice.model if zbdevice is not None else None - parts.append(f"device={device.id}" + (f"({model})" if model else "")) + parts.append(f"device={device.physical_id}" + (f"({model})" if model else "")) if endpoint is not None: ep_type = getattr(endpoint.device_type, "name", None) parts.append(f"endpoint={endpoint.endpoint_id}" + (f"({ep_type})" if ep_type else "")) @@ -261,7 +263,7 @@ def _check_zcl_failures( log.error(f"{log_prefix} ZCL failures:\n\t{details}") -class ZigBeeController(AbstractController[ZBDevice, ZBParameter, "ZigBeeController.Settings"]): +class ZigBeeController(AbstractController[ZBDevice, ZBParameter, "ZigBeeController.Settings", ZBDeviceState]): """Bridges the Hub to Zigbee devices through a USB coordinator radio via zigpy. zigpy owns the Zigbee network, the ZCL, and device interviews; this controller adapts it @@ -302,7 +304,7 @@ def __init__(self, platform: Platform, *, settings: Settings | None = None): self._majordom_discoveries: dict[UUID, Discovery] = {} self._awaiting_zb_discoveries: dict[UUID, ZPDevice] = {} self._connected_devices: dict[UUID, ZPDevice] = {} - self._availability: dict[UUID, bool] = {} # device_id -> last signalled availability + self._availability: dict[UUID, bool] = {} # physical_id -> last signalled availability self._subscriptions: dict[UUID, list[tuple[zigpy.zcl.Cluster, ZBAttributeUpdatedListener]]] = {} self._tasks: set[asyncio.Task[Any]] = set() self._application: ControllerApplication | None = None # while started @@ -331,6 +333,11 @@ def device_type(self) -> type[ZBDevice]: def parameter_type(self) -> type[ZBParameter]: return ZBParameter + @property + @override + def device_state_type(self) -> type[ZBDeviceState]: + return ZBDeviceState + # ------------------------------------------------------------------------- # Lifecycle # ------------------------------------------------------------------------- @@ -392,13 +399,13 @@ async def _open(self): for zbdevice in self._application.devices.values(): if zbdevice.nwk == 0x0000: continue - device_id = self._mapper.device_uuid_from_ieee(self._mapper.convert_eui64_to_str(zbdevice.ieee)) - if await device_repo.get(device_id, ZBDevice): - self._connected_devices[device_id] = zbdevice - await self._subscribe(device_id, zbdevice) + physical_id = self._mapper.device_uuid_from_ieee(zbdevice.ieee) + if await device_repo.get(physical_id=physical_id, as_=ZBDevice): + self._connected_devices[physical_id] = zbdevice + await self._subscribe(physical_id, zbdevice) log.debug(f"[KNOWN] ieee={zbdevice.ieee} nwk=0x{zbdevice.nwk:04X}") else: - self._create_task(self._disconnect_unpaired_discovery(device_id, zbdevice.ieee)) + self._create_task(self._disconnect_unpaired_discovery(physical_id, zbdevice.ieee)) log.debug( f"[UNKNOWN] ieee={zbdevice.ieee} nwk=0x{zbdevice.nwk:04X} — " "not in DB, starting disconnect timer" @@ -412,14 +419,14 @@ async def _open(self): continue device.available = False device.last_error = f"Device {device.name} is no longer connected to the ZigBee network" - self._availability[device.id] = False # baseline for mid-session transitions - await device_repo.save(device, device.id) + self._availability[device.physical_id] = False # baseline for mid-session transitions + await device_repo.save(device) # the Hub marked them unavailable when Zigbee stopped - for device_id, zbdevice in list(self._connected_devices.items()): + for physical_id, zbdevice in list(self._connected_devices.items()): if _is_seen_lately(zbdevice): - await self._set_availability(device_id, True) + await self._set_availability(physical_id, True) else: - self._availability[device_id] = False # left or died: until its next message + self._availability[physical_id] = False # left or died: until its next message async def _close(self): """Lets go of the radio and of what was found on it.""" @@ -452,237 +459,249 @@ async def start_pairing_window(self, duration_sec: int, credentials: ProvidedCre await self._application.permit(duration_sec) async def pair_device( - self, discovery: Discovery, credentials: ProvidedCredentials | None - ): # Break down into submethods - async with self.platform.device_repository(self) as device_repository: - device = await device_repository.state(discovery.id, ZBDeviceState) - self._majordom_discoveries.pop(discovery.id) - zbdevice = self._awaiting_zb_discoveries.pop(discovery.id) - self._connected_devices[discovery.id] = zbdevice - - assert device - assert zbdevice - - if not device.integration_data.ieee: - device.integration_data = ZBDeviceIntegrationData(ieee=self._mapper.convert_eui64_to_str(zbdevice.ieee)) - # Manufacturer-provided, read-only description — the ZCL model string. - device.description = zbdevice.model or None - parameters: list[ParameterState[ZBParameterIntegrationData]] = list() - # v2 QuirkBuilder entity judgment for this device (empty for non-quirked devices). - quirk_ux = quirk_ux_map(zbdevice) - for endpoint in zbdevice.non_zdo_endpoints: - # Only server (input) clusters: output clusters are client-side, so their attributes - # live on the remote and fetch/send_command never reach them. - for cluster in endpoint.in_clusters.values(): - # Probe before mapping: a simple descriptor often lists clusters the firmware - # doesn't implement (e.g. Tuya relays with Metering/ElectricalMeasurement). The - # read marks unsupported attributes, so only what the device has gets exposed. - await self._read_cluster_attributes( - device, - zbdevice, - endpoint, - cluster, - self._readable_attribute_ids(cluster), - log_prefix="[PAIR]", - timeout=2, - ) - if self._is_unimplemented(cluster): - log.debug(f"[PAIR] skipping unimplemented {_zb_path(endpoint=endpoint, cluster=cluster)}") + self, discovery: Discovery, draft: ZBDeviceState, credentials: ProvidedCredentials | None + ) -> ZBDeviceState: # Break down into submethods + device = draft + zbdevice = self._awaiting_zb_discoveries[discovery.id] + device.physical_id = self._mapper.device_uuid_from_ieee(zbdevice.ieee) + await self.check_device_id(device.physical_id, device) + # Still offered until the Hub saves it (it fetches it then): joined, the node needs nothing undone, and a + # failed or unsaved pairing is retried from the same discovery (the node leaves after the join timeout) + device.integration_data = ZBDeviceIntegrationData(ieee=self._mapper.convert_eui64_to_str(zbdevice.ieee)) + # Manufacturer-provided, read-only description — the ZCL model string. + device.description = zbdevice.model or None + parameters: list[ParameterState[ZBParameterIntegrationData]] = list() + # v2 QuirkBuilder entity judgment for this device (empty for non-quirked devices). + quirk_ux = quirk_ux_map(zbdevice) + for endpoint in zbdevice.non_zdo_endpoints: + # Only server (input) clusters: output clusters are client-side, so their attributes + # live on the remote and fetch/send_command never reach them. + for cluster in endpoint.in_clusters.values(): + # Probe before mapping: a simple descriptor often lists clusters the firmware + # doesn't implement (e.g. Tuya relays with Metering/ElectricalMeasurement). The + # read marks unsupported attributes, so only what the device has gets exposed. + await self._read_cluster_attributes( + device, + zbdevice, + endpoint, + cluster, + self._readable_attribute_ids(cluster), + log_prefix="[PAIR]", + timeout=2, + ) + if self._is_unimplemented(cluster): + log.debug(f"[PAIR] skipping unimplemented {_zb_path(endpoint=endpoint, cluster=cluster)}") + continue + for attribute_id, attribute in cluster.attributes.items(): + if cluster.is_attribute_unsupported(attribute_id): continue - for attribute_id, attribute in cluster.attributes.items(): - if cluster.is_attribute_unsupported(attribute_id): - continue - - value = None - - # Classification via the priority ladder (see the zigbee README): our hand - # overrides > v2 quirk metadata > harvested zha judgment > fallback heuristic - # (which warns). Metadata and manufacturer-on-system-cluster attrs are hidden. - spec, source = classify_attribute( - cluster.cluster_id, - attribute_id, - attribute.name, - writable=bool(attribute.access & ZCLAttributeAccess.Write), - reportable=bool(attribute.access & ZCLAttributeAccess.Report), - quirk_ux=quirk_ux.get((endpoint.endpoint_id, cluster.cluster_id, attribute.name)), + + value = None + + # Classification via the priority ladder (see the zigbee README): our hand + # overrides > v2 quirk metadata > harvested zha judgment > fallback heuristic + # (which warns). Metadata and manufacturer-on-system-cluster attrs are hidden. + spec, source = classify_attribute( + cluster.cluster_id, + attribute_id, + attribute.name, + writable=bool(attribute.access & ZCLAttributeAccess.Write), + reportable=bool(attribute.access & ZCLAttributeAccess.Report), + quirk_ux=quirk_ux.get((endpoint.endpoint_id, cluster.cluster_id, attribute.name)), + ) + visibility = spec.visibility + role = ( + spec.role + if spec.role is not None + else self._mapper.parse_zigbee_attribute_access(attribute.access) + ) + if source.startswith("fallback"): + log.warning( + "[PAIR] uncurated attribute " + f"{_zb_path(cluster=cluster, attr_id=attribute_id, attr_only=True)} -> " + f"{visibility.value} ({source}); add to OUR_ATTRIBUTE_UX or refresh the zha harvest" ) - visibility = spec.visibility - role = ( - spec.role - if spec.role is not None - else self._mapper.parse_zigbee_attribute_access(attribute.access) + + data_type = self._mapper.parse_zigbee_data_type(attribute.zcl_type) + min_value = None + max_value = None + # Annotated so the untyped-enum comprehension below (member.name is Unknown) + # matches Parameter.valid_values' declared type. + valid_values: dict[int | float | str, str] | None = None + min_step = get_min_step(cluster.cluster_id, attribute_id) + # Our spec tables win; the harvested/quirk unit fills gaps get_unit() leaves plain. + unit = get_unit(cluster.cluster_id, attribute_id) + if unit is ParameterUnit.plain and spec.unit is not None: + unit = spec.unit + + if hasattr(attribute.type, "min_value"): + min_value = attribute.type.min_value + if hasattr(attribute.type, "max_value"): + max_value = attribute.type.max_value + + # Metadata priority 1: the device's own limit attributes (runtime values) win + # over the wire-type default. cluster.get returns the cached sibling value. + min_value, max_value, missing_bounds = resolve_metadata_bounds( + cluster.cluster_id, attribute_id, cluster.get, min_value, max_value + ) + for missing_attr in missing_bounds: + log.debug( + "[PAIR] metadata source " + f"{_zb_path(cluster=cluster, attr_id=missing_attr, attr_only=True)} not reported for " + f"{_zb_path(cluster=cluster, attr_id=attribute_id, attr_only=True)} — " + "quirk or unsupported; using wire-type default" ) - if source.startswith("fallback"): - log.warning( - "[PAIR] uncurated attribute " - f"{_zb_path(cluster=cluster, attr_id=attribute_id, attr_only=True)} -> " - f"{visibility.value} ({source}); add to OUR_ATTRIBUTE_UX or refresh the zha harvest" - ) - data_type = self._mapper.parse_zigbee_data_type(attribute.zcl_type) + if issubclass(attribute.type, Enum) and data_type != ParameterDataType.bool: + valid_values = {member.value: member.name for member in attribute.type} + + parameters.append( + ZBParameterState( + id=self._mapper.attribute_parameter_uuid( + device.physical_id, endpoint.endpoint_id, cluster.cluster_id, attribute_id + ), + name=attribute.name, + data_type=data_type, + visibility=visibility, + min_value=min_value, + max_value=max_value, + min_step=min_step, + unit=unit, + valid_values=valid_values, + role=role, + integration_data=ZBParameterIntegrationData( + endpoint_id=endpoint.endpoint_id, + cluster_id=cluster.cluster_id, + attribute_id=attribute_id, + type=ZBParameterType.attribute, + ), + value=value, + ) + ) + for command in cluster.commands: + fields: list[Parameter] = [] + + # Command visibility: system-cluster commands hidden; everyday one-tap + # actions -> user; every other command (schedule/credential/log + # management) -> setting. + if cluster.cluster_id in SYSTEM_CLUSTERS: + visibility = ParameterVisibility.system + elif (cluster.cluster_id, command.id) in EVERYDAY_COMMANDS: + visibility = ParameterVisibility.user + else: + visibility = ParameterVisibility.setting + + for i, field in enumerate(command.schema.fields): min_value = None max_value = None - # Annotated so the untyped-enum comprehension below (member.name is Unknown) - # matches Parameter.valid_values' declared type. valid_values: dict[int | float | str, str] | None = None - min_step = get_min_step(cluster.cluster_id, attribute_id) - # Our spec tables win; the harvested/quirk unit fills gaps get_unit() leaves plain. - unit = get_unit(cluster.cluster_id, attribute_id) - if unit is ParameterUnit.plain and spec.unit is not None: - unit = spec.unit - - if hasattr(attribute.type, "min_value"): - min_value = attribute.type.min_value - if hasattr(attribute.type, "max_value"): - max_value = attribute.type.max_value - - # Metadata priority 1: the device's own limit attributes (runtime values) win - # over the wire-type default. cluster.get returns the cached sibling value. - min_value, max_value, missing_bounds = resolve_metadata_bounds( - cluster.cluster_id, attribute_id, cluster.get, min_value, max_value - ) - for missing_attr in missing_bounds: - log.debug( - "[PAIR] metadata source " - f"{_zb_path(cluster=cluster, attr_id=missing_attr, attr_only=True)} not reported for " - f"{_zb_path(cluster=cluster, attr_id=attribute_id, attr_only=True)} — " - "quirk or unsupported; using wire-type default" - ) - - if issubclass(attribute.type, Enum) and data_type != ParameterDataType.bool: - valid_values = {member.value: member.name for member in attribute.type} - parameters.append( - ZBParameterState( - id=self._mapper.attribute_parameter_uuid( - device.id, endpoint.endpoint_id, cluster.cluster_id, attribute_id + if hasattr(field.type, "min_value"): + min_value = field.type.min_value + if hasattr(field.type, "max_value"): + max_value = field.type.max_value + if isinstance(field.type, type) and issubclass(field.type, Enum): + valid_values = {member.value: member.name for member in field.type} + + fields.append( + Parameter( + id=self._mapper.command_field_uuid( + device.physical_id, endpoint.endpoint_id, cluster.cluster_id, command.id, i ), - name=attribute.name, - data_type=data_type, - visibility=visibility, + name=field.name, + data_type=self._mapper.parse_zigbee_data_type(field.type), + role=ParameterRole.control, + visibility=ParameterVisibility.setting, min_value=min_value, max_value=max_value, - min_step=min_step, - unit=unit, valid_values=valid_values, - role=role, - integration_data=ZBParameterIntegrationData( - endpoint_id=endpoint.endpoint_id, - cluster_id=cluster.cluster_id, - attribute_id=attribute_id, - type=ZBParameterType.attribute, - ), - value=value, + integration_data=None, ) ) - for command in cluster.commands: - fields: list[Parameter] = [] - - # Command visibility: system-cluster commands hidden; everyday one-tap - # actions -> user; every other command (schedule/credential/log - # management) -> setting. - if cluster.cluster_id in SYSTEM_CLUSTERS: - visibility = ParameterVisibility.system - elif (cluster.cluster_id, command.id) in EVERYDAY_COMMANDS: - visibility = ParameterVisibility.user - else: - visibility = ParameterVisibility.setting - - for i, field in enumerate(command.schema.fields): - min_value = None - max_value = None - valid_values: dict[int | float | str, str] | None = None - - if hasattr(field.type, "min_value"): - min_value = field.type.min_value - if hasattr(field.type, "max_value"): - max_value = field.type.max_value - if isinstance(field.type, type) and issubclass(field.type, Enum): - valid_values = {member.value: member.name for member in field.type} - - fields.append( - Parameter( - id=self._mapper.command_field_uuid( - device.id, endpoint.endpoint_id, cluster.cluster_id, command.id, i - ), - name=field.name, - data_type=self._mapper.parse_zigbee_data_type(field.type), - role=ParameterRole.control, - visibility=ParameterVisibility.setting, - min_value=min_value, - max_value=max_value, - valid_values=valid_values, - integration_data=None, - ) - ) - parameters.append( - ZBParameterState( - id=self._mapper.command_parameter_uuid( - device.id, endpoint.endpoint_id, cluster.cluster_id, command.id - ), - name=command.name, - data_type=ParameterDataType.struct if fields else ParameterDataType.none, - role=ParameterRole.control, - fields=json.loads(json.dumps([f.model_dump(mode="json") for f in fields])) - if fields - else None, - visibility=visibility, - integration_data=ZBParameterIntegrationData( - endpoint_id=endpoint.endpoint_id, - cluster_id=cluster.cluster_id, - command_id=command.id, - type=ZBParameterType.command, - ), - value=None, - ) + parameters.append( + ZBParameterState( + id=self._mapper.command_parameter_uuid( + device.physical_id, endpoint.endpoint_id, cluster.cluster_id, command.id + ), + name=command.name, + data_type=ParameterDataType.struct if fields else ParameterDataType.none, + role=ParameterRole.control, + fields=json.loads(json.dumps([f.model_dump(mode="json") for f in fields])) + if fields + else None, + visibility=visibility, + integration_data=ZBParameterIntegrationData( + endpoint_id=endpoint.endpoint_id, + cluster_id=cluster.cluster_id, + command_id=command.id, + type=ZBParameterType.command, + ), + value=None, ) - device.parameters = parameters - main_parameter_id, main_spec = self._get_device_main_parameter(device.id, zbdevice) - device.main_parameter = main_parameter_id - if main_parameter_id and main_spec is not None: - # Attach the one-tap send info to the chosen main parameter; drop the main parameter - # if the target command/attribute wasn't actually exposed. - main_parameter = next((p for p in parameters if p.id == main_parameter_id), None) - if main_parameter is None: - device.main_parameter = None - elif main_spec.is_attribute and main_spec.cycle: - # Attribute main (e.g. fan_mode): a tap cycles through a value subset. Store it - # as the parameter's default_value — the generic, relay-readable cycle source - # (the relay derives the next value via Parameter.main_cycle). A spec with no - # explicit subset leaves the param to cycle its full valid_values, which the - # relay already derives, so there's nothing to set here. - main_parameter.default_value = set(main_spec.cycle) - elif main_spec.default_arguments is not None: - data = main_parameter.integration_data - data.default_arguments = main_spec.default_arguments - # The same arguments keyed by sub-parameter id (the SDK struct value) as a one-value - # button: a `struct` command then passes can_be_main_parameter and the relay sends - # them on a tap. default_arguments stays for devices stored before this. - endpoint = cast(zigpy.endpoint.Endpoint, zbdevice.endpoints[data.endpoint_id]) - zbcommand = endpoint.in_clusters[data.cluster_id].server_commands[main_spec.target_id] - names = self._command_field_names(device.id, data.endpoint_id, data.cluster_id, zbcommand) - ids = {name: field_id for field_id, name in names.items()} - main_parameter.default_value = { - ids.get(name, name): value for name, value in main_spec.default_arguments.items() - } - log.debug( - f"[PAIR] mapped schema {_zb_path(device, zbdevice)}\n\t" - + "\n\t".join( - f" {p.role.value:8} {p.visibility.value:8} {p.data_type.value:10} {p.name} id={p.id}" - for p in parameters - ), - ) - await device_repository.save(device, discovery.id) - await self._subscribe(discovery.id, zbdevice) - # fetch runs in background; controller_did_connect_device fires after fetch completes - self._create_task(self._fetch_after_pair(device, zbdevice)) + ) + device.parameters = parameters + main_parameter_id, main_spec = self._get_device_main_parameter(device.physical_id, zbdevice) + device.main_parameter = main_parameter_id + if main_parameter_id and main_spec is not None: + # Attach the one-tap send info to the chosen main parameter; drop the main parameter + # if the target command/attribute wasn't actually exposed. + main_parameter = next((p for p in parameters if p.id == main_parameter_id), None) + if main_parameter is None: + device.main_parameter = None + elif main_spec.is_attribute and main_spec.cycle: + # Attribute main (e.g. fan_mode): a tap cycles through a value subset. Store it + # as the parameter's default_value — the generic, relay-readable cycle source + # (the relay derives the next value via Parameter.main_cycle). A spec with no + # explicit subset leaves the param to cycle its full valid_values, which the + # relay already derives, so there's nothing to set here. + main_parameter.default_value = set(main_spec.cycle) + elif main_spec.default_arguments is not None: + data = main_parameter.integration_data + data.default_arguments = main_spec.default_arguments + # The same arguments keyed by sub-parameter id (the SDK struct value) as a one-value + # button: a `struct` command then passes can_be_main_parameter and the relay sends + # them on a tap. default_arguments stays for devices stored before this. + endpoint = cast(zigpy.endpoint.Endpoint, zbdevice.endpoints[data.endpoint_id]) + zbcommand = endpoint.in_clusters[data.cluster_id].server_commands[main_spec.target_id] + names = self._command_field_names(device.physical_id, data.endpoint_id, data.cluster_id, zbcommand) + ids = {name: field_id for field_id, name in names.items()} + main_parameter.default_value = { + ids.get(name, name): value for name, value in main_spec.default_arguments.items() + } + log.debug( + f"[PAIR] mapped schema {_zb_path(device, zbdevice)}\n\t" + + "\n\t".join( + f" {p.role.value:8} {p.visibility.value:8} {p.data_type.value:10} {p.name} id={p.id}" + for p in parameters + ), + ) + await self._subscribe(device.physical_id, zbdevice) + # The Hub saves the draft, tells the app the device is connected and then fetches it + device.available = True + self._availability[device.physical_id] = True + return device async def unpair(self, device: ZBDevice): if not self._application: raise self._not_started() + if not device.integration_data.ieee: + return # a record that never got its node log.debug(f"[UNPAIR] ieee={device.integration_data.ieee}") - await self._application.remove(self._mapper.convert_str_to_eui64(device.integration_data.ieee)) - self._connected_devices.pop(self._mapper.device_uuid_from_ieee(device.integration_data.ieee)) + physical_id = self._mapper.device_uuid_from_ieee( + self._mapper.convert_str_to_eui64(device.integration_data.ieee) + ) + try: + # Still offered: the Hub's rollback of an unsaved pairing. The joined node needs no undo and stays the + # discovery the Hub retries from (the unpaired timer removes it if nobody does) + if physical_id not in self._majordom_discoveries: + await self._application.remove(self._mapper.convert_str_to_eui64(device.integration_data.ieee)) + finally: + for cluster, listener in self._subscriptions.pop(physical_id, []): + cluster.remove_listener(listener) + self._connected_devices.pop(physical_id, None) + self._availability.pop(physical_id, None) + if physical_id not in self._majordom_discoveries: + self._awaiting_zb_discoveries.pop(physical_id, None) async def identify(self, device: ZBDevice): if not self._application: @@ -709,50 +728,66 @@ async def fetch(self, device: ZBDevice): if not (zbdevice := self._application.devices.get(ieee)): raise ZBUnexpectedError(f"Device {ieee} not found in ZigBee network") + # The Hub saved it (it fetches only then): paired now, no longer offered + self._connected_devices[device.physical_id] = zbdevice + self._awaiting_zb_discoveries.pop(device.physical_id, None) + self._majordom_discoveries.pop(device.physical_id, None) if not zbdevice.is_initialized: - raise ZBUnexpectedError(f"Device {ieee} is not initialized") + log.debug(f"[FETCH] device={device.physical_id} is still being interviewed, skipping") + return + if not self._is_subscribed( + device.physical_id, zbdevice + ): # zigpy rebuilt its clusters (a re-interview, a quirk) + await self._subscribe(device.physical_id, zbdevice) events: list[DeviceParameterChange] = list() - log.debug(f"[FETCH] start device={device.id}({zbdevice.model})") + log.debug(f"[FETCH] start device={device.physical_id}({zbdevice.model})") t0 = asyncio.get_event_loop().time() - for endpoint in zbdevice.non_zdo_endpoints: - for cluster_id, cluster in endpoint.in_clusters.items(): - attr_values = await self._read_cluster_attributes( - device, - zbdevice, - endpoint, - cluster, - self._readable_attribute_ids(cluster), - log_prefix="[FETCH]", - timeout=2, - ) - if self._is_unimplemented(cluster): - continue # pairing exposed no parameters for it - - for attribute_id in cluster.attributes: - if cluster.is_attribute_unsupported(attribute_id): - continue - events.append( - DeviceParameterChange( - device_id=device.id, - parameter_id=self._mapper.attribute_parameter_uuid( - device.id, endpoint.endpoint_id, cluster_id, attribute_id - ), - value=self._mapper.normalize_zigbee_value(attr_values.get(attribute_id)), - ) - ) - for command in cluster.commands: - events.append( - DeviceParameterChange( - device_id=device.id, - parameter_id=self._mapper.command_parameter_uuid( - device.id, endpoint.endpoint_id, cluster_id, command.id - ), - value=None, + try: + async with asyncio.timeout(_FETCH_TIMEOUT): + for endpoint in zbdevice.non_zdo_endpoints: + for cluster_id, cluster in endpoint.in_clusters.items(): + attr_values = await self._read_cluster_attributes( + device, + zbdevice, + endpoint, + cluster, + self._readable_attribute_ids(cluster), + log_prefix="[FETCH]", + timeout=2, ) - ) + if self._is_unimplemented(cluster): + continue # pairing exposed no parameters for it + + for attribute_id in cluster.attributes: + if cluster.is_attribute_unsupported(attribute_id) or attribute_id not in attr_values: + continue # unanswered: the device keeps its last known value + events.append( + DeviceParameterChange( + physical_id=device.physical_id, + parameter_id=self._mapper.attribute_parameter_uuid( + device.physical_id, endpoint.endpoint_id, cluster_id, attribute_id + ), + value=self._mapper.normalize_zigbee_value(attr_values[attribute_id]), + ) + ) + for command in cluster.commands: + events.append( + DeviceParameterChange( + physical_id=device.physical_id, + parameter_id=self._mapper.command_parameter_uuid( + device.physical_id, endpoint.endpoint_id, cluster_id, command.id + ), + value=None, + ) + ) + except TimeoutError: + log.warning( + f"[FETCH] device={device.physical_id}({zbdevice.model}) took over {_FETCH_TIMEOUT}s, " + "reporting what it answered" + ) duration = asyncio.get_event_loop().time() - t0 - log.debug(f"[FETCH] done device={device.id}({zbdevice.model}) duration={duration:.2f}s") + log.debug(f"[FETCH] done device={device.physical_id}({zbdevice.model}) duration={duration:.2f}s") await self.output.controller_did_receive_events(self, events) async def send_command(self, command: DeviceCommand, device: ZBDevice, parameter: ZBParameter): @@ -810,7 +845,10 @@ async def send_command(self, command: DeviceCommand, device: ZBDevice, parameter # A struct value is keyed by sub-parameter id (SDK), zigpy takes field names. Name # keys (e.g. default_arguments) pass through as-is. names = self._command_field_names( - device.id, parameter.integration_data.endpoint_id, parameter.integration_data.cluster_id, zbcommand + device.physical_id, + parameter.integration_data.endpoint_id, + parameter.integration_data.cluster_id, + zbcommand, ) arguments = {names.get(str(key), str(key)): value for key, value in arguments.items()} try: @@ -849,8 +887,8 @@ async def _reconnect(self): async with self._radio_lock: if time.monotonic() - self._opened_at >= self.STABLE_RUN: self._reopens = 0 - for device_id in list(self._connected_devices): # unreachable until the radio is back - await self._set_availability(device_id, False) + for physical_id in list(self._connected_devices): # unreachable until the radio is back + await self._set_availability(physical_id, False) lost = list(self._majordom_discoveries) await self._close() for discovery_id in lost: @@ -874,12 +912,12 @@ async def _reconnect(self): def device_joined(self, device: ZPDevice): """A device joined the Zigbee network (only happens while the permit-join window is open).""" log.debug(f"[JOIN] ieee={device.ieee} nwk=0x{device.nwk:04X}") - device_id = self._mapper.device_uuid_from_ieee(self._mapper.convert_eui64_to_str(device.ieee)) + physical_id = self._mapper.device_uuid_from_ieee(device.ieee) # Zigbee has no separate "discovery": a device is on the network as soon as it joins. # We hold it in the awaiting list and disconnect it if it isn't paired in majordom within # the window (see _disconnect_unpaired_discovery). An already-paired device that merely # rejoined is handled in device_initialized, not here. - self._create_task(self._disconnect_unpaired_discovery(device_id, device.ieee)) + self._create_task(self._disconnect_unpaired_discovery(physical_id, device.ieee)) def device_initialized(self, device: ZPDevice): """A device finished interviewing and is ready to talk. Fires both for a brand-new join @@ -888,25 +926,25 @@ def device_initialized(self, device: ZPDevice): f"[INIT] ieee={device.ieee} nwk=0x{device.nwk:04X} " f"model={device.model!r} manufacturer={device.manufacturer!r}" ) - device_id = self._mapper.device_uuid_from_ieee(self._mapper.convert_eui64_to_str(device.ieee)) + physical_id = self._mapper.device_uuid_from_ieee(device.ieee) # Already paired in majordom -> a mid-session reconnect: re-subscribe and mark it back # online instead of surfacing it as a fresh discovery. - if device_id in self._connected_devices: - self._connected_devices[device_id] = device - self._create_task(self._subscribe(device_id, device)) - self._create_task(self._set_availability(device_id, True)) + if physical_id in self._connected_devices: + self._connected_devices[physical_id] = device + self._create_task(self._subscribe(physical_id, device)) + self._create_task(self._set_availability(physical_id, True)) return # Awaiting pairing and re-initialized -> just (re)subscribe. - if device_id in self.discoveries: - self._awaiting_zb_discoveries[device_id] = device - self._create_task(self._subscribe(device_id, device)) + if physical_id in self.discoveries: + self._awaiting_zb_discoveries[physical_id] = device + self._create_task(self._subscribe(physical_id, device)) return # Otherwise it's a new, not-yet-paired device -> surface it as a discovery. discovery = Discovery( - id=device_id, + id=physical_id, integration=NonEmptyStr(self.key), expected_credentials_options=[CredentialsType.none], expiration=None, @@ -916,50 +954,40 @@ def device_initialized(self, device: ZPDevice): device_category=None, device_icon=None, ) - self._majordom_discoveries[device_id] = discovery - self._awaiting_zb_discoveries[device_id] = device - log.debug(f"[DISCOVERY] ieee={device.ieee} discovery_id={device_id}") + self._majordom_discoveries[physical_id] = discovery + self._awaiting_zb_discoveries[physical_id] = device + log.debug(f"[DISCOVERY] ieee={device.ieee} discovery_id={physical_id}") self._create_task(self.output.controller_did_receive_discovery(self, discovery)) def device_left(self, device: ZPDevice): """A device left the Zigbee network. If it's one of ours, mark it unavailable so the app reflects it; the pairing stays in the DB so it comes back online on rejoin.""" log.debug(f"[LEFT] ieee={device.ieee} nwk=0x{device.nwk:04X}") - device_id = self._mapper.device_uuid_from_ieee(self._mapper.convert_eui64_to_str(device.ieee)) - if device_id in self._connected_devices: - self._create_task(self._set_availability(device_id, False)) + physical_id = self._mapper.device_uuid_from_ieee(device.ieee) + if physical_id in self._connected_devices: + self._create_task(self._set_availability(physical_id, False)) def handle_message(self, device: ZPDevice, *_): """Any message from a device: one held unavailable is back.""" - device_id = self._mapper.device_uuid_from_ieee(self._mapper.convert_eui64_to_str(device.ieee)) - if self._availability.get(device_id) is False and device_id in self._connected_devices: - self._create_task(self._set_availability(device_id, True)) + physical_id = self._mapper.device_uuid_from_ieee(device.ieee) + if self._availability.get(physical_id) is False and physical_id in self._connected_devices: + self._create_task(self._set_availability(physical_id, True)) - async def _set_availability(self, device_id: UUID, available: bool): + async def _set_availability(self, physical_id: UUID, available: bool): """Single funnel for availability transitions — dedupes so the Hub is only told on an actual change, and translates it into the framework's connect / lose callbacks.""" - if self._availability.get(device_id) == available: + if self._availability.get(physical_id) == available: return - self._availability[device_id] = available + self._availability[physical_id] = available if available: - await self.output.controller_did_connect_device(self, device_id) + await self.output.controller_did_connect_device(self, physical_id=physical_id) else: - await self.output.controller_did_lose_device(self, device_id) + await self.output.controller_did_lose_device(self, physical_id=physical_id) # ------------------------------------------------------------------------- # Private helpers # ------------------------------------------------------------------------- - async def _fetch_after_pair(self, device: ZBDevice, zbdevice: ZPDevice): - log.debug(f"[PAIR] starting background fetch device={device.id}({zbdevice.model})") - try: - await self.fetch(device) - except Exception as e: - log.warning(f"[PAIR] fetch failed for device={device.id}({zbdevice.model}), skipping connect signal: {e}") - return - await self._set_availability(device.id, True) - log.debug(f"[PAIR] background fetch done, device connected device={device.id}({zbdevice.model})") - async def _read_cluster_attributes( self, device: ZBDevice, @@ -1032,14 +1060,20 @@ def _create_task[T](self, coro: Coroutine[Any, Any, T]) -> asyncio.Task[T]: task.add_done_callback(_log_task_exception) return task - async def _subscribe(self, device_id: UUID, device: ZPDevice): + def _is_subscribed(self, physical_id: UUID, device: ZPDevice) -> bool: + subscribed = {id(cluster) for cluster, _ in self._subscriptions.get(physical_id, [])} + return subscribed == { + id(cluster) for endpoint in device.non_zdo_endpoints for cluster in endpoint.in_clusters.values() + } + + async def _subscribe(self, physical_id: UUID, device: ZPDevice): """Listens to the device's attribute reports, once: a rejoin keeps a plain device's clusters.""" - for cluster, listener in self._subscriptions.pop(device_id, []): + for cluster, listener in self._subscriptions.pop(physical_id, []): cluster.remove_listener(listener) - subscriptions = self._subscriptions[device_id] = [] + subscriptions = self._subscriptions[physical_id] = [] for endpoint in device.non_zdo_endpoints: for cluster in endpoint.in_clusters.values(): - listener = ZBAttributeUpdatedListener(self, device_id, cluster) + listener = ZBAttributeUpdatedListener(self, physical_id, cluster) cluster.add_listener(listener) subscriptions.append((cluster, listener)) @@ -1056,17 +1090,17 @@ async def _disconnect_unpaired_discovery(self, discovery_id: UUID, ieee: EUI64): await self.output.controller_did_lose_discovery(self, discovery_id) def _command_field_names( - self, device_id: UUID, endpoint_id: int, cluster_id: int, zbcommand: ZCLCommandDef + self, physical_id: UUID, endpoint_id: int, cluster_id: int, zbcommand: ZCLCommandDef ) -> dict[str, str]: """Sub-parameter id (as str) -> zigpy field name, for a command parameter's fields.""" fields = enumerate(zbcommand.schema.fields) return { - str(self._mapper.command_field_uuid(device_id, endpoint_id, cluster_id, zbcommand.id, i)): field.name + str(self._mapper.command_field_uuid(physical_id, endpoint_id, cluster_id, zbcommand.id, i)): field.name for i, field in fields } def _get_device_main_parameter( - self, device_id: UUID, zbdevice: ZPDevice + self, physical_id: UUID, zbdevice: ZPDevice ) -> tuple[UUID | None, MainParameterSpec | None]: """Pick the parameter used for the device's one-tap action on the room view, in cluster priority order (see MAIN_PARAMETER_BY_CLUSTER). Returns the parameter id and its spec @@ -1076,11 +1110,11 @@ def _get_device_main_parameter( if endpoint.in_clusters.get(cluster_id): if spec.is_attribute: param_id = self._mapper.attribute_parameter_uuid( - device_id, endpoint.endpoint_id, cluster_id, spec.target_id + physical_id, endpoint.endpoint_id, cluster_id, spec.target_id ) else: param_id = self._mapper.command_parameter_uuid( - device_id, endpoint.endpoint_id, cluster_id, spec.target_id + physical_id, endpoint.endpoint_id, cluster_id, spec.target_id ) return param_id, spec return None, None diff --git a/majordom_zigbee/listener.py b/majordom_zigbee/listener.py index 7b20aa0..5a25162 100644 --- a/majordom_zigbee/listener.py +++ b/majordom_zigbee/listener.py @@ -5,19 +5,19 @@ class ZBAttributeUpdatedListener: - def __init__(self, controller, device_id: UUID, cluster: Cluster): + def __init__(self, controller, physical_id: UUID, cluster: Cluster): self._controller = controller - self._device_id = device_id + self._physical_id = physical_id self._cluster = cluster def attribute_updated(self, attribute_id, value, time): cluster = self._cluster endpoint_id = cluster.endpoint.endpoint_id parameter_id = self._controller._mapper.attribute_parameter_uuid( - self._device_id, endpoint_id, cluster.cluster_id, attribute_id + self._physical_id, endpoint_id, cluster.cluster_id, attribute_id ) event = DeviceParameterChange( - device_id=self._device_id, + physical_id=self._physical_id, parameter_id=parameter_id, value=self._controller._mapper.normalize_zigbee_value(value), ) diff --git a/majordom_zigbee/mapper.py b/majordom_zigbee/mapper.py index 78593b2..9f7e4b3 100644 --- a/majordom_zigbee/mapper.py +++ b/majordom_zigbee/mapper.py @@ -13,7 +13,7 @@ class ZigBeeMapper: def __init__( self, - device_uuid: Callable[[str], UUID], + device_uuid: Callable[[bytes], UUID], parameter_uuid: Callable[[UUID, str], UUID], ): # The controller's framework UUID generators (see AbstractController). Every Zigbee @@ -27,12 +27,8 @@ def __init__( # Identity: Zigbee addresses/paths -> MajorDom UUIDs # ------------------------------------------------------------------------- - def device_uuid_from_ieee(self, ieee: str | None) -> UUID: - # ieee is Optional on the domain model, but a paired Zigbee device always has one; a - # missing address here means a corrupt/half-written record, not a normal path. - if ieee is None: - raise ZBUnexpectedError("Zigbee device is missing its IEEE address") - return self._device_uuid(ieee) + def device_uuid_from_ieee(self, ieee: EUI64) -> UUID: + return self._device_uuid(bytes(ieee.serialize())) def normalize_zigbee_value(self, value): """Coerce zigpy wire values to plain python types for the SDK's typed encoder. @@ -56,16 +52,16 @@ def normalize_zigbee_value(self, value): return str(value) return value - def attribute_parameter_uuid(self, device_id: UUID, endpoint_id: int, cluster_id: int, attribute_id: int) -> UUID: - return self._parameter_uuid(device_id, f"attribute_{endpoint_id}/{cluster_id}/{attribute_id}") + def attribute_parameter_uuid(self, physical_id: UUID, endpoint_id: int, cluster_id: int, attribute_id: int) -> UUID: + return self._parameter_uuid(physical_id, f"attribute_{endpoint_id}/{cluster_id}/{attribute_id}") - def command_parameter_uuid(self, device_id: UUID, endpoint_id: int, cluster_id: int, command_id: int) -> UUID: - return self._parameter_uuid(device_id, f"command_{endpoint_id}/{cluster_id}/{command_id}") + def command_parameter_uuid(self, physical_id: UUID, endpoint_id: int, cluster_id: int, command_id: int) -> UUID: + return self._parameter_uuid(physical_id, f"command_{endpoint_id}/{cluster_id}/{command_id}") def command_field_uuid( - self, device_id: UUID, endpoint_id: int, cluster_id: int, command_id: int, field_index: int + self, physical_id: UUID, endpoint_id: int, cluster_id: int, command_id: int, field_index: int ) -> UUID: - return self._parameter_uuid(device_id, f"field_{endpoint_id}/{cluster_id}/{command_id}/{field_index}") + return self._parameter_uuid(physical_id, f"field_{endpoint_id}/{cluster_id}/{command_id}/{field_index}") # ------------------------------------------------------------------------- # Value / type conversions diff --git a/poetry.lock b/poetry.lock index 930ad46..30a0689 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1263,24 +1263,24 @@ dev = ["Sphinx (>=5.0.2)", "doc8 (>=0.11.2)", "pytest (>=7.0.1)", "pytest-xdist [[package]] name = "majordom-integration-sdk" -version = "0.3.0" +version = "0.4.0" description = "Models, protocols, tooling and the runtime for building and running MajorDom integrations." optional = false -python-versions = ">=3.13" +python-versions = "<4.0,>=3.13" groups = ["main"] files = [ - {file = "majordom_integration_sdk-0.3.0-py3-none-any.whl", hash = "sha256:c27bc916845c82b51498dad77e5fe6e93e69f193842856bcec24b23639a2bebd"}, - {file = "majordom_integration_sdk-0.3.0.tar.gz", hash = "sha256:1a188d365debc63aec21e83f331fc98f0ca8d6c56c4a839c88b2219801eeb27a"}, + {file = "majordom_integration_sdk-0.4.0-py3-none-any.whl", hash = "sha256:aed8ae19e22f93f2db50888e4bcc636aed1bc6c315be93b76107fb15e6480403"}, + {file = "majordom_integration_sdk-0.4.0.tar.gz", hash = "sha256:3fe3f504550e57b328ba21d466340d788ce90cabddbfc65f3214e94453391c8c"}, ] [package.dependencies] -pydantic = ">=2.14.1,<3.0" +pydantic = ">=2.14.3,<3.0" python-slugify = "*" [package.extras] ble = ["bleak (>=0.22)", "dbus-fast (>=2.0) ; sys_platform == \"linux\""] cli = ["rich (>=13)", "typer-shell (>=0.2)"] -discovery = ["zeroconf (>=0.151.5)"] +discovery = ["zeroconf (>=0.153.0)"] runtime = ["pyserial (>=3.5)"] [[package]] @@ -1964,19 +1964,19 @@ files = [ [[package]] name = "pydantic" -version = "2.14.2" +version = "2.14.3" description = "Data validation using Python type hints" optional = false python-versions = ">=3.10" groups = ["main"] files = [ - {file = "pydantic-2.14.2-py3-none-any.whl", hash = "sha256:7efbf7507b937931cd32a5755acb00ea1cf5ccb1d4e8067a5850d5069e382118"}, - {file = "pydantic-2.14.2.tar.gz", hash = "sha256:fb7b2db6cefe8414dd612edeede49c4c433acb0432b0f92b95024e45f66c505d"}, + {file = "pydantic-2.14.3-py3-none-any.whl", hash = "sha256:3f7b347782ab7e4cf4c798496ae3a82787d9f21ec12676a9c564355eeef8daa8"}, + {file = "pydantic-2.14.3.tar.gz", hash = "sha256:1054f237f4d4733e5a30e1e2333bd33a2004ab9ab1510bd053a9a31bb48e232d"}, ] [package.dependencies] annotated-types = ">=0.6.0" -pydantic-core = "2.50.2" +pydantic-core = "2.50.4" typing-extensions = ">=4.16.0" typing-inspection = ">=0.4.4" @@ -1986,153 +1986,152 @@ timezone = ["tzdata ; platform_system == \"Windows\""] [[package]] name = "pydantic-core" -version = "2.50.2" +version = "2.50.4" description = "Core functionality for Pydantic validation and serialization" optional = false python-versions = ">=3.10" groups = ["main"] files = [ - {file = "pydantic_core-2.50.2-cp310-cp310-macosx_10_12_x86_64.whl", hash = "sha256:6258754c473b3045a7aa30b833a8a331a1ab36c6147cb230789861d80bb26f83"}, - {file = "pydantic_core-2.50.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:a786cf782ebb2e45a43c7118d75d452aac982b79577dfe804d8dbf2878f0b589"}, - {file = "pydantic_core-2.50.2-cp310-cp310-manylinux1_i686.manylinux_2_5_i686.whl", hash = "sha256:ea71b94a2eb5d2fc102926321f56d2ee8eddfad2673eadb1d23e9f287a492715"}, - {file = "pydantic_core-2.50.2-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:71615edeaf1ae70f5f3f558426072eede0168b7e5190fd9633878e29a0b85732"}, - {file = "pydantic_core-2.50.2-cp310-cp310-manylinux2014_armv7l.manylinux_2_17_armv7l.whl", hash = "sha256:1a5e859f5a8a6d834b0a13acaa0eaddf1a9b4b015fcda13bab7b471e18299d32"}, - {file = "pydantic_core-2.50.2-cp310-cp310-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:d71a9a9352acbcb5c73d39dd003383599428067b6eda5cf7c5d335a7a0da37e1"}, - {file = "pydantic_core-2.50.2-cp310-cp310-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:bf7f99a0e6616cea754e2334d129091f3260d011369d9b8c658522bfb2427619"}, - {file = "pydantic_core-2.50.2-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:5c12a5a080570a91bbcbf6d10db008b80e3f5dea015ef2f0137bbec70f24f3f3"}, - {file = "pydantic_core-2.50.2-cp310-cp310-manylinux_2_31_riscv64.whl", hash = "sha256:89213368eef163350af37127939ace099010e8102757905c3e329f1175950ed8"}, - {file = "pydantic_core-2.50.2-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:d93c066a38f83376b5bc020e563666784d1b680a70d6ceb625fdb541af7a312e"}, - {file = "pydantic_core-2.50.2-cp310-cp310-musllinux_1_1_armv7l.whl", hash = "sha256:eec187d2876abb6a74203efbe2aa796455c1809334acf4e739dde35da8cfb69f"}, - {file = "pydantic_core-2.50.2-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:701bc55d08c22f981973ca4f6fdf4ea102ee1ee3a21b818b66fdb161ea711a4a"}, - {file = "pydantic_core-2.50.2-cp310-cp310-win32.whl", hash = "sha256:7f9821dfc0c473c96ad55ce4189c7cb4f9c94e7d4f563afb874173243dec1162"}, - {file = "pydantic_core-2.50.2-cp310-cp310-win_amd64.whl", hash = "sha256:3939538e640c94ab779a05f2d45dafedd01d65d93e1290797f3ac5b59fcb6455"}, - {file = "pydantic_core-2.50.2-cp311-cp311-macosx_10_12_x86_64.whl", hash = "sha256:2115d7ca6d58554af8a14da3dd32d361a4fe999fae52f115a6155679b5b00e72"}, - {file = "pydantic_core-2.50.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:b2dd65864aad38dbcc57c3d0e2c978d4286e063378137d8fc0c9fcd558943285"}, - {file = "pydantic_core-2.50.2-cp311-cp311-manylinux1_i686.manylinux_2_5_i686.whl", hash = "sha256:26b778d4ebb75f181d36220ff0f54a513fc46f053d9b09ce79993c2f00bc45cc"}, - {file = "pydantic_core-2.50.2-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:e80c47314c7233e7105a7efcfffd89d56e479e558189d1959eeeaf2639a27680"}, - {file = "pydantic_core-2.50.2-cp311-cp311-manylinux2014_armv7l.manylinux_2_17_armv7l.whl", hash = "sha256:3bfe12243b3ded517c6734d91f127489e2f51bf95cb533b53130fe360333db80"}, - {file = "pydantic_core-2.50.2-cp311-cp311-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:01eb0282d0b3a065d55956d1be9ce398c46db3dd6d277a6cb2358c8aa8c53179"}, - {file = "pydantic_core-2.50.2-cp311-cp311-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:196b87b48b2695426920e8470d20f9e99f019ebd86f15808aa018b68086840cd"}, - {file = "pydantic_core-2.50.2-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:86e7abd24a67f61a4bfe8df059b67a2bdd8bf33705178e98463195d140bd3780"}, - {file = "pydantic_core-2.50.2-cp311-cp311-manylinux_2_31_riscv64.whl", hash = "sha256:aff31602e8518594e6f6bc670cdb27e37cb7dbeb2d5d0b76a7707b70fe951ddf"}, - {file = "pydantic_core-2.50.2-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:a88851e8e332588cb8cced8b5318d1163c7d0bb87830aa8dcafbc4ae9602b73c"}, - {file = "pydantic_core-2.50.2-cp311-cp311-musllinux_1_1_armv7l.whl", hash = "sha256:3b1bb3950e0794a795c9344d818d5b476189b0c9c9755e8eb8fde87c3acee17a"}, - {file = "pydantic_core-2.50.2-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:928a44ad1e21a7e923eb924d601605f0694cd187d2ce5d40bf7ad76650f4627d"}, - {file = "pydantic_core-2.50.2-cp311-cp311-win32.whl", hash = "sha256:9a87744e683d9a13f60b7fa5242c17f8d283ffa94ad727cb19063b48c3d34960"}, - {file = "pydantic_core-2.50.2-cp311-cp311-win_amd64.whl", hash = "sha256:b958c217c6e56bef261f516e4caf5d490b079ad6a428752afada5a764cca6c71"}, - {file = "pydantic_core-2.50.2-cp311-cp311-win_arm64.whl", hash = "sha256:b0e6a2152706d84f7da8b9d34dcecc7e9bde678af32c40bd5b405f427ae0fbdb"}, - {file = "pydantic_core-2.50.2-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:e3d824b6152e1c0fd58dc6266f2de470eb7b2286135294f5f7cd26a0f0693738"}, - {file = "pydantic_core-2.50.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:596921489390a002d6a5e303384a0f1f98384f8bb550fbf38a1aafa6093da0f9"}, - {file = "pydantic_core-2.50.2-cp312-cp312-manylinux1_i686.manylinux_2_5_i686.whl", hash = "sha256:36d8b9725684ca3bf658b90a101d335fc8cae405bb22196b7b5ef41344913756"}, - {file = "pydantic_core-2.50.2-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:43a8fd56f3c681f3cda2d5c842ad28e88241df742dfcbe8fd1dd437a3056e1f6"}, - {file = "pydantic_core-2.50.2-cp312-cp312-manylinux2014_armv7l.manylinux_2_17_armv7l.whl", hash = "sha256:6f5a432c6c1ef18a1a02a04b3616b8d3f2f88b13faa46caae1ac6559ab202234"}, - {file = "pydantic_core-2.50.2-cp312-cp312-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:5d3cd8be71c4da3c9b42cc92f17e5e3036bdca98bf18555a0e072c3fe87abbb4"}, - {file = "pydantic_core-2.50.2-cp312-cp312-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:6a438cb8a3f87f2c49e82e43fb19511d4d5043f53e0787dc4df937ccb904373a"}, - {file = "pydantic_core-2.50.2-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:9667637665acba166a7dbbc786f14c50512d3a01f7199e0e1a13b929e92d7c7a"}, - {file = "pydantic_core-2.50.2-cp312-cp312-manylinux_2_31_riscv64.whl", hash = "sha256:b3e681208e2d39fde13fbea449ef2736a85ec1ea2afa41e9193a8c536e71dafe"}, - {file = "pydantic_core-2.50.2-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:6eb6ff07964f39e33c6f57fefe939514e76b8c0d4a694e5663e2e04e80cc1798"}, - {file = "pydantic_core-2.50.2-cp312-cp312-musllinux_1_1_armv7l.whl", hash = "sha256:4eb54c25e3463d73e1e4ed439ffc45d1d7e590df40bc7bb06f11a906afd996c3"}, - {file = "pydantic_core-2.50.2-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:91238117cd296352f54f24117ff5a227bdea428865dba1244aa0cdd1424c0bc2"}, - {file = "pydantic_core-2.50.2-cp312-cp312-win32.whl", hash = "sha256:98722314e12a8e4fa346e0afd3fff2098b5732875ff45592b450a7b589b43c4f"}, - {file = "pydantic_core-2.50.2-cp312-cp312-win_amd64.whl", hash = "sha256:b381574614245f18fdb2d6d1aa8f149e225869c47b5ee7f81812de8977817314"}, - {file = "pydantic_core-2.50.2-cp312-cp312-win_arm64.whl", hash = "sha256:f07c965a8aa6d62145f122641f292129984f39a3e3697585b19298a1488287db"}, - {file = "pydantic_core-2.50.2-cp313-cp313-macosx_10_12_x86_64.whl", hash = "sha256:93eb41d626d9a2749a678823c70bba8c25033cef474ae8001fd7621adbbd8437"}, - {file = "pydantic_core-2.50.2-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:7c539d452cba22f250103c7d1c00cbe9038eb705e657476e701c43374efd9f2e"}, - {file = "pydantic_core-2.50.2-cp313-cp313-manylinux1_i686.manylinux_2_5_i686.whl", hash = "sha256:53bd25e8ab54c02bb4c55d4848c1d36f75f3b9a7356e83179fe27794d9e9e6c4"}, - {file = "pydantic_core-2.50.2-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:f142cd663d1148ed32993ed9a58e5c67ea312f446a01a6c13a956945aafc9f23"}, - {file = "pydantic_core-2.50.2-cp313-cp313-manylinux2014_armv7l.manylinux_2_17_armv7l.whl", hash = "sha256:126f158474346f457c0759c29c1a6334acd5f7f99dd272bb27d19314f3d81b4d"}, - {file = "pydantic_core-2.50.2-cp313-cp313-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:0b94a515f44f1ebcb25395bcdba506c4cdaf6d3fcb0466b9658521b41e5ff057"}, - {file = "pydantic_core-2.50.2-cp313-cp313-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:a55c1163e829a08707b4a92c8ee02a5a3a3847ced74aa4da94e3e975ffe1ec63"}, - {file = "pydantic_core-2.50.2-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:31a1fb3ffbd1195b24490f671d12623dd4c9bfa56d6af0a299fa43b516134f5b"}, - {file = "pydantic_core-2.50.2-cp313-cp313-manylinux_2_31_riscv64.whl", hash = "sha256:83d6f42ae6eba44548a1a3d4f900a5b1500fdd14f09f04754a8800ab0d544432"}, - {file = "pydantic_core-2.50.2-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:9fcde11462e0faab4c2a2ae8cd4516f7dd8239eec583bd88c5524d8064ad2d0c"}, - {file = "pydantic_core-2.50.2-cp313-cp313-musllinux_1_1_armv7l.whl", hash = "sha256:848984e231190ae49bc8b5229e64d2a6fba4231dc6046e1b6b28ddc060bc7601"}, - {file = "pydantic_core-2.50.2-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:8772c2c0091e6fc2d0499151793d31bf811826986b0727052935a95104845544"}, - {file = "pydantic_core-2.50.2-cp313-cp313-win32.whl", hash = "sha256:bd6ecae08c0d871cf93b6f0d4ee76b06c65be44ea22311981a022b2f1948cf9d"}, - {file = "pydantic_core-2.50.2-cp313-cp313-win_amd64.whl", hash = "sha256:e5c801bdf3cc92274b8fc2c7023c8751e5ae81260c009ac558ff55ce712a2d45"}, - {file = "pydantic_core-2.50.2-cp313-cp313-win_arm64.whl", hash = "sha256:fd9aa71a800c87c0f7ab53fa38009169a23a82c685989626ca74a4bd483e1b67"}, - {file = "pydantic_core-2.50.2-cp314-cp314-macosx_10_12_x86_64.whl", hash = "sha256:efad0bdc67d3b119c3bab6b94d341a27333c2bb89ed75dfa182a4a06cd0ea329"}, - {file = "pydantic_core-2.50.2-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:6ffb4dce3ecb2cd563aa30f9eb5088a1cf1f4f688b90cbb374fa96e49fc50b02"}, - {file = "pydantic_core-2.50.2-cp314-cp314-manylinux1_i686.manylinux_2_5_i686.whl", hash = "sha256:150f6e101f575c21a4ecfed1be1c05bb89a0ad49cb9c846ed377583bd71b32c2"}, - {file = "pydantic_core-2.50.2-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:1db9cab6197e797824f0479dd2ae5fd2e272aa61c61b7faa5a6e450ca7a0d3b7"}, - {file = "pydantic_core-2.50.2-cp314-cp314-manylinux2014_armv7l.manylinux_2_17_armv7l.whl", hash = "sha256:1b9f652e17a13bbc09b45f74c3c326cca72059ce4dcdef687fcb04389db413a9"}, - {file = "pydantic_core-2.50.2-cp314-cp314-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:823b222c4fc861a82c650998a6117ecbd150cc71bf8b78f9a31bf3f48c456108"}, - {file = "pydantic_core-2.50.2-cp314-cp314-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:783abdfac21247d33bec40aa683d26bba30d61655c40de38b2decc4797aabf92"}, - {file = "pydantic_core-2.50.2-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:b29b7c5adf4b2be7c941f7f76432aa3269cd5052ff8610376b8ece24d7b02c51"}, - {file = "pydantic_core-2.50.2-cp314-cp314-manylinux_2_31_riscv64.whl", hash = "sha256:4ac996e42a93d80122a23edce44e02c6b9c4913f5c6198a077da31475341a39a"}, - {file = "pydantic_core-2.50.2-cp314-cp314-musllinux_1_1_aarch64.whl", hash = "sha256:99e1d482138a71902415ba375bb4627679a5fefd3bd07803c3a8f37632f4981d"}, - {file = "pydantic_core-2.50.2-cp314-cp314-musllinux_1_1_armv7l.whl", hash = "sha256:a53d5f11cd6d15569ba3e53f3498077f0d5e633f6ec604d2ea613e895017ebee"}, - {file = "pydantic_core-2.50.2-cp314-cp314-musllinux_1_1_x86_64.whl", hash = "sha256:23385c4626f8b5a7792aa381ea573d9432cfbf4c21375a0a5eed2a4fb64e0e58"}, - {file = "pydantic_core-2.50.2-cp314-cp314-pyemscripten_2026_0_wasm32.whl", hash = "sha256:9a8a62281fd9c6a373b3fd3d473685e6838d43341eecde5f47729748e2c11ee3"}, - {file = "pydantic_core-2.50.2-cp314-cp314-win32.whl", hash = "sha256:18f008ef58cd30782f81b6e0119e20b7e884edcefbc2d370162ebe033f6e5c99"}, - {file = "pydantic_core-2.50.2-cp314-cp314-win_amd64.whl", hash = "sha256:b62c89545d21d930c333208fd548e7b4f262228ba3a322fd75c987a75ab11f31"}, - {file = "pydantic_core-2.50.2-cp314-cp314-win_arm64.whl", hash = "sha256:6e731bf5a5e8e25398544d7709e39068ec4230b0177e4db7fa955692fd415ba3"}, - {file = "pydantic_core-2.50.2-cp314-cp314t-macosx_10_12_x86_64.whl", hash = "sha256:33c6800ab9563adaa0d7893e9cd8f5b972ef1e6a23df70498e05c24f3fcec5e1"}, - {file = "pydantic_core-2.50.2-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:f81df206b937d0dca5efb38c25fc99037d82dbcd3740e34c3f81997d2322ac1c"}, - {file = "pydantic_core-2.50.2-cp314-cp314t-manylinux1_i686.manylinux_2_5_i686.whl", hash = "sha256:21ea3b00f1e87c66f3f9e92f9f6fec20495ac0e60d7d2e68ba1fc49739d7cf40"}, - {file = "pydantic_core-2.50.2-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:9eff570402175c7d5fff8497d5a9c05580664a79bb66c07b8f205d17f69e580b"}, - {file = "pydantic_core-2.50.2-cp314-cp314t-manylinux2014_armv7l.manylinux_2_17_armv7l.whl", hash = "sha256:240fec32a74af0979f7253532859b3fd209ad5eea822416bb010929dba445c3d"}, - {file = "pydantic_core-2.50.2-cp314-cp314t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:92acf02c770b9d5c4e9a3e8d64e9d95ae26456a86ebb7b7cf64a97f899e5871b"}, - {file = "pydantic_core-2.50.2-cp314-cp314t-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:1ac5b99bc7b0a68ec64f5f75a6828a7bab5535c8df0cdc07901deb50e0815910"}, - {file = "pydantic_core-2.50.2-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:713d7c33c0e231e3786eb0ec95885814dd65d5f3a09754399b6acbf5e9365f11"}, - {file = "pydantic_core-2.50.2-cp314-cp314t-manylinux_2_31_riscv64.whl", hash = "sha256:61e13100b30d8d25fc0d1f0297014b32941bf0975a3584bd08f3adebb68d1ead"}, - {file = "pydantic_core-2.50.2-cp314-cp314t-musllinux_1_1_aarch64.whl", hash = "sha256:523fe6574aea50f456cbc301c1cdddcbf237939f7657f9af99b4f0f71942b59c"}, - {file = "pydantic_core-2.50.2-cp314-cp314t-musllinux_1_1_armv7l.whl", hash = "sha256:6c25b8826be85714b27dafe908d3461e1b09e3e31c0279a7029040c832c781ef"}, - {file = "pydantic_core-2.50.2-cp314-cp314t-musllinux_1_1_x86_64.whl", hash = "sha256:a59db03b80a156a6fbeae41096866d1cb89cdf31031ba44c768a804538880636"}, - {file = "pydantic_core-2.50.2-cp314-cp314t-win32.whl", hash = "sha256:0d090ae76d5b09c003600c7779b3adcf3d1b49268f616c5c51d844e54c8e318d"}, - {file = "pydantic_core-2.50.2-cp314-cp314t-win_amd64.whl", hash = "sha256:9b01a092955c1c7530196ad526755cff4f2d11f37ca9a6fc9ebe37ca49a48977"}, - {file = "pydantic_core-2.50.2-cp314-cp314t-win_arm64.whl", hash = "sha256:4ea01f30e119f1ec7a2034e85c40f491d469896aef02cd6436fd9292fe1be3fb"}, - {file = "pydantic_core-2.50.2-cp315-cp315-macosx_10_12_x86_64.whl", hash = "sha256:a3317630e2791f56071b82f89bb71624146125e4311e6643f708c6ba744b5ac5"}, - {file = "pydantic_core-2.50.2-cp315-cp315-macosx_11_0_arm64.whl", hash = "sha256:f73930dacad5e611fe019e18df6f53c30629b1843d038d303b8dec86a32493bd"}, - {file = "pydantic_core-2.50.2-cp315-cp315-manylinux1_i686.manylinux_2_5_i686.whl", hash = "sha256:e2e6240a0a5ad847017b3d65187877fdb7a11d5a58d43c30736f9f523478913b"}, - {file = "pydantic_core-2.50.2-cp315-cp315-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:1fdf5b52ed22f1404c2433d0b46df2d86d9befb742d0b9b4042a2325c43cdb97"}, - {file = "pydantic_core-2.50.2-cp315-cp315-manylinux2014_armv7l.manylinux_2_17_armv7l.whl", hash = "sha256:4e9392ddf67fe97ab9889f796d468c9908a8754b8b6c7520eb03a65012b9a1e7"}, - {file = "pydantic_core-2.50.2-cp315-cp315-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:48e944091b7bff233920bed8a60b0ed6c96c73d3c5836bf51c4b9a4bfb58e4ca"}, - {file = "pydantic_core-2.50.2-cp315-cp315-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:91c92856b846aa690ea6239ffd6c5003c5e3e296a69095570bf4efee5bfa0bdc"}, - {file = "pydantic_core-2.50.2-cp315-cp315-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:5299296ff5cafcb69851fd652de8f9268a0bb036bcbedbfcaa94cf743baf3986"}, - {file = "pydantic_core-2.50.2-cp315-cp315-manylinux_2_31_riscv64.whl", hash = "sha256:d3d049b557875f9d15230eec8a731749a7a873d8ed6a051903b05bdf46e0e65f"}, - {file = "pydantic_core-2.50.2-cp315-cp315-musllinux_1_1_aarch64.whl", hash = "sha256:b0b25d647036972c2951059046cb498f72b7af5a2def27bf8e5f44c3067ab7dd"}, - {file = "pydantic_core-2.50.2-cp315-cp315-musllinux_1_1_armv7l.whl", hash = "sha256:8835566b3e94026da3ce2249f9ee35c9d2ebe4cd131f6a39bfc82708d3010a46"}, - {file = "pydantic_core-2.50.2-cp315-cp315-musllinux_1_1_x86_64.whl", hash = "sha256:3fbcd402e4b607d4b8de5d4591215f31f042af03f9d09e58f693a6221e32833f"}, - {file = "pydantic_core-2.50.2-cp315-cp315-win32.whl", hash = "sha256:8431ecb131489cbdaf6f51f7ade47475f73aff4f1912552f75ba19a6cfe233a8"}, - {file = "pydantic_core-2.50.2-cp315-cp315-win_amd64.whl", hash = "sha256:04cf672960b8c4fc28bb159c8cdd101fbd311c520237a5c0360448b851adfb41"}, - {file = "pydantic_core-2.50.2-cp315-cp315-win_arm64.whl", hash = "sha256:36917e29c0b815d6b940bc91560fcf453b5b85d55c579796373f0ea11d1c111a"}, - {file = "pydantic_core-2.50.2-cp315-cp315t-macosx_10_12_x86_64.whl", hash = "sha256:bd1fe69056a19c377a6c6de2c1240fb8676ba0512a969965efb486510c5e0f1f"}, - {file = "pydantic_core-2.50.2-cp315-cp315t-macosx_11_0_arm64.whl", hash = "sha256:9b2383933b1dd7a8c93e02f99ebfd305f1286057172483b8e6898bed3fef69d3"}, - {file = "pydantic_core-2.50.2-cp315-cp315t-manylinux1_i686.manylinux_2_5_i686.whl", hash = "sha256:a1b4d60bad57d6e0e7cd30cc4d1dc646d258dd6dfb7935ce76c7dd72dd1e98b0"}, - {file = "pydantic_core-2.50.2-cp315-cp315t-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:93bedc68c4138088ea3c042189c01d2945f530f0dcc36e1ea02df8418bd4f1cd"}, - {file = "pydantic_core-2.50.2-cp315-cp315t-manylinux2014_armv7l.manylinux_2_17_armv7l.whl", hash = "sha256:d684ff87d00de2f6abcbbfa9b0fdce8b513dd799a900809dcfa7eb62ad69832a"}, - {file = "pydantic_core-2.50.2-cp315-cp315t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:bb6d49f00e2babd40af4889d6b9f4bf50879f522dd4e2e22cb705cac5e0c5e8e"}, - {file = "pydantic_core-2.50.2-cp315-cp315t-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:6d47b2d0e00e030e0ebdb08115a37da7294e7a6d196d134a77ed7ee6c142284b"}, - {file = "pydantic_core-2.50.2-cp315-cp315t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:95838be125133fa314753f8cc5168f7c41e3a9dd5eef5383dbbbeed511bd4853"}, - {file = "pydantic_core-2.50.2-cp315-cp315t-manylinux_2_31_riscv64.whl", hash = "sha256:2d4a043c820363359e40ac96270e1915e5376e116be1f59cee0701775de3e376"}, - {file = "pydantic_core-2.50.2-cp315-cp315t-musllinux_1_1_aarch64.whl", hash = "sha256:57bccd3e1128736c792094da1feac6da46ec3feb1957ef649a9b3e4f8de6fa04"}, - {file = "pydantic_core-2.50.2-cp315-cp315t-musllinux_1_1_armv7l.whl", hash = "sha256:24120c644322a35b5eb765416ac8442214c45689e255f5fc6e761e7e7c743c8b"}, - {file = "pydantic_core-2.50.2-cp315-cp315t-musllinux_1_1_x86_64.whl", hash = "sha256:b1adf2f37521b578c438f6ec61d1c1d0c20b076863ddd5d8b6f3ab658857db3f"}, - {file = "pydantic_core-2.50.2-cp315-cp315t-win32.whl", hash = "sha256:d79aaa468193c1bed6b0560d3c5c9f9e369e3efb0b128b38a2537e2d51d42773"}, - {file = "pydantic_core-2.50.2-cp315-cp315t-win_amd64.whl", hash = "sha256:cc488daac19e6f5292180fac5e0ef7efffabeef4e096af9a17a75a7d3d6781f6"}, - {file = "pydantic_core-2.50.2-cp315-cp315t-win_arm64.whl", hash = "sha256:91315aea7adb51821d4a3378ede953bfdd76e3bf71551de4a82d7638cef7dc02"}, - {file = "pydantic_core-2.50.2-graalpy311-graalpy242_311_native-macosx_10_12_x86_64.whl", hash = "sha256:adec010c824290d4ca87047e8d8bfa4f85ac29f545f326cd5321696805d311ed"}, - {file = "pydantic_core-2.50.2-graalpy311-graalpy242_311_native-macosx_11_0_arm64.whl", hash = "sha256:f47c1349c3b4274aeb18459d54244881a5c0dee0fdccedffca45704ba5c9e0a0"}, - {file = "pydantic_core-2.50.2-graalpy311-graalpy242_311_native-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:4ee64baeab403b9de9c92846c5c1abec28ffb046cbc023bfae059897841f88af"}, - {file = "pydantic_core-2.50.2-graalpy311-graalpy242_311_native-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:16ec8e07c37f02dcf68939cc7f202ba9a148cc155ee2acf22d337e10b24c2cb7"}, - {file = "pydantic_core-2.50.2-graalpy312-graalpy250_312_native-macosx_10_12_x86_64.whl", hash = "sha256:d18d56c1ec63b304f4bb3c7db7e0d311e61cca1b1c944590a4b13ac39b2ca92b"}, - {file = "pydantic_core-2.50.2-graalpy312-graalpy250_312_native-macosx_11_0_arm64.whl", hash = "sha256:41ed8abeffda6a880207fdc0cd1343a448cec3cc6b38b53f730c0745f745292d"}, - {file = "pydantic_core-2.50.2-graalpy312-graalpy250_312_native-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:b7abcfaf66c1dc14c5ed928c349614f223c972a8b021b4be9548dbea6c817371"}, - {file = "pydantic_core-2.50.2-graalpy312-graalpy250_312_native-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:9e7460abce637f90e37f8c443559fbd687c38884d05cb69ef265e634945f4324"}, - {file = "pydantic_core-2.50.2-pp311-pypy311_pp73-macosx_10_12_x86_64.whl", hash = "sha256:b583ddeee6a6bb5bbc04462167c68034913221139d52d9f155ca6d1637a2fdcf"}, - {file = "pydantic_core-2.50.2-pp311-pypy311_pp73-macosx_11_0_arm64.whl", hash = "sha256:5ab5738c39b25b5dc5a721270e2269a2f5e86e614375e6c07ee6caab8cbc0f2f"}, - {file = "pydantic_core-2.50.2-pp311-pypy311_pp73-manylinux1_i686.manylinux_2_5_i686.whl", hash = "sha256:21a902e546032c82b7275552345a2342d862e0541aea7226c91067c396e68b3f"}, - {file = "pydantic_core-2.50.2-pp311-pypy311_pp73-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:92ada606285dab054e40848a951f583c537cde1e54701ea1305ec0096877012d"}, - {file = "pydantic_core-2.50.2-pp311-pypy311_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:c1b65a42afc73b39e6ae908ec7b9c3b9898676a7b15ce4c66d4965f7071007c8"}, - {file = "pydantic_core-2.50.2-pp311-pypy311_pp73-musllinux_1_1_armv7l.whl", hash = "sha256:c324a7e0c0012e3974053f81a270d8f1aa23227571f4ddd3254c911bb356459b"}, - {file = "pydantic_core-2.50.2-pp311-pypy311_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:cb8d2d7b07cbe2d7488de7e53671f836c4f4a8032dcda079df33dc1b7e2397c0"}, - {file = "pydantic_core-2.50.2-pp311-pypy311_pp73-win_amd64.whl", hash = "sha256:7c6e1bd6cadae13958e52897ef020e85c9916a95917149fca463bb0c0421a7c6"}, - {file = "pydantic_core-2.50.2-pp311-pypy311_pp80-macosx_10_12_x86_64.whl", hash = "sha256:f078e276848bc23d1f92f46fc88d5b9cbb824b9acc60d9e07116620e502e16a9"}, - {file = "pydantic_core-2.50.2-pp311-pypy311_pp80-macosx_11_0_arm64.whl", hash = "sha256:3435c443da7510a6de1a30c68beae338852a11f0440cc8320ea756a162f38dbe"}, - {file = "pydantic_core-2.50.2-pp311-pypy311_pp80-manylinux_2_28_x86_64.whl", hash = "sha256:b5675a12a7b67063fe3ca187e735b0463cf13fabc10166ae4d4b2f775fd0632d"}, - {file = "pydantic_core-2.50.2-pp311-pypy311_pp80-win_amd64.whl", hash = "sha256:f5ba7ef10ce82737e173fa95cafa1c8210918f7e653715b2c7a7a31877a74848"}, - {file = "pydantic_core-2.50.2.tar.gz", hash = "sha256:1b0e8dc3932cf4e9ed5727570325cacc716b9409ffc794a221c0ccc72e8eb775"}, + {file = "pydantic_core-2.50.4-cp310-cp310-macosx_10_12_x86_64.whl", hash = "sha256:83d2beac85b757bfc404c5c0612df51c4ef33bbb7be65cf4a96b4da7cbc4ff4f"}, + {file = "pydantic_core-2.50.4-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:76e0065998159244ff4c097a6c05ff08019c6fbb6e597a85846e73044f0215b3"}, + {file = "pydantic_core-2.50.4-cp310-cp310-manylinux1_i686.manylinux_2_5_i686.whl", hash = "sha256:25e7e1080f9f7ce7cd9d114b31470ce912771bd02f38c824721d3c35d312abff"}, + {file = "pydantic_core-2.50.4-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:c4c5a1770ecfe8bdb6c6f09f8d81ea4de04f7efb012fac1efa4ad315dccc1fd1"}, + {file = "pydantic_core-2.50.4-cp310-cp310-manylinux2014_armv7l.manylinux_2_17_armv7l.whl", hash = "sha256:2f6767122b37c780bb756a720a4eef2bc6a050a0a1143428834b3cbc89448bd2"}, + {file = "pydantic_core-2.50.4-cp310-cp310-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:86c7c4615634b5c57a79770f5b738354e45ae219a89949aeae84f19169a05283"}, + {file = "pydantic_core-2.50.4-cp310-cp310-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:6c7d7b0b596319e9ce79ef96ce57a14054a2eac629c0588a0539187a218be799"}, + {file = "pydantic_core-2.50.4-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:ed9c0b6f236648dbf30d57e9f57e1f74878caafa04833a19f529b5ba5164b7a8"}, + {file = "pydantic_core-2.50.4-cp310-cp310-manylinux_2_31_riscv64.whl", hash = "sha256:dfcf6e51000b34f7026322cd9ea9bc340d745637e27e0bbc22f504b4f6b967ee"}, + {file = "pydantic_core-2.50.4-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:bd46bcc28ed85d3cf71581b42d90b4ebd1f2062f81879519fed209f8a4d1cfc6"}, + {file = "pydantic_core-2.50.4-cp310-cp310-musllinux_1_1_armv7l.whl", hash = "sha256:696613a0c0e7b2b35356e389ba4195ce20cfe7a2fc2e992c87d974d973eabec7"}, + {file = "pydantic_core-2.50.4-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:2980a701be88f9128a7470189fa3bcda5387f76c298a6f8e000fc29eb2a6f4e7"}, + {file = "pydantic_core-2.50.4-cp310-cp310-win32.whl", hash = "sha256:dd8bed00731a21e3106e5dd6bbffb6c775a2c0bbc7c0c9face534d830057bdc9"}, + {file = "pydantic_core-2.50.4-cp310-cp310-win_amd64.whl", hash = "sha256:e512c75ec5cf4475c1aa50ad975ecdf253f4963b06e152e1a11edd6de4010753"}, + {file = "pydantic_core-2.50.4-cp311-cp311-macosx_10_12_x86_64.whl", hash = "sha256:3e547ceec1da7382f01f9e13963023e53367a71802c88778b21b9645a077cbdf"}, + {file = "pydantic_core-2.50.4-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:c813ada7a651193acda85b6bc1cf12abd4b37cd25c7c6a75d7183512cc374969"}, + {file = "pydantic_core-2.50.4-cp311-cp311-manylinux1_i686.manylinux_2_5_i686.whl", hash = "sha256:57fa0a9490785139f1a4e4f43891830d55dfe4408845c0c9cb5eff4aeaf75f69"}, + {file = "pydantic_core-2.50.4-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:30d4dc35bc0eea52202a90b3820445ee0072c820241bfa710a623a078c9b267b"}, + {file = "pydantic_core-2.50.4-cp311-cp311-manylinux2014_armv7l.manylinux_2_17_armv7l.whl", hash = "sha256:789f88dea57841cdebef392b5d6e90444d767117e9ff2e0d9172df5c9de6690c"}, + {file = "pydantic_core-2.50.4-cp311-cp311-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:d690121e80ab16e623415351ab24713534d4e500b3cadff216409cb6826063d4"}, + {file = "pydantic_core-2.50.4-cp311-cp311-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:b42f64825f5d750228f08318a9bf4d723b7ecb4c472aedcb3013c3ec2dc1f949"}, + {file = "pydantic_core-2.50.4-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:0574866e05f6adeecc520d87e87dd06210c0a51706341f6ef8421572f5a64444"}, + {file = "pydantic_core-2.50.4-cp311-cp311-manylinux_2_31_riscv64.whl", hash = "sha256:dcf2c7eaaa4cafe8e49b017e5bb49e76e084ab6f0cd712ee4019c812b5cf68b8"}, + {file = "pydantic_core-2.50.4-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:3b8ee2589a082739c522c1fe4be227412fcf108b903abb6672ae2f5570558882"}, + {file = "pydantic_core-2.50.4-cp311-cp311-musllinux_1_1_armv7l.whl", hash = "sha256:aec3c2d741a8e3ee993de7f95f37afb51e31b169c95dbd29da4cf6688f340914"}, + {file = "pydantic_core-2.50.4-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:8923fcd49f875e8a0448d7223d1fdf1a9973ae2d1f20d4158753ceb8909facd2"}, + {file = "pydantic_core-2.50.4-cp311-cp311-win32.whl", hash = "sha256:fc04affef30be98c1f36f0c422a4061ef618fdc1dde79f5ad5458dd496fecffa"}, + {file = "pydantic_core-2.50.4-cp311-cp311-win_amd64.whl", hash = "sha256:15bece43a02ad543c621c8305e67dedb5f27d378c5ba741e5a2c36523f8ef37f"}, + {file = "pydantic_core-2.50.4-cp311-cp311-win_arm64.whl", hash = "sha256:e498900bfbf7ddddd862f810440c09e9b81674739e8a11d619b40906dccd4a9a"}, + {file = "pydantic_core-2.50.4-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:32a991aebd165f227b7c7c60bb9d66c2c7de9c24308552da264c9938fde0f8d6"}, + {file = "pydantic_core-2.50.4-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:1e20cbde2b6deb33a51d08cd168454dd9044ec7d4474056f4d98d63f51578783"}, + {file = "pydantic_core-2.50.4-cp312-cp312-manylinux1_i686.manylinux_2_5_i686.whl", hash = "sha256:8cceae48ae7f94990c2f4e36291e9ec9868735e8b0f19e4489a17b0422338466"}, + {file = "pydantic_core-2.50.4-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:16902a147b3da4840612164a5e67947104d63e978f7a57c395877a5e26690b9c"}, + {file = "pydantic_core-2.50.4-cp312-cp312-manylinux2014_armv7l.manylinux_2_17_armv7l.whl", hash = "sha256:d6e3485a5e5c01fb5339c1ee3d4b9e21e2135a2a9d44caafb71acd994487ee7c"}, + {file = "pydantic_core-2.50.4-cp312-cp312-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:629eae995185540406e3635df5d5cf1d44f19ea240840b835d3f44541ff694d8"}, + {file = "pydantic_core-2.50.4-cp312-cp312-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:41b2cd8b29dbb5a4c9828a70f50d1abfc92011115c813213d3a91205c6f731b3"}, + {file = "pydantic_core-2.50.4-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:c81d98e27d9d9261909dcccab1ba5d6ea1c98b0bb9470e368604614fd1d36ddd"}, + {file = "pydantic_core-2.50.4-cp312-cp312-manylinux_2_31_riscv64.whl", hash = "sha256:ca83a32b2b41653d89f09a3d22b770bca96da72273bef8f7a68136bdd1e8b823"}, + {file = "pydantic_core-2.50.4-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:817953730e4a73a09008b010c4a42396cefe799616a22df2ac21d3927b3080cf"}, + {file = "pydantic_core-2.50.4-cp312-cp312-musllinux_1_1_armv7l.whl", hash = "sha256:664e74848c2f5fc27db8505fe24e1ecd3ac669412913bf73d176916f86cc08e2"}, + {file = "pydantic_core-2.50.4-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:219114f8dcdcbe4720d82ef016b1287ce5a0a67d7c69ca61524eb72e82aac344"}, + {file = "pydantic_core-2.50.4-cp312-cp312-win32.whl", hash = "sha256:67f7cc397e1d5556a801d1cba74de0d27d827eb242e6c036c0ca273c745414f1"}, + {file = "pydantic_core-2.50.4-cp312-cp312-win_amd64.whl", hash = "sha256:ea2f61b0bc12f3592288503961b764579dea0658852d96a0b3d823614d808821"}, + {file = "pydantic_core-2.50.4-cp312-cp312-win_arm64.whl", hash = "sha256:32d6dda86383645ec428ea64dfc277036f5cbc60a72238eab28b91a3fdb9a113"}, + {file = "pydantic_core-2.50.4-cp313-cp313-macosx_10_12_x86_64.whl", hash = "sha256:0f87ae9db5ba8d8de40dcb93982cf8dd544e6552a80d3345af51941cc2146b80"}, + {file = "pydantic_core-2.50.4-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:1239daaf063e62213ca1f34d96663900bd7510c42a786e843fd328af70e46445"}, + {file = "pydantic_core-2.50.4-cp313-cp313-manylinux1_i686.manylinux_2_5_i686.whl", hash = "sha256:1afefe44ec042fbabfb4483ea258c04cf75ff4ff328d754f09b321fdaa232aca"}, + {file = "pydantic_core-2.50.4-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:a9ee990bf2cfbd81574c5d4f9f6c9d480a14b5b43d2c4f2ca13f4c6f48089394"}, + {file = "pydantic_core-2.50.4-cp313-cp313-manylinux2014_armv7l.manylinux_2_17_armv7l.whl", hash = "sha256:ab2822bcdcefb54d1e8ca29f5e3ec3afe160fb794bb3a3a73b09d11ed2671104"}, + {file = "pydantic_core-2.50.4-cp313-cp313-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:0001d6920e3a5d92758cda460d6dc9f918a78ad6d5d092f1c8b5395e6b775356"}, + {file = "pydantic_core-2.50.4-cp313-cp313-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:ad92d255a165cde5f9882ff69699eaf5495e0a1f32e97566bbbb80f11e46781f"}, + {file = "pydantic_core-2.50.4-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:fb2bb5b557080da398b866408117d98fe9731a12334afd0cdff221b458cdc5dc"}, + {file = "pydantic_core-2.50.4-cp313-cp313-manylinux_2_31_riscv64.whl", hash = "sha256:92f8f63df729061bb14558ed740e7a222f6e2aa6c2e6a5bcfb4e706676562049"}, + {file = "pydantic_core-2.50.4-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:2a60ec2a57ac3ef3767e526e9bf706ec75aa3d79c4ea134d9d4fcf7c62a297a7"}, + {file = "pydantic_core-2.50.4-cp313-cp313-musllinux_1_1_armv7l.whl", hash = "sha256:a2f8716344bbbd10443391be0b1f2003b34949e3c4e6883005c2bc498ab6b64b"}, + {file = "pydantic_core-2.50.4-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:b300a30304c4c6aeab03ed06809819d9eceacdd58441d3c7dffe41edfd006091"}, + {file = "pydantic_core-2.50.4-cp313-cp313-win32.whl", hash = "sha256:ef8a9ddb2e2a4eae4abb72dc0710eca6c2726779b0664bd10c3ce9fcfaed8c4e"}, + {file = "pydantic_core-2.50.4-cp313-cp313-win_amd64.whl", hash = "sha256:4c29b8f2d6417069bb1f257e6b9113f5d64dc2f554cc200ea90b4fe2c5cdb733"}, + {file = "pydantic_core-2.50.4-cp313-cp313-win_arm64.whl", hash = "sha256:a0c5210d038418a115e7cf8706bfa611bd14add2f5787274dba45aadca3155e0"}, + {file = "pydantic_core-2.50.4-cp314-cp314-macosx_10_12_x86_64.whl", hash = "sha256:5c074454dc6d4f6f4ba6561a56bf33a14db7651d882a5a5321ba3ae8868e082d"}, + {file = "pydantic_core-2.50.4-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:a4bb174bd65f795c39ad6642d9d5bdc43351b306b7d0a654ab0d0abb38be245f"}, + {file = "pydantic_core-2.50.4-cp314-cp314-manylinux1_i686.manylinux_2_5_i686.whl", hash = "sha256:0ec20aca2b067369913716847f7dfe5f4dddf16a46965b7a70bbad5defaaba86"}, + {file = "pydantic_core-2.50.4-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:70dbc9f83c41f37a4faa62dae5203853847223a891da446f48ef2efcfd5df806"}, + {file = "pydantic_core-2.50.4-cp314-cp314-manylinux2014_armv7l.manylinux_2_17_armv7l.whl", hash = "sha256:3de6c2a4df2af0ac9ab4dc1488746fe8b1a90e27955d870d9edda3187d20092b"}, + {file = "pydantic_core-2.50.4-cp314-cp314-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:3a48a5254d15a0ad050318bfc7a9566d4ec740118187e8f303e47a6840287eb7"}, + {file = "pydantic_core-2.50.4-cp314-cp314-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:0af56dbf8822ba9f4efcbbfdc15478f8b6fb08f1609860cb50aa2cc8476b3c34"}, + {file = "pydantic_core-2.50.4-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:f1d62fb172db35c6478c9323da34ff37d1f3d37d7d44337a9d94ba8c583e5730"}, + {file = "pydantic_core-2.50.4-cp314-cp314-manylinux_2_31_riscv64.whl", hash = "sha256:5c1013647be741647895c102831dcf79c34209662dbb683df9efb864417ed7d5"}, + {file = "pydantic_core-2.50.4-cp314-cp314-musllinux_1_1_aarch64.whl", hash = "sha256:aeb2e123cbf978a905e9f55155c1b8316fbbfa7cf64d04521fe174bab302d100"}, + {file = "pydantic_core-2.50.4-cp314-cp314-musllinux_1_1_armv7l.whl", hash = "sha256:523466eba8ee10f7480f3c2057563145978011c583130d2cc01fb1e7af808e25"}, + {file = "pydantic_core-2.50.4-cp314-cp314-musllinux_1_1_x86_64.whl", hash = "sha256:c9e70012926e97069cdd09221861aff412aa94e4cac2e019055cdb79485b150c"}, + {file = "pydantic_core-2.50.4-cp314-cp314-pyemscripten_2026_0_wasm32.whl", hash = "sha256:e6da138a1ecc1341c8b788a5ee822670b03788e1f5decf7af9d461de6e508b8e"}, + {file = "pydantic_core-2.50.4-cp314-cp314-win32.whl", hash = "sha256:13b6dd62b5279f5b9d72f3bf918a35443ee8bd549241d9dc52d79a2c3b6d7016"}, + {file = "pydantic_core-2.50.4-cp314-cp314-win_amd64.whl", hash = "sha256:b0cdb655fbd1562c2dfc9986f9103a106f7058cd0915afc6e656d4b1d73f3387"}, + {file = "pydantic_core-2.50.4-cp314-cp314-win_arm64.whl", hash = "sha256:df1c174796cd63eb6b139f7daf783affe1f3ed659605850e843b24764c21bfc5"}, + {file = "pydantic_core-2.50.4-cp314-cp314t-macosx_10_12_x86_64.whl", hash = "sha256:edbca8789fd10f0de534b660a6b4c71f1fd18039679c918dad392ab044bb37e4"}, + {file = "pydantic_core-2.50.4-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:33b21f69540a12c2053cd1d95766d8bd9667a3897f7c712a642de8aa37eb0865"}, + {file = "pydantic_core-2.50.4-cp314-cp314t-manylinux1_i686.manylinux_2_5_i686.whl", hash = "sha256:ffb616d8d55965839670301dc3bae3abacff560a7e137a89056058a8a9da4d96"}, + {file = "pydantic_core-2.50.4-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:6c5687b59b6ba0f663c4f2f15470f68507d6b45ccd3a19ee6d224f95cbee70d8"}, + {file = "pydantic_core-2.50.4-cp314-cp314t-manylinux2014_armv7l.manylinux_2_17_armv7l.whl", hash = "sha256:c733087ecf7dde06b1d071679bfd5f3ba03266ba77814c1c7253bc48c9adedd9"}, + {file = "pydantic_core-2.50.4-cp314-cp314t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:94733cb447c37b0ce6f71b39ca1288d5f966a084023a5617b4cc35a852586859"}, + {file = "pydantic_core-2.50.4-cp314-cp314t-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:b26f39a5be3cd91a2035818be3d0ffdf5282c3e1f5f53d3b80b7024021acee52"}, + {file = "pydantic_core-2.50.4-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:c856e439a9d54d514e81a7131229ba151cdf81df7c408e0f6c89340e5003dfe2"}, + {file = "pydantic_core-2.50.4-cp314-cp314t-manylinux_2_31_riscv64.whl", hash = "sha256:cbf0777d54672990b10cb8ca9b0523499e182d7e2ea39f86b138519a902aa601"}, + {file = "pydantic_core-2.50.4-cp314-cp314t-musllinux_1_1_aarch64.whl", hash = "sha256:edc17549ab592e33cfcaf285f047bb75fcd98f608aa9309af1187fd736ce9641"}, + {file = "pydantic_core-2.50.4-cp314-cp314t-musllinux_1_1_armv7l.whl", hash = "sha256:23a9ba564b2db709ff16eca990992ba95a19069972b34bff87c81d4b473cd755"}, + {file = "pydantic_core-2.50.4-cp314-cp314t-musllinux_1_1_x86_64.whl", hash = "sha256:41f4f8ae714e4fea1d635880f8a1af715ecf080eed4d13c5b04a0f3210f9c61a"}, + {file = "pydantic_core-2.50.4-cp314-cp314t-win32.whl", hash = "sha256:601fce6cea9ddeaa85329e12e7f351def38d233075f42a3012b9c48071b02941"}, + {file = "pydantic_core-2.50.4-cp314-cp314t-win_amd64.whl", hash = "sha256:22e874666bdbd96d6bf629d32cd8ab376fedf1fd62585b52a42b9fa9fa6c20b6"}, + {file = "pydantic_core-2.50.4-cp314-cp314t-win_arm64.whl", hash = "sha256:71395a43da5584bb70556f380387e15f845c0dcf76373c1afbfa0025737576ac"}, + {file = "pydantic_core-2.50.4-cp315-cp315-macosx_10_12_x86_64.whl", hash = "sha256:7ac2769a7ddd661e07e26c12220adc31b17014c48234b2a5a88993b8d4109e09"}, + {file = "pydantic_core-2.50.4-cp315-cp315-macosx_11_0_arm64.whl", hash = "sha256:930ad463d3fb7a340d323bcc496ec32dae469ec9974c29ff569f19806b6b03b4"}, + {file = "pydantic_core-2.50.4-cp315-cp315-manylinux1_i686.manylinux_2_5_i686.whl", hash = "sha256:b867f9fd183d76977f810c626d539265183c25b2284762893a31e8d6cacc81c0"}, + {file = "pydantic_core-2.50.4-cp315-cp315-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:49eb1241a969a5994db6880c18c012b6cbe2340343d8f529721571806583e500"}, + {file = "pydantic_core-2.50.4-cp315-cp315-manylinux2014_armv7l.manylinux_2_17_armv7l.whl", hash = "sha256:477af785d1846e4e96bf56983b92ea7553aaeccdeb8acdaa55c7cee9eda0ae32"}, + {file = "pydantic_core-2.50.4-cp315-cp315-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:29358a8ca74e7d81158d14e2b10c904bd18773293ae3788716c0626fe0342347"}, + {file = "pydantic_core-2.50.4-cp315-cp315-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:300753f71c73302e218124baf995f00058e085cd01869bd9610bcbd0bd4500c1"}, + {file = "pydantic_core-2.50.4-cp315-cp315-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:26cb012c4b8ca9f847bd0ac15978bd3d0f55b050bfbe6c47355edfc7e945029b"}, + {file = "pydantic_core-2.50.4-cp315-cp315-manylinux_2_31_riscv64.whl", hash = "sha256:9be1cfe715ecaa060ffd5d599ef410b94ef2697a0eed4cee562f788a2aa2175b"}, + {file = "pydantic_core-2.50.4-cp315-cp315-musllinux_1_1_aarch64.whl", hash = "sha256:c81e35862aced259177a537ce1a6264c3a97bae1ced184ca9dc10ea754563688"}, + {file = "pydantic_core-2.50.4-cp315-cp315-musllinux_1_1_armv7l.whl", hash = "sha256:b2f2d13239487cecaae98c9f4d5904ad0737643cdf8873c88ec6a78b12214f20"}, + {file = "pydantic_core-2.50.4-cp315-cp315-musllinux_1_1_x86_64.whl", hash = "sha256:e6b4b08d09054310a4dc389fa61ee22a7a5a292cb23ab8a985136ca8828bf924"}, + {file = "pydantic_core-2.50.4-cp315-cp315-win32.whl", hash = "sha256:6619d49a89a15cd04334f76fec530c155923bfc60da74ff5d815a52629e1aa6c"}, + {file = "pydantic_core-2.50.4-cp315-cp315-win_amd64.whl", hash = "sha256:e5bd109d095aaae989a0463d5ef0fcc43e9ddd5de125e656d3c119a79e466380"}, + {file = "pydantic_core-2.50.4-cp315-cp315-win_arm64.whl", hash = "sha256:6118e5a5550e36582e19bac1a403711a748f9f18251b054c326d3db02aaa7a18"}, + {file = "pydantic_core-2.50.4-cp315-cp315t-macosx_10_12_x86_64.whl", hash = "sha256:d8201c9f9035520cdcc7dcad383b039ec8123969b87e01cf27c3dd883c02313b"}, + {file = "pydantic_core-2.50.4-cp315-cp315t-macosx_11_0_arm64.whl", hash = "sha256:1de7be9a66fc8536770481ab64a05aae5067c725f2b29a09543af00e6a417b97"}, + {file = "pydantic_core-2.50.4-cp315-cp315t-manylinux1_i686.manylinux_2_5_i686.whl", hash = "sha256:789a6453e5ffd18a7ab6b8c3a0dd8403053829197ec258ecb90c604c21ffcc99"}, + {file = "pydantic_core-2.50.4-cp315-cp315t-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:6348ad12fa741bcc9c2f173e99fbf27cbc038826d8c31a4a7d836eca27878ba2"}, + {file = "pydantic_core-2.50.4-cp315-cp315t-manylinux2014_armv7l.manylinux_2_17_armv7l.whl", hash = "sha256:d49127f137f871cde3c5650af33bbbdcee02679dae76e020902fa106f522b8ae"}, + {file = "pydantic_core-2.50.4-cp315-cp315t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:2f5cc5bcb94063fbbdfd285a2b302da34af07491337c10bb35de1d5220fa1583"}, + {file = "pydantic_core-2.50.4-cp315-cp315t-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:b99bed995ed7c41515c11fe2beb86f8a6cc298e5537cae2f736de2f982f74ef0"}, + {file = "pydantic_core-2.50.4-cp315-cp315t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:faa4e96385c820ce9d7f7a623486e23d4134ae3c9ba2071e44e0ab5a5a5002c4"}, + {file = "pydantic_core-2.50.4-cp315-cp315t-manylinux_2_31_riscv64.whl", hash = "sha256:d6a166978f22f10cb91413f70519861605219346decf65bc79008f9257c94afe"}, + {file = "pydantic_core-2.50.4-cp315-cp315t-musllinux_1_1_aarch64.whl", hash = "sha256:a70d5effebd81ebd8e15a8aabdc7980832367b2b00c36543bac378977004cc80"}, + {file = "pydantic_core-2.50.4-cp315-cp315t-musllinux_1_1_armv7l.whl", hash = "sha256:f8fd23653a252cefabea11cd041efd7b80bdf403e43a36dea53f9cb0aaa21f0f"}, + {file = "pydantic_core-2.50.4-cp315-cp315t-musllinux_1_1_x86_64.whl", hash = "sha256:7646353a5a7c553c04167aca628e2550b538f492765b03ccf34321a560acc43c"}, + {file = "pydantic_core-2.50.4-cp315-cp315t-win32.whl", hash = "sha256:65376dbe1ab4dbc768ca2b72b7c13993562c035f5925fd3bc7ff9c8c585c515d"}, + {file = "pydantic_core-2.50.4-cp315-cp315t-win_amd64.whl", hash = "sha256:f08ee8248aad2d054e5bc4c73554d4505464698f6d754f16198dbc5764e9821d"}, + {file = "pydantic_core-2.50.4-cp315-cp315t-win_arm64.whl", hash = "sha256:da779ae50b46f3f7d1e1b5f362fdc0ad376a49fd55f6f3122dc2b6149936cdf7"}, + {file = "pydantic_core-2.50.4-graalpy312-graalpy250_312_native-macosx_10_12_x86_64.whl", hash = "sha256:c04e9d920e2674f54651fd260a15c5d2843526c73d5242ee4311325ddc9573b3"}, + {file = "pydantic_core-2.50.4-graalpy312-graalpy250_312_native-macosx_11_0_arm64.whl", hash = "sha256:5bc1811ef2b4d4ba63e8e452f6e332b6374bd1d2cbbfdf66826c8cb1f71dd10d"}, + {file = "pydantic_core-2.50.4-graalpy312-graalpy250_312_native-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:0b059a7968b1911be5a2d9a8234827ab0bef9d1e465d4b42da525894143550e8"}, + {file = "pydantic_core-2.50.4-graalpy312-graalpy250_312_native-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:bee28aab5a580eec673f7b68dfa8dece3dd37bd207ef8d22fafe23a8e9837296"}, + {file = "pydantic_core-2.50.4-graalpy313-graalpy253_313_native-macosx_11_0_arm64.whl", hash = "sha256:71e03d2ea1a221d020cfc5b6cc8bbbedef23a06704c70fcf4d0afb42965b22d1"}, + {file = "pydantic_core-2.50.4-graalpy313-graalpy253_313_native-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:09450778e3ab58d3f565899fcfbf6c82926e31af29e28e799d1d50941316e0cb"}, + {file = "pydantic_core-2.50.4-graalpy313-graalpy253_313_native-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:4eb15be588407148ef5937dc8d9256a71f6b115e6cddadb7aa20b6ee384680dc"}, + {file = "pydantic_core-2.50.4-pp311-pypy311_pp73-macosx_10_12_x86_64.whl", hash = "sha256:39f489ce31272073e6e146f6781690f9c1ee8c126836e6403361ef91154d89fe"}, + {file = "pydantic_core-2.50.4-pp311-pypy311_pp73-macosx_11_0_arm64.whl", hash = "sha256:5b26e5f1793b96cdc60242bf38da86ff24a27a708aa396214cac9b534bf571c7"}, + {file = "pydantic_core-2.50.4-pp311-pypy311_pp73-manylinux1_i686.manylinux_2_5_i686.whl", hash = "sha256:7210398a1607ad607dc73196e575b3148b00a333cbb602ddbe1b60ba54554f43"}, + {file = "pydantic_core-2.50.4-pp311-pypy311_pp73-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:2f42584e5785385f681163a42506cab0d51295e17599a648396c52a7046c1372"}, + {file = "pydantic_core-2.50.4-pp311-pypy311_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:2039e323acee9abfec1fb5f661776e8965fe5928f3b7f8431900a774cba5c317"}, + {file = "pydantic_core-2.50.4-pp311-pypy311_pp73-musllinux_1_1_armv7l.whl", hash = "sha256:71ade6d2e445839350d589ff99bbddfde16f3f32db28da5c894a09f99c8b2a03"}, + {file = "pydantic_core-2.50.4-pp311-pypy311_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:d7d406709ae924cf0b08b8282ca2f0e1c90526911d93bc040557cbc83b74c55f"}, + {file = "pydantic_core-2.50.4-pp311-pypy311_pp73-win_amd64.whl", hash = "sha256:7472c39480ccc11dda69a196d1b7c7a6b48eb6594b77f05d945599d3e47f731c"}, + {file = "pydantic_core-2.50.4-pp311-pypy311_pp80-macosx_10_12_x86_64.whl", hash = "sha256:b67d38e8bb0ade7e6e84575e4bb153fab35b122458077273aeb08fdf12be9d2c"}, + {file = "pydantic_core-2.50.4-pp311-pypy311_pp80-macosx_11_0_arm64.whl", hash = "sha256:4eda7e3fdef382b7d4492745988a5baaf6953923a337f8b9dde5f76fa8afde20"}, + {file = "pydantic_core-2.50.4-pp311-pypy311_pp80-manylinux_2_28_x86_64.whl", hash = "sha256:474f7e598c7902165662a5d5160d3fce31037890a2975a9871ebf7c05862300b"}, + {file = "pydantic_core-2.50.4-pp311-pypy311_pp80-win_amd64.whl", hash = "sha256:3e0b395648c6cb871bceb2906907f255dc876ec425f2d5b024e129985cea8519"}, + {file = "pydantic_core-2.50.4.tar.gz", hash = "sha256:aead3b74b68396bf0feab5d57e050b730ded7df55853c1e048a87e00aaf033c6"}, ] [package.dependencies] @@ -3316,4 +3315,4 @@ ziggurat = ["zigpy-ziggurat"] [metadata] lock-version = "2.1" python-versions = ">=3.13,<3.14" -content-hash = "a36c8669ad727be6432683539faf86290097f65019ab318a97c5116e0cba3741" +content-hash = "4d3e56a0e498e047d8f6bf28d787e79792c029abb6484cf37a7837bcf39923d1" diff --git a/pyproject.toml b/pyproject.toml index 9ad3f08..407b945 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,7 +23,7 @@ classifiers = [ ] requires-python = ">=3.13,<3.14" dependencies = [ - "majordom-integration-sdk (>=0.3.0,<1.0)", + "majordom-integration-sdk (>=0.4.0,<1.0)", "zigpy (>=2.0.0,<3.0.0)", "zigpy-znp (>=1.1.0,<2.0.0)", "bellows (>=0.49.2,<0.50.0)", diff --git a/tests/conftest.py b/tests/conftest.py index 8308f2c..12aa21a 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -26,15 +26,15 @@ from majordom_zigbee import ZigBeeController -# IEEE 00:11:22:33:44:55:66:77 -> discovery_id 3ad0d5e0-e32d-5b43-ac8f-150aa969c63d +# IEEE 00:11:22:33:44:55:66:77 -> discovery_id 915c8f1c-444b-5659-a997-7d59b59527d3 MOCK_IEEE = t.EUI64.convert("00:11:22:33:44:55:66:77") MOCK_NWK = t.NWK(0x1234) NCP_IEEE = t.EUI64.convert("aa:11:22:bb:33:44:be:ef") EXTENDED_PAN_ID = "dd:dd:dd:dd:dd:dd:dd:dd" # of the network the radio runs, on channel 15 with PAN ID 0x1234 -DEVICE_ID = "3ad0d5e0-e32d-5b43-ac8f-150aa969c63d" -PARAM_COMMAND_ID = "71f0a643-94d1-5def-b4ff-c5a394fafb63" # toggle command_1/6/2 -PARAM_ATTRIBUTE_ID = "d20e6f38-6ad2-5f51-a7b0-0f812b58e5cd" # on_time attribute_1/6/16385 (Read|Write) +DEVICE_ID = "915c8f1c-444b-5659-a997-7d59b59527d3" +PARAM_COMMAND_ID = "4142c1f6-8696-5acf-a547-e46daf222444" # toggle command_1/6/2 +PARAM_ATTRIBUTE_ID = "ca4b246f-9f31-52ec-9628-1a6dbac4a989" # on_time attribute_1/6/16385 (Read|Write) MOCK_INPUT_CLUSTERS: list[int] = [6, 8] # OnOff, LevelControl; tests may monkeypatch it MOCK_OUTPUT_CLUSTERS: list[int] = [] # client-side clusters; tests may monkeypatch it RADIO = Endpoint("zigbee", "ezsp", "/dev/null") # pinned backend: no probing of /dev/null diff --git a/tests/test_controller.py b/tests/test_controller.py index 05238ae..5522398 100644 --- a/tests/test_controller.py +++ b/tests/test_controller.py @@ -6,7 +6,7 @@ from dataclasses import replace from typing import Any, cast from unittest.mock import AsyncMock, patch -from uuid import UUID +from uuid import UUID, uuid4 import conftest import pytest @@ -19,7 +19,7 @@ import zigpy.zcl import zigpy.zdo.types as zdo_t from conftest import DEVICE_ID, PARAM_ATTRIBUTE_ID, PARAM_COMMAND_ID, wait_for -from majordom_integration_sdk import Peripherals +from majordom_integration_sdk import DeviceIdTakenError, Peripherals from majordom_integration_sdk.runtime import PeripheralState, Pinned, Runtime, StatusKind from majordom_integration_sdk.schemas.command import DeviceCommand from majordom_integration_sdk.schemas.parameter import Parameter, ParameterDataType @@ -37,7 +37,7 @@ from majordom_zigbee import ZigBeeController, ZigpyDriver from majordom_zigbee.exceptions import ZBConnectionError from majordom_zigbee.listener import ZBAttributeUpdatedListener -from majordom_zigbee.model import ZBDeviceState, ZBParameter +from majordom_zigbee.model import ZBDevice, ZBDeviceIntegrationData, ZBDeviceState, ZBParameter from majordom_zigbee.zigbee_spec import MAIN_PARAMETER_BY_CLUSTER _NO_RADIO = patch("bellows.zigbee.application.ControllerApplication.new", side_effect=OSError("no radio")) @@ -60,50 +60,88 @@ async def _discover(controller, output): return output.received_discoveries[-1] -async def _seed_provisional(repository, discovery): - """The Hub creates the device row before calling pair_device (persistence is the Hub's job).""" - from majordom_zigbee.model import ZBDeviceIntegrationData, ZBDeviceState +def _draft(discovery, **fields) -> ZBDeviceState: + """What the Hub hands pair_device: the user's form fields, the discovery id.""" + return ZBDeviceState.model_validate( + { + "id": uuid4(), + "physical_id": discovery.id, + "name": "Mock Device", + "room_id": UUID(int=1), + "transport": discovery.transport, + "integration": "zigbee", + "manufacturer": None, + "parameters": [], + "integration_data": ZBDeviceIntegrationData(), + **fields, + } + ) + +async def _pair_as_the_hub(controller, output, repository, discovery, draft=None) -> ZBDeviceState: + """pair_device, then the Hub's part: save, tell the app the device is connected, fetch.""" + device = await controller.pair_device(discovery, draft or _draft(discovery), None) async with repository.session() as repo: - await repo.save( - ZBDeviceState( - id=discovery.id, - name="Mock Device", - room_id=UUID(int=1), - transport=discovery.transport, - integration="zigbee", - manufacturer=None, - parameters=[], - integration_data=ZBDeviceIntegrationData(), - ) - ) + await repo.save(device) + if device.available: + await output.controller_did_connect_device(controller, physical_id=device.physical_id) + await controller.fetch(device) + return device async def test_pairs_a_joined_device(zigbee): controller, output, repository, _app = zigbee - from majordom_zigbee.model import ZBDevice + discovery = await _discover(controller, output) + draft = _draft(discovery, description="kept?") + + device = await controller.pair_device(discovery, draft, None) + + assert device is draft # filled in place and returned + assert discovery.id in controller.discoveries # until the Hub saves it + assert discovery.id not in controller._connected_devices + assert device.physical_id == discovery.id + assert device.integration_data.ieee == controller._mapper.convert_eui64_to_str(conftest.MOCK_IEEE) + assert device.available + assert device.name == "Mock Device" and device.room_id == UUID(int=1) # the user's fields survive + assert len(device.parameters) > 0 + +async def test_pairing_reports_nothing_about_the_device_and_leaves_the_repository_alone(zigbee): + controller, output, repository, _app = zigbee discovery = await _discover(controller, output) - await _seed_provisional(repository, discovery) + await controller.pair_device(discovery, _draft(discovery), None) + await asyncio.sleep(0.05) # a background fetch would have reported by now + assert output.connected_devices == [] and output.events == [] + async with repository.session() as repo: + assert await repo.get(physical_id=discovery.id, as_=ZBDevice) is None - await controller.pair_device(discovery, None) - # the discovery is consumed and the device is now tracked as connected - assert discovery.id not in controller.discoveries - assert discovery.id in controller._connected_devices - # persistence: the controller mapped the device's clusters into parameters +async def test_pairing_a_picked_record_never_changes_its_id(zigbee): + controller, output, _repo, _app = zigbee + discovery = await _discover(controller, output) + picked = _draft(discovery, id=UUID(int=42)) # the record the user picked + device = await controller.pair_device(discovery, picked, None) + assert device.id == UUID(int=42) + assert device.physical_id == discovery.id + assert str(device.physical_id) == DEVICE_ID + + +async def test_a_taken_id_stops_pairing_before_the_device_is_touched(zigbee): + controller, output, repository, _app = zigbee + discovery = await _discover(controller, output) async with repository.session() as repo: - device = await repo.get(discovery.id, as_=ZBDevice) - state = await repo.state(discovery.id) - assert device is not None and device.integration_data.ieee - assert state is not None and len(state.parameters) > 0 + await repo.save(_draft(discovery)) # another record holds the id + other = _draft(discovery) + with pytest.raises(DeviceIdTakenError): + await controller.pair_device(discovery, other, None) + assert discovery.id in controller.discoveries # still pairable + assert discovery.id not in controller._connected_devices async def _pair(zigbee): controller, output, repository, app = zigbee discovery = await _discover(controller, output) - await _seed_provisional(repository, discovery) - await controller.pair_device(discovery, None) + await _pair_as_the_hub(controller, output, repository, discovery) return discovery @@ -111,7 +149,7 @@ async def _param(repository, device_id, parameter_id): from majordom_zigbee.model import ZBDeviceState, ZBParameter async with repository.session() as repo: - state = await repo.state(device_id, as_=ZBDeviceState) + state = await repo.state(physical_id=device_id, as_=ZBDeviceState) param = next(p for p in state.parameters if str(p.id) == parameter_id) return ZBParameter.model_validate(param.model_dump()) @@ -120,7 +158,7 @@ async def _device(repository, device_id): from majordom_zigbee.model import ZBDevice async with repository.session() as repo: - return await repo.get(device_id, as_=ZBDevice) + return await repo.get(physical_id=device_id, as_=ZBDevice) async def test_sends_a_command_parameter(zigbee): @@ -133,7 +171,7 @@ async def test_sends_a_command_parameter(zigbee): # a ZCL command parameter (toggle) — no exception means the command reached the cluster await controller.send_command( - DeviceCommand(device_id=discovery.id, parameter_id=UUID(PARAM_COMMAND_ID), value=None), device, parameter + DeviceCommand(device_id=device.id, parameter_id=UUID(PARAM_COMMAND_ID), value=None), device, parameter ) @@ -146,7 +184,7 @@ async def test_sends_an_attribute_write(zigbee): parameter = await _param(repository, discovery.id, PARAM_ATTRIBUTE_ID) await controller.send_command( - DeviceCommand(device_id=discovery.id, parameter_id=UUID(PARAM_ATTRIBUTE_ID), value=0), device, parameter + DeviceCommand(device_id=device.id, parameter_id=UUID(PARAM_ATTRIBUTE_ID), value=0), device, parameter ) @@ -162,6 +200,85 @@ async def test_unpairs_a_device(zigbee): assert MOCK_IEEE not in app.devices +async def test_unpair_tolerates_a_record_without_its_node(zigbee): + controller, output, _repo, app = zigbee + discovery = await _discover(controller, output) + await controller.unpair(_draft(discovery)) # no ieee + assert conftest.MOCK_IEEE in app.devices + + +async def test_a_pairing_that_failed_halfway_is_retried_from_the_same_discovery(zigbee, monkeypatch): + controller, output, repository, app = zigbee + discovery = await _discover(controller, output) + + async def fail(*_args, **_kwargs): + raise RuntimeError("boom") + + with monkeypatch.context() as patched: + patched.setattr(controller, "_subscribe", fail) + with pytest.raises(RuntimeError): + await controller.pair_device(discovery, draft := _draft(discovery), None) + await controller.unpair(draft) # the Hub's rollback + await controller.unpair(draft) # and again: nothing more + + assert conftest.MOCK_IEEE in app.devices # nothing undone: it stays joined + assert controller.discoveries.keys() == {discovery.id} + device = await _pair_as_the_hub(controller, output, repository, controller.discoveries[discovery.id]) + assert device.parameters and discovery.id in controller._connected_devices + assert controller.discoveries == {} + + +async def test_a_pairing_the_hub_never_saved_is_retried_from_the_same_discovery(zigbee): + controller, output, repository, app = zigbee + discovery = await _discover(controller, output) + await controller.unpair(await controller.pair_device(discovery, _draft(discovery), None)) + # the Hub failed to save it, and rolled it back: the node stays joined + + device = await _pair_as_the_hub(controller, output, repository, controller.discoveries[discovery.id]) + + assert device.physical_id == discovery.id and discovery.id in controller._connected_devices + assert controller.discoveries == {} and conftest.MOCK_IEEE in app.devices + output.events.clear() + _flip_the_switch(app) + await asyncio.sleep(0.05) + assert len(output.events) == 1 # subscribed once + + +async def test_fetch_resubscribes_only_when_the_subscription_is_gone(zigbee, monkeypatch): + controller, output, repository, app = zigbee + discovery = await _pair(zigbee) + device = await _device(repository, discovery.id) + subscribe = AsyncMock(wraps=controller._subscribe) + monkeypatch.setattr(controller, "_subscribe", subscribe) + + await controller.fetch(device) + await controller.fetch(device) + subscribe.assert_not_awaited() # nothing lost: no second subscription + + controller._subscriptions.pop(discovery.id) # as after a rebuilt device + await controller.fetch(device) + subscribe.assert_awaited_once() + await controller.fetch(device) + subscribe.assert_awaited_once() + + +async def test_fetch_of_a_sleeping_device_is_not_a_failure(zigbee, monkeypatch): + controller, output, repository, _app = zigbee + discovery = await _pair(zigbee) + device = await _device(repository, discovery.id) + + async def asleep(*_args, **_kwargs): + raise TimeoutError + + monkeypatch.setattr(zigpy.zcl.Cluster, "read_attributes", asleep) + output.events.clear() + await controller.fetch(device) + on_off = controller._mapper.attribute_parameter_uuid( + discovery.id, 1, OnOff.cluster_id, OnOff.AttributeDefs.on_off.id + ) + assert on_off not in {event.parameter_id for event in output.events} # no None over the last known value + + async def _restart_with_the_device_last_seen(zigbee, monkeypatch, hours_ago: float | None, *, mains: bool = False): """Pairs the mock device, then starts Zigbee again on a network whose database says when it last heard from it.""" controller, output, _repo, _app = zigbee @@ -216,7 +333,7 @@ async def test_a_freshly_paired_devices_reports_reach_the_hub(zigbee): output.events.clear() _flip_the_switch(app) await wait_for(lambda: bool(output.events)) - assert [event.device_id for event in output.events] == [discovery.id] + assert [event.physical_id for event in output.events] == [discovery.id] async def test_a_report_reaches_the_hub_once_however_often_the_device_rejoined(zigbee): @@ -237,8 +354,7 @@ async def test_a_discovery_is_paired_as_zigpy_last_built_it(zigbee): discovery = await _discover(controller, output) rebuilt = conftest._make_mock_zb_device(app) # interviewed again, and built anew (as with a quirk) controller.device_initialized(rebuilt) - await _seed_provisional(repository, discovery) - await controller.pair_device(discovery, None) + await _pair_as_the_hub(controller, output, repository, discovery) assert controller._connected_devices[discovery.id] is rebuilt @@ -322,7 +438,7 @@ async def _send_move(zigbee, value_by_field: dict[str, Any]) -> Any: command_mock.reset_mock() await controller.send_command( - DeviceCommand(device_id=discovery.id, parameter_id=UUID(param_id), value=value_by_field), device, parameter + DeviceCommand(device_id=device.id, parameter_id=UUID(param_id), value=value_by_field), device, parameter ) command_mock.assert_awaited_once() @@ -383,7 +499,7 @@ async def test_main_command_with_arguments_is_a_struct_button(zigbee, monkeypatc command_mock = cast(AsyncMock, zigpy.zcl.Cluster.command) command_mock.reset_mock() await controller.send_command( - DeviceCommand(device_id=discovery.id, parameter_id=UUID(param_id), value=cycle[0]), device, main + DeviceCommand(device_id=device.id, parameter_id=UUID(param_id), value=cycle[0]), device, main ) call = command_mock.await_args assert call is not None and call.args == (command_id,) and call.kwargs == expected @@ -412,7 +528,7 @@ async def test_attribute_enum_valid_values_map_value_to_label(zigbee, monkeypatc write_mock = cast(AsyncMock, zigpy.zcl.Cluster.write_attributes) write_mock.reset_mock() await controller.send_command( - DeviceCommand(device_id=discovery.id, parameter_id=UUID(param_id), value=Fan.FanMode.On.value), + DeviceCommand(device_id=device.id, parameter_id=UUID(param_id), value=Fan.FanMode.On.value), device, fan_mode, ) @@ -446,7 +562,7 @@ async def test_ts0001_exposes_only_supported_clusters(zigbee, monkeypatch): await wait_for(lambda: bool(output.events)) # the background fetch after pairing device = await _device(repository, discovery.id) async with repository.session() as repo: - parameters = (await repo.state(discovery.id, as_=ZBDeviceState)).parameters + parameters = (await repo.state(physical_id=discovery.id, as_=ZBDeviceState)).parameters clusters = {p.integration_data.cluster_id for p in parameters} # unimplemented clusters expose nothing, client-side (output) clusters have no attributes to read, @@ -462,7 +578,7 @@ async def test_ts0001_exposes_only_supported_clusters(zigbee, monkeypatch): assert {on_off_id, toggle_id} <= {str(p.id) for p in parameters} toggle = await _param(repository, discovery.id, toggle_id) await controller.send_command( - DeviceCommand(device_id=discovery.id, parameter_id=UUID(toggle_id), value=None), device, toggle + DeviceCommand(device_id=device.id, parameter_id=UUID(toggle_id), value=None), device, toggle )