@orellbuehler/homeassistant-mcp 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/server.js CHANGED
@@ -10,7 +10,7 @@ import { registerEnergyTools } from "./tools/energy.js";
10
10
  import { registerTraceTools } from "./tools/trace.js";
11
11
  import { registerZhaTools } from "./tools/zha.js";
12
12
  export function createServer(client, wsClient) {
13
- const server = new McpServer({ name: "homeassistant-mcp", version: "0.5.0" });
13
+ const server = new McpServer({ name: "homeassistant-mcp", version: "0.5.1" });
14
14
  registerEntityTools(server, client);
15
15
  registerServiceTools(server, client);
16
16
  registerSystemTools(server, client);
package/dist/tools/zha.js CHANGED
@@ -1,5 +1,19 @@
1
1
  import { z } from "zod";
2
2
  import { ok, err } from "../hass/format.js";
3
+ // An entity_id can be listed either on the groupable endpoint itself or, on some
4
+ // HA versions where the endpoint list comes back empty/null, only under the
5
+ // device. Check both.
6
+ function endpointHasEntity(ep, entityId) {
7
+ const onEndpoint = ep.entities?.some((e) => e?.entity_id === entityId);
8
+ const onDevice = ep.device?.entities?.some((e) => e?.entity_id === entityId);
9
+ return Boolean(onEndpoint || onDevice);
10
+ }
11
+ function endpointEntityIds(ep) {
12
+ const refs = [...(ep.entities ?? []), ...(ep.device?.entities ?? [])];
13
+ return [
14
+ ...new Set(refs.filter((e) => !!e?.entity_id).map((e) => e.entity_id)),
15
+ ];
16
+ }
3
17
  const memberSchema = z.union([
4
18
  z.string(),
5
19
  z.object({
@@ -16,7 +30,7 @@ async function resolveMembers(ws, members) {
16
30
  return members.map((m) => {
17
31
  if (typeof m !== "string")
18
32
  return { ieee: m.ieee, endpoint_id: m.endpoint_id };
19
- const hit = groupable.find((ep) => ep.entities?.some((e) => e.entity_id === m));
33
+ const hit = groupable.find((ep) => endpointHasEntity(ep, m));
20
34
  if (!hit) {
21
35
  throw new Error(`'${m}' is not a groupable ZHA entity. A ZHA group member must be a ZHA entity on an endpoint that supports the Zigbee Groups cluster (see list_zha_groupable). Non-ZHA entities (Wi-Fi/Shelly/Hue-bridge/etc.) cannot join a ZHA group.`);
22
36
  }
@@ -39,7 +53,7 @@ export function registerZhaTools(server, ws) {
39
53
  ieee: ep.device?.ieee ?? null,
40
54
  endpoint_id: ep.endpoint_id,
41
55
  device_name: ep.device?.user_given_name ?? ep.device?.name ?? null,
42
- entities: (ep.entities ?? []).map((e) => e.entity_id),
56
+ entities: endpointEntityIds(ep),
43
57
  }));
44
58
  return ok({ count: endpoints.length, endpoints });
45
59
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orellbuehler/homeassistant-mcp",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "Model Context Protocol server for Home Assistant: introspect entities, services, events, registries, render templates and validate configuration to help AI agents author HA configs and automations.",
5
5
  "type": "module",
6
6
  "bin": {