ha_get_logbook
Retrieve Home Assistant logbook entries from a specified start time, with optional filtering by entity ID.
Instructions
Fetch logbook entries since an ISO time (optionally for an entity).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| since | Yes | ||
| end | No | ||
| entity_id | No |
Implementation Reference
- src/index.ts:181-191 (registration)Registration of the 'ha_get_logbook' tool with server.tool(), including name, description, schema (GetLogbookInput.shape), and the async handler that calls ha.getLogbook(input).
server.tool( 'ha_get_logbook', 'Fetch logbook entries since an ISO time (optionally for an entity).', GetLogbookInput.shape, async (input) => { const res = await ha.getLogbook(input) return { content: [{ type: 'text', text: JSON.stringify(res, null, 2) }], } }, ) - src/ha.ts:139-152 (handler)Implementation of getLogbook() method on the HomeAssistantClient class. Constructs query parameters (entity, end_time) and calls the Home Assistant REST API endpoint /api/logbook/{since}.
async getLogbook(params: { since: string end?: string entity_id?: string }) { const qs = new URLSearchParams() if (params.entity_id) qs.set('entity', params.entity_id) if (params.end) qs.set('end_time', params.end) const q = qs.toString() return await this.restRequest(`/api/logbook/${encodeURIComponent(params.since)}${q ? `?${q}` : ''}`) } - src/tools.ts:38-42 (schema)Zod schema definition for GetLogbookInput: requires 'since' (string), optional 'end' (string) and 'entity_id' (string).
export const GetLogbookInput = z.object({ since: z.string().min(1), end: z.string().min(1).optional(), entity_id: z.string().min(1).optional(), })