Skip to content

Commit 9da440a

Browse files
julienldjulienld
andauthored
fix: align add-on schema with HA Supervisor (#33)
Co-authored-by: julienld <julien@LAPTOP.localdomain>
1 parent 74f171a commit 9da440a

6 files changed

Lines changed: 22 additions & 24 deletions

File tree

homeassistant-addon/config.yaml

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,9 @@ image: "ghcr.io/homeassistant-ai/ha-mcp-addon-{arch}"
2323
# Options for user configuration
2424
options:
2525
backup_hint: "normal"
26-
secret_path: ""
2726
schema:
28-
backup_hint:
29-
required: false
30-
advanced: true
31-
default: "normal"
32-
description: "Controls when backups are suggested before operations."
33-
options:
34-
- "strong"
35-
- "normal"
36-
- "weak"
37-
- "auto"
38-
secret_path:
39-
required: false
40-
advanced: true
41-
description: "Custom secret path (overrides auto-generated). Leave empty for auto-generation."
27+
backup_hint: list(strong|normal|weak|auto)
28+
secret_path: str?
4229
# Add-on exposes HTTP port for MCP communication (fixed internal port)
4330
ports:
4431
9583/tcp: 9583

homeassistant-addon/start.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ def get_or_create_secret_path(data_dir: Path, custom_path: str = "") -> str:
6161

6262
# Generate new secret path
6363
new_path = generate_secret_path()
64+
log_info("Generated new secret path with 128-bit entropy")
6465
try:
6566
data_dir.mkdir(parents=True, exist_ok=True)
6667
secret_file.write_text(new_path)
67-
log_info(f"Generated new secret path with 128-bit entropy")
6868
return new_path
6969
except Exception as e:
7070
log_error(f"Failed to save secret path: {e}")
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
configuration:
3+
backup_hint:
4+
name: Backup hint
5+
description: Controls when backup reminders are shown before risky operations.
6+
secret_path:
7+
name: Secret path override
8+
description: |
9+
Optional custom HTTP path for the MCP server. Leave empty to use the auto-generated secure path.

pyproject.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,8 @@ ha-mcp = "ha_mcp.__main__:main"
6161
hamcp-test-env = "tests.test_env_manager:main"
6262

6363
[tool.setuptools]
64-
packages = ["ha_mcp"]
65-
66-
[tool.setuptools.package-dir]
67-
ha_mcp = "src/ha_mcp"
64+
package-dir = {"" = "src"}
65+
packages = { find = { where = ["src"], include = ["ha_mcp*"] } }
6866

6967
[tool.setuptools.package-data]
7068
ha_mcp = ["py.typed"]

tests/addon/test_addon_structure.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,18 @@ def test_config_yaml_valid(self):
5858
assert "ports" in config, "ports section required for HTTP transport"
5959
assert "9583/tcp" in config["ports"], "port 9583/tcp must be exposed"
6060

61-
# Verify secret_path configuration (advanced option for custom overrides)
62-
assert "secret_path" in config["options"], "options must include secret_path field"
63-
assert config["options"]["secret_path"] == "", "default secret_path should be empty (auto-generate)"
61+
# Verify secret_path configuration (optional advanced override)
62+
assert "secret_path" not in config["options"], \
63+
"secret_path should be optional and omitted so Supervisor treats it as advanced"
6464
assert "secret_path" in config["schema"], "schema must include secret_path field"
65+
assert config["schema"]["secret_path"] == "str?", \
66+
"secret_path schema should be optional string (str?)"
6567

6668
# Verify backup_hint configuration
6769
assert "backup_hint" in config["options"], "options must include backup_hint field"
6870
assert config["options"]["backup_hint"] == "normal", "default backup_hint should be normal"
71+
assert config["schema"]["backup_hint"] == "list(strong|normal|weak|auto)", \
72+
"backup_hint schema must enumerate allowed values"
6973

7074
# Verify architectures (only 64-bit platforms supported by uv image)
7175
expected_archs = ["amd64", "aarch64"]

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)