Fix bad conditional in ZHA logbook (#74277)
* Fix bad conditional in ZHA logbook * change syntax
This commit is contained in:
parent
b61530742e
commit
78e5296d07
2 changed files with 31 additions and 2 deletions
|
@ -74,8 +74,8 @@ def async_describe_events(
|
|||
else:
|
||||
message = f"{event_type} event was fired"
|
||||
|
||||
if event_data["params"]:
|
||||
message = f"{message} with parameters: {event_data['params']}"
|
||||
if params := event_data.get("params"):
|
||||
message = f"{message} with parameters: {params}"
|
||||
|
||||
return {
|
||||
LOGBOOK_ENTRY_NAME: device_name,
|
||||
|
|
|
@ -185,6 +185,27 @@ 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": {},
|
||||
},
|
||||
),
|
||||
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,
|
||||
},
|
||||
),
|
||||
],
|
||||
)
|
||||
|
||||
|
@ -201,6 +222,14 @@ async def test_zha_logbook_event_device_no_triggers(hass, mock_devices):
|
|||
events[1]["message"] == "Zha Event was fired with parameters: {'test': 'test'}"
|
||||
)
|
||||
|
||||
assert events[2]["name"] == "FakeManufacturer FakeModel"
|
||||
assert events[2]["domain"] == "zha"
|
||||
assert events[2]["message"] == "Zha Event was fired"
|
||||
|
||||
assert events[3]["name"] == "FakeManufacturer FakeModel"
|
||||
assert events[3]["domain"] == "zha"
|
||||
assert events[3]["message"] == "Zha Event was fired"
|
||||
|
||||
|
||||
async def test_zha_logbook_event_device_no_device(hass, mock_devices):
|
||||
"""Test zha logbook events without device and without triggers."""
|
||||
|
|
Loading…
Add table
Reference in a new issue