mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
Add logbook support for args same as params for zha (#154997)
This commit is contained in:
@@ -79,6 +79,9 @@ def async_describe_events(
|
||||
if params := event_data.get("params"):
|
||||
message = f"{message} with parameters: {params}"
|
||||
|
||||
if args := event_data.get("args"):
|
||||
message = f"{message} with arguments: {args}"
|
||||
|
||||
return {
|
||||
LOGBOOK_ENTRY_NAME: device_name,
|
||||
LOGBOOK_ENTRY_MESSAGE: message,
|
||||
|
||||
@@ -32,6 +32,7 @@ COMMAND_SHAKE = "shake"
|
||||
COMMAND_HOLD = "hold"
|
||||
COMMAND_SINGLE = "single"
|
||||
COMMAND_DOUBLE = "double"
|
||||
COMMAND_ATTRIBUTE_UPDATED = "attribute_updated"
|
||||
DOUBLE_PRESS = "remote_button_double_press"
|
||||
SHORT_PRESS = "remote_button_short_press"
|
||||
LONG_PRESS = "remote_button_long_press"
|
||||
@@ -230,6 +231,22 @@ async def test_zha_logbook_event_device_no_triggers(
|
||||
"cluster_id": 6,
|
||||
},
|
||||
),
|
||||
MockRow(
|
||||
ZHA_EVENT,
|
||||
{
|
||||
CONF_DEVICE_ID: reg_device.id,
|
||||
COMMAND: COMMAND_ATTRIBUTE_UPDATED,
|
||||
"device_ieee": str(ieee_address),
|
||||
CONF_UNIQUE_ID: f"{ieee_address!s}:1:0x0006",
|
||||
"endpoint_id": 1,
|
||||
"cluster_id": 6,
|
||||
"args": {
|
||||
"attribute_id": 1234,
|
||||
"attribute_name": "name",
|
||||
"attribute_value": "value",
|
||||
},
|
||||
},
|
||||
),
|
||||
],
|
||||
)
|
||||
|
||||
@@ -254,6 +271,13 @@ async def test_zha_logbook_event_device_no_triggers(
|
||||
assert events[3]["domain"] == "zha"
|
||||
assert events[3]["message"] == "Zha Event was fired"
|
||||
|
||||
assert events[4]["name"] == "FakeManufacturer FakeModel"
|
||||
assert events[4]["domain"] == "zha"
|
||||
assert (
|
||||
events[4]["message"]
|
||||
== "Attribute Updated event was fired with arguments: {'attribute_id': 1234, 'attribute_name': 'name', 'attribute_value': 'value'}"
|
||||
)
|
||||
|
||||
|
||||
async def test_zha_logbook_event_device_no_device(
|
||||
hass: HomeAssistant, mock_devices
|
||||
|
||||
Reference in New Issue
Block a user