mirror of
https://github.com/home-assistant/core.git
synced 2025-07-11 15:27:08 +00:00
Fix ZHA device triggers (#92186)
* Fix missing endpoint data on ZHA events * revert to flat structure * update test
This commit is contained in:
parent
ebd9cd096a
commit
e6438dabff
@ -424,13 +424,13 @@ class ClusterHandler(LogMixin):
|
|||||||
else:
|
else:
|
||||||
raise TypeError(f"Unexpected zha_send_event {command!r} argument: {arg!r}")
|
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_UNIQUE_ID: self.unique_id,
|
||||||
ATTR_CLUSTER_ID: self.cluster.cluster_id,
|
ATTR_CLUSTER_ID: self.cluster.cluster_id,
|
||||||
ATTR_COMMAND: command,
|
ATTR_COMMAND: command,
|
||||||
# Maintain backwards compatibility with the old zigpy response format
|
# Maintain backwards compatibility with the old zigpy response format
|
||||||
ATTR_ARGS: args, # type: ignore[dict-item]
|
ATTR_ARGS: args,
|
||||||
ATTR_PARAMS: params,
|
ATTR_PARAMS: params,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -205,11 +205,13 @@ class Endpoint:
|
|||||||
|
|
||||||
def send_event(self, signal: dict[str, Any]) -> None:
|
def send_event(self, signal: dict[str, Any]) -> None:
|
||||||
"""Broadcast an event from this endpoint."""
|
"""Broadcast an event from this endpoint."""
|
||||||
signal["endpoint"] = {
|
self.device.zha_send_event(
|
||||||
"id": self.id,
|
{
|
||||||
"unique_id": self.unique_id,
|
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:
|
def claim_cluster_handlers(self, cluster_handlers: list[ClusterHandler]) -> None:
|
||||||
"""Claim cluster handlers."""
|
"""Claim cluster handlers."""
|
||||||
|
@ -9,6 +9,7 @@ import zigpy.zcl.clusters.general as general
|
|||||||
|
|
||||||
import homeassistant.components.automation as automation
|
import homeassistant.components.automation as automation
|
||||||
from homeassistant.components.device_automation import DeviceAutomationType
|
from homeassistant.components.device_automation import DeviceAutomationType
|
||||||
|
from homeassistant.components.zha.core.const import ATTR_ENDPOINT_ID
|
||||||
from homeassistant.const import Platform
|
from homeassistant.const import Platform
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import device_registry as dr
|
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 = {
|
zigpy_device.device_automation_triggers = {
|
||||||
(SHAKEN, SHAKEN): {COMMAND: COMMAND_SHAKE},
|
(SHAKEN, SHAKEN): {COMMAND: COMMAND_SHAKE},
|
||||||
(DOUBLE_PRESS, DOUBLE_PRESS): {COMMAND: COMMAND_DOUBLE},
|
(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_PRESS, LONG_PRESS): {COMMAND: COMMAND_HOLD},
|
||||||
(LONG_RELEASE, LONG_RELEASE): {COMMAND: COMMAND_HOLD},
|
(LONG_RELEASE, LONG_RELEASE): {COMMAND: COMMAND_HOLD},
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user