Problem
Opening the device log (A) on a Zigbee/deconz device — say a wireless button — only ever shows
its entities' state changes. Home Assistant's own device page shows more: button presses, pings,
automation triggers fired by that device. hatty's device log is missing exactly the events that
make it useful for battery-powered sensors and buttons, which often have no state-bearing entity
at all for "someone just pressed this."
Root cause
HAClient.fetch_logbook (client.py:268-282) fetches over REST:
GET /api/logbook/{start}?entity=<csv>&end_time=<iso>.
Home Assistant's REST logbook view (homeassistant/components/logbook/rest_api.py) accepts
only period, entity, end_time, context_id — there is no device filter on this endpoint
at all. Device-scoped events (e.g. zha_event) carry a device_id in their event data and have
no entity_id, so they can never match an entity= filter, no matter what's passed.
(Ironically, before #13 fixed entity_id → entity, the filter was silently ignored by HA and
the whole-instance logbook came back — which is why these events used to appear, by accident.)
Only the websocket commands accept device ids:
# logbook/websocket_api.py
{"type": "logbook/get_events", "start_time": ..., "end_time": ...,
"entity_ids": [...], "device_ids": [...], "context_id": ...}
{"type": "logbook/event_stream", "start_time": ..., "end_time": ...,
"entity_ids": [...], "device_ids": [...]}
Home Assistant's own frontend device page (ha-config-device-page.ts) passes both:
<ha-logbook .entityIds=${this._entityIds(entities)} .deviceIds=${this._deviceIdInList(this.deviceId)} ...>
async_determine_event_types (logbook/helpers.py) confirms external events like zha_event are
only included in the result set when device_ids is supplied and the device's config-entry domain
is among the "interested domains" — passing device_ids is exactly what unlocks them.
Two response-shape differences to handle
The WS logbook/get_events handler builds its EventProcessor with
timestamp=True, include_entity_name=False, while the REST view uses the opposite
(timestamp=False, include_entity_name=True). So WS entries differ from what hatty renders today:
when is a float epoch, not an ISO string.
- State-change entries have no
name key — the caller must resolve display names itself.
External/"describe" events (like zha_event) do carry name + message.
This will need a normalization layer so ActivityLogPanel and the fullscreen graph's event-mark
overlay (plot_render.render_event_marks, which calls datetime.fromisoformat on when today)
both keep working.
Depends on
#1 — fetching via WS and awaiting the response needs a request/response mechanism HAClient
doesn't have yet.
Refs #1
Problem
Opening the device log (
A) on a Zigbee/deconz device — say a wireless button — only ever showsits entities' state changes. Home Assistant's own device page shows more: button presses, pings,
automation triggers fired by that device. hatty's device log is missing exactly the events that
make it useful for battery-powered sensors and buttons, which often have no state-bearing entity
at all for "someone just pressed this."
Root cause
HAClient.fetch_logbook(client.py:268-282) fetches over REST:GET /api/logbook/{start}?entity=<csv>&end_time=<iso>.Home Assistant's REST logbook view (
homeassistant/components/logbook/rest_api.py) acceptsonly
period,entity,end_time,context_id— there is no device filter on this endpointat all. Device-scoped events (e.g.
zha_event) carry adevice_idin their event data and haveno
entity_id, so they can never match anentity=filter, no matter what's passed.(Ironically, before #13 fixed
entity_id→entity, the filter was silently ignored by HA andthe whole-instance logbook came back — which is why these events used to appear, by accident.)
Only the websocket commands accept device ids:
Home Assistant's own frontend device page (
ha-config-device-page.ts) passes both:async_determine_event_types(logbook/helpers.py) confirms external events likezha_eventareonly included in the result set when
device_idsis supplied and the device's config-entry domainis among the "interested domains" — passing
device_idsis exactly what unlocks them.Two response-shape differences to handle
The WS
logbook/get_eventshandler builds itsEventProcessorwithtimestamp=True, include_entity_name=False, while the REST view uses the opposite(
timestamp=False, include_entity_name=True). So WS entries differ from what hatty renders today:whenis a float epoch, not an ISO string.namekey — the caller must resolve display names itself.External/"describe" events (like
zha_event) do carryname+message.This will need a normalization layer so
ActivityLogPaneland the fullscreen graph's event-markoverlay (
plot_render.render_event_marks, which callsdatetime.fromisoformatonwhentoday)both keep working.
Depends on
#1 — fetching via WS and awaiting the response needs a request/response mechanism
HAClientdoesn't have yet.
Refs #1