Skip to content

Commit ab879c0

Browse files
authored
Add logbook support for args same as params for zha (home-assistant#154997)
1 parent 488c975 commit ab879c0

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

homeassistant/components/zha/logbook.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ def async_describe_zha_event(event: Event) -> dict[str, str]:
7979
if params := event_data.get("params"):
8080
message = f"{message} with parameters: {params}"
8181

82+
if args := event_data.get("args"):
83+
message = f"{message} with arguments: {args}"
84+
8285
return {
8386
LOGBOOK_ENTRY_NAME: device_name,
8487
LOGBOOK_ENTRY_MESSAGE: message,

tests/components/zha/test_logbook.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
COMMAND_HOLD = "hold"
3333
COMMAND_SINGLE = "single"
3434
COMMAND_DOUBLE = "double"
35+
COMMAND_ATTRIBUTE_UPDATED = "attribute_updated"
3536
DOUBLE_PRESS = "remote_button_double_press"
3637
SHORT_PRESS = "remote_button_short_press"
3738
LONG_PRESS = "remote_button_long_press"
@@ -230,6 +231,22 @@ async def test_zha_logbook_event_device_no_triggers(
230231
"cluster_id": 6,
231232
},
232233
),
234+
MockRow(
235+
ZHA_EVENT,
236+
{
237+
CONF_DEVICE_ID: reg_device.id,
238+
COMMAND: COMMAND_ATTRIBUTE_UPDATED,
239+
"device_ieee": str(ieee_address),
240+
CONF_UNIQUE_ID: f"{ieee_address!s}:1:0x0006",
241+
"endpoint_id": 1,
242+
"cluster_id": 6,
243+
"args": {
244+
"attribute_id": 1234,
245+
"attribute_name": "name",
246+
"attribute_value": "value",
247+
},
248+
},
249+
),
233250
],
234251
)
235252

@@ -254,6 +271,13 @@ async def test_zha_logbook_event_device_no_triggers(
254271
assert events[3]["domain"] == "zha"
255272
assert events[3]["message"] == "Zha Event was fired"
256273

274+
assert events[4]["name"] == "FakeManufacturer FakeModel"
275+
assert events[4]["domain"] == "zha"
276+
assert (
277+
events[4]["message"]
278+
== "Attribute Updated event was fired with arguments: {'attribute_id': 1234, 'attribute_name': 'name', 'attribute_value': 'value'}"
279+
)
280+
257281

258282
async def test_zha_logbook_event_device_no_device(
259283
hass: HomeAssistant, mock_devices

0 commit comments

Comments
 (0)