Skip to content

Commit aa07171

Browse files
committed
state is needed to calculate the icon on the frontend as well
1 parent 4d7e851 commit aa07171

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

homeassistant/components/logbook/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,7 @@ def humanify(hass, events, entity_attr_cache, context_lookup):
323323
entity_id, domain, event, entity_attr_cache
324324
),
325325
"domain": domain,
326+
"state": event.state,
326327
"entity_id": entity_id,
327328
}
328329

tests/components/logbook/test_init.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -2176,8 +2176,8 @@ async def test_logbook_invalid_entity(hass, hass_client):
21762176
assert response.status == 500
21772177

21782178

2179-
async def test_icons(hass, hass_client):
2180-
"""Test to ensure custom icons are returned."""
2179+
async def test_icon_and_state(hass, hass_client):
2180+
"""Test to ensure state and custom icons are returned."""
21812181
await hass.async_add_executor_job(init_recorder_component, hass)
21822182
await async_setup_component(hass, "logbook", {})
21832183
await hass.async_add_job(hass.data[recorder.DATA_INSTANCE].block_till_done)
@@ -2221,9 +2221,11 @@ async def test_icons(hass, hass_client):
22212221
assert response_json[1]["message"] == "turned on"
22222222
assert response_json[1]["entity_id"] == "light.kitchen"
22232223
assert response_json[1]["icon"] == "mdi:security"
2224+
assert response_json[1]["state"] == STATE_ON
22242225
assert response_json[2]["message"] == "turned off"
22252226
assert response_json[2]["entity_id"] == "light.kitchen"
22262227
assert response_json[2]["icon"] == "mdi:chemical-weapon"
2228+
assert response_json[2]["state"] == STATE_OFF
22272229

22282230

22292231
class MockLazyEventPartialState(ha.Event):

0 commit comments

Comments
 (0)