mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Fix ZHA group creation (#69629)
This commit is contained in:
parent
be8e28503c
commit
74bec58bfa
@ -232,7 +232,7 @@ GROUP_MEMBER_SCHEMA = vol.All(
|
|||||||
vol.Schema(
|
vol.Schema(
|
||||||
{
|
{
|
||||||
vol.Required(ATTR_IEEE): IEEE_SCHEMA,
|
vol.Required(ATTR_IEEE): IEEE_SCHEMA,
|
||||||
vol.Required(ATTR_ENDPOINT_ID): int,
|
vol.Required(ATTR_ENDPOINT_ID): vol.Coerce(int),
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
_cv_group_member,
|
_cv_group_member,
|
||||||
@ -244,8 +244,8 @@ CLUSTER_BINDING_SCHEMA = vol.All(
|
|||||||
{
|
{
|
||||||
vol.Required(ATTR_NAME): cv.string,
|
vol.Required(ATTR_NAME): cv.string,
|
||||||
vol.Required(ATTR_TYPE): cv.string,
|
vol.Required(ATTR_TYPE): cv.string,
|
||||||
vol.Required(ATTR_ID): int,
|
vol.Required(ATTR_ID): vol.Coerce(int),
|
||||||
vol.Required(ATTR_ENDPOINT_ID): int,
|
vol.Required(ATTR_ENDPOINT_ID): vol.Coerce(int),
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
_cv_cluster_binding,
|
_cv_cluster_binding,
|
||||||
|
@ -661,7 +661,11 @@ class ZHADevice(LogMixin):
|
|||||||
async def async_add_to_group(self, group_id: int) -> None:
|
async def async_add_to_group(self, group_id: int) -> None:
|
||||||
"""Add this device to the provided zigbee group."""
|
"""Add this device to the provided zigbee group."""
|
||||||
try:
|
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:
|
except (zigpy.exceptions.ZigbeeException, asyncio.TimeoutError) as ex:
|
||||||
self.debug(
|
self.debug(
|
||||||
"Failed to add device '%s' to group: 0x%04x ex: %s",
|
"Failed to add device '%s' to group: 0x%04x ex: %s",
|
||||||
@ -687,7 +691,9 @@ class ZHADevice(LogMixin):
|
|||||||
) -> None:
|
) -> None:
|
||||||
"""Add the device endpoint to the provided zigbee group."""
|
"""Add the device endpoint to the provided zigbee group."""
|
||||||
try:
|
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:
|
except (zigpy.exceptions.ZigbeeException, asyncio.TimeoutError) as ex:
|
||||||
self.debug(
|
self.debug(
|
||||||
"Failed to add endpoint: %s for device: '%s' to group: 0x%04x ex: %s",
|
"Failed to add endpoint: %s for device: '%s' to group: 0x%04x ex: %s",
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import collections
|
|
||||||
import logging
|
import logging
|
||||||
from typing import TYPE_CHECKING, Any, NamedTuple
|
from typing import TYPE_CHECKING, Any, NamedTuple
|
||||||
|
|
||||||
@ -30,9 +29,12 @@ class GroupMember(NamedTuple):
|
|||||||
endpoint_id: int
|
endpoint_id: int
|
||||||
|
|
||||||
|
|
||||||
GroupEntityReference = collections.namedtuple(
|
class GroupEntityReference(NamedTuple):
|
||||||
"GroupEntityReference", "name original_name entity_id"
|
"""Reference to a group entity."""
|
||||||
)
|
|
||||||
|
name: str
|
||||||
|
original_name: str
|
||||||
|
entity_id: int
|
||||||
|
|
||||||
|
|
||||||
class ZHAGroupMember(LogMixin):
|
class ZHAGroupMember(LogMixin):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user