Fix ZHA device triggers (#92186)
* Fix missing endpoint data on ZHA events * revert to flat structure * update testpull/92090/head
parent
ebd9cd096a
commit
e6438dabff
|
@ -424,13 +424,13 @@ class ClusterHandler(LogMixin):
|
|||
else:
|
||||
raise TypeError(f"Unexpected zha_send_event {command!r} argument: {arg!r}")
|
||||
|
||||
self._endpoint.device.zha_send_event(
|
||||
self._endpoint.send_event(
|
||||
{
|
||||
ATTR_UNIQUE_ID: self.unique_id,
|
||||
ATTR_CLUSTER_ID: self.cluster.cluster_id,
|
||||
ATTR_COMMAND: command,
|
||||
# Maintain backwards compatibility with the old zigpy response format
|
||||
ATTR_ARGS: args, # type: ignore[dict-item]
|
||||
ATTR_ARGS: args,
|
||||
ATTR_PARAMS: params,
|
||||
}
|
||||
)
|
||||
|
|
|
@ -205,11 +205,13 @@ class Endpoint:
|
|||
|
||||
def send_event(self, signal: dict[str, Any]) -> None:
|
||||
"""Broadcast an event from this endpoint."""
|
||||
signal["endpoint"] = {
|
||||
"id": self.id,
|
||||
"unique_id": self.unique_id,
|
||||
self.device.zha_send_event(
|
||||
{
|
||||
const.ATTR_UNIQUE_ID: self.unique_id,
|
||||
const.ATTR_ENDPOINT_ID: self.id,
|
||||
**signal,
|
||||
}
|
||||
self.device.zha_send_event(signal)
|
||||
)
|
||||
|
||||
def claim_cluster_handlers(self, cluster_handlers: list[ClusterHandler]) -> None:
|
||||
"""Claim cluster handlers."""
|
||||
|
|
|
@ -9,6 +9,7 @@ import zigpy.zcl.clusters.general as general
|
|||
|
||||
import homeassistant.components.automation as automation
|
||||
from homeassistant.components.device_automation import DeviceAutomationType
|
||||
from homeassistant.components.zha.core.const import ATTR_ENDPOINT_ID
|
||||
from homeassistant.const import Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import device_registry as dr
|
||||
|
@ -190,7 +191,7 @@ async def test_if_fires_on_event(hass: HomeAssistant, mock_devices, calls) -> No
|
|||
zigpy_device.device_automation_triggers = {
|
||||
(SHAKEN, SHAKEN): {COMMAND: COMMAND_SHAKE},
|
||||
(DOUBLE_PRESS, DOUBLE_PRESS): {COMMAND: COMMAND_DOUBLE},
|
||||
(SHORT_PRESS, SHORT_PRESS): {COMMAND: COMMAND_SINGLE},
|
||||
(SHORT_PRESS, SHORT_PRESS): {COMMAND: COMMAND_SINGLE, ATTR_ENDPOINT_ID: 1},
|
||||
(LONG_PRESS, LONG_PRESS): {COMMAND: COMMAND_HOLD},
|
||||
(LONG_RELEASE, LONG_RELEASE): {COMMAND: COMMAND_HOLD},
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue