Fix ZHA group creation (#69629)
parent
3dd0ddb73e
commit
88a081be24
|
@ -232,7 +232,7 @@ GROUP_MEMBER_SCHEMA = vol.All(
|
|||
vol.Schema(
|
||||
{
|
||||
vol.Required(ATTR_IEEE): IEEE_SCHEMA,
|
||||
vol.Required(ATTR_ENDPOINT_ID): int,
|
||||
vol.Required(ATTR_ENDPOINT_ID): vol.Coerce(int),
|
||||
}
|
||||
),
|
||||
_cv_group_member,
|
||||
|
@ -244,8 +244,8 @@ CLUSTER_BINDING_SCHEMA = vol.All(
|
|||
{
|
||||
vol.Required(ATTR_NAME): cv.string,
|
||||
vol.Required(ATTR_TYPE): cv.string,
|
||||
vol.Required(ATTR_ID): int,
|
||||
vol.Required(ATTR_ENDPOINT_ID): int,
|
||||
vol.Required(ATTR_ID): vol.Coerce(int),
|
||||
vol.Required(ATTR_ENDPOINT_ID): vol.Coerce(int),
|
||||
}
|
||||
),
|
||||
_cv_cluster_binding,
|
||||
|
|
|
@ -661,7 +661,11 @@ class ZHADevice(LogMixin):
|
|||
async def async_add_to_group(self, group_id: int) -> None:
|
||||
"""Add this device to the provided zigbee group."""
|
||||
try:
|
||||
await self._zigpy_device.add_to_group(group_id)
|
||||
# A group name is required. However, the spec also explicitly states that
|
||||
# the group name can be ignored by the receiving device if a device cannot
|
||||
# store it, so we cannot rely on it existing after being written. This is
|
||||
# only done to make the ZCL command valid.
|
||||
await self._zigpy_device.add_to_group(group_id, name=f"0x{group_id:04X}")
|
||||
except (zigpy.exceptions.ZigbeeException, asyncio.TimeoutError) as ex:
|
||||
self.debug(
|
||||
"Failed to add device '%s' to group: 0x%04x ex: %s",
|
||||
|
@ -687,7 +691,9 @@ class ZHADevice(LogMixin):
|
|||
) -> None:
|
||||
"""Add the device endpoint to the provided zigbee group."""
|
||||
try:
|
||||
await self._zigpy_device.endpoints[endpoint_id].add_to_group(group_id)
|
||||
await self._zigpy_device.endpoints[endpoint_id].add_to_group(
|
||||
group_id, name=f"0x{group_id:04X}"
|
||||
)
|
||||
except (zigpy.exceptions.ZigbeeException, asyncio.TimeoutError) as ex:
|
||||
self.debug(
|
||||
"Failed to add endpoint: %s for device: '%s' to group: 0x%04x ex: %s",
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import collections
|
||||
import logging
|
||||
from typing import TYPE_CHECKING, Any, NamedTuple
|
||||
|
||||
|
@ -30,9 +29,12 @@ class GroupMember(NamedTuple):
|
|||
endpoint_id: int
|
||||
|
||||
|
||||
GroupEntityReference = collections.namedtuple(
|
||||
"GroupEntityReference", "name original_name entity_id"
|
||||
)
|
||||
class GroupEntityReference(NamedTuple):
|
||||
"""Reference to a group entity."""
|
||||
|
||||
name: str
|
||||
original_name: str
|
||||
entity_id: int
|
||||
|
||||
|
||||
class ZHAGroupMember(LogMixin):
|
||||
|
|
Loading…
Reference in New Issue