mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Fix ZHA events for logbook (#74245)
This commit is contained in:
parent
5fa3b90b2c
commit
8bcccb17f9
@ -62,14 +62,18 @@ def async_describe_events(
|
|||||||
break
|
break
|
||||||
|
|
||||||
if event_type is None:
|
if event_type is None:
|
||||||
event_type = event_data[ATTR_COMMAND]
|
event_type = event_data.get(ATTR_COMMAND, ZHA_EVENT)
|
||||||
|
|
||||||
if event_subtype is not None and event_subtype != event_type:
|
if event_subtype is not None and event_subtype != event_type:
|
||||||
event_type = f"{event_type} - {event_subtype}"
|
event_type = f"{event_type} - {event_subtype}"
|
||||||
|
|
||||||
event_type = event_type.replace("_", " ").title()
|
if event_type is not None:
|
||||||
|
event_type = event_type.replace("_", " ").title()
|
||||||
|
if "event" in event_type.lower():
|
||||||
|
message = f"{event_type} was fired"
|
||||||
|
else:
|
||||||
|
message = f"{event_type} event was fired"
|
||||||
|
|
||||||
message = f"{event_type} event was fired"
|
|
||||||
if event_data["params"]:
|
if event_data["params"]:
|
||||||
message = f"{message} with parameters: {event_data['params']}"
|
message = f"{message} with parameters: {event_data['params']}"
|
||||||
|
|
||||||
|
@ -172,6 +172,19 @@ async def test_zha_logbook_event_device_no_triggers(hass, mock_devices):
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
MockRow(
|
||||||
|
ZHA_EVENT,
|
||||||
|
{
|
||||||
|
CONF_DEVICE_ID: reg_device.id,
|
||||||
|
"device_ieee": str(ieee_address),
|
||||||
|
CONF_UNIQUE_ID: f"{str(ieee_address)}:1:0x0006",
|
||||||
|
"endpoint_id": 1,
|
||||||
|
"cluster_id": 6,
|
||||||
|
"params": {
|
||||||
|
"test": "test",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -182,6 +195,12 @@ async def test_zha_logbook_event_device_no_triggers(hass, mock_devices):
|
|||||||
== "Shake event was fired with parameters: {'test': 'test'}"
|
== "Shake event was fired with parameters: {'test': 'test'}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
assert events[1]["name"] == "FakeManufacturer FakeModel"
|
||||||
|
assert events[1]["domain"] == "zha"
|
||||||
|
assert (
|
||||||
|
events[1]["message"] == "Zha Event was fired with parameters: {'test': 'test'}"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
async def test_zha_logbook_event_device_no_device(hass, mock_devices):
|
async def test_zha_logbook_event_device_no_device(hass, mock_devices):
|
||||||
"""Test zha logbook events without device and without triggers."""
|
"""Test zha logbook events without device and without triggers."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user