@@ -23,6 +23,51 @@ function Quote-BashArg {
2323$containerNameQ = Quote- BashArg - Value $ContainerName
2424$configPathQ = Quote- BashArg - Value $ConfigPath
2525
26+ $containerCheckScript = @'
27+ import asyncio
28+ import os
29+
30+ from homeassistant import bootstrap, core, loader
31+ from homeassistant.config_entries import ConfigEntries
32+ from homeassistant.helpers.check_config import async_check_ha_config_file
33+
34+ CONFIG_DIR = os.environ.get("CONFIG_DIR", "/config")
35+
36+
37+ async def main() -> int:
38+ hass = core.HomeAssistant(CONFIG_DIR)
39+ loader.async_setup(hass)
40+ hass.config_entries = ConfigEntries(hass, {})
41+
42+ ok = await bootstrap.async_load_base_functionality(hass)
43+ if not ok:
44+ print(f"Failed to initialize base functionality for {CONFIG_DIR}")
45+ await hass.async_stop(force=True)
46+ return 1
47+
48+ res = await async_check_ha_config_file(hass)
49+ await hass.async_stop(force=True)
50+
51+ print(f"Testing configuration at {CONFIG_DIR}")
52+ if res.errors:
53+ print("Failed config")
54+ for err in res.errors:
55+ print(f" {err.domain or 'error'}: {err.message}")
56+ return 1
57+
58+ print("Configuration valid")
59+ if res.warnings:
60+ print("Warnings:")
61+ for warn in res.warnings:
62+ print(f" {warn.domain or 'warning'}: {warn.message}")
63+ return 0
64+
65+
66+ raise SystemExit(asyncio.run(main()))
67+ '@
68+
69+ $containerCheckScript = ($containerCheckScript -replace " `r`n " , " `n " ).Trim()
70+
2671$containerCheck = @"
2772if ! command -v docker >/dev/null 2>&1; then
2873 echo Docker CLI not found on host. >&2
@@ -33,7 +78,7 @@ if ! docker ps --format '{{.Names}}' | grep -Fx $containerNameQ >/dev/null 2>&1;
3378 exit 1
3479fi
3580echo Running Home Assistant config check in container $containerNameQ ...
36- docker exec $containerNameQ python -m homeassistant --script check_config --config $configPathQ
81+ docker exec -i -e CONFIG_DIR= $configPathQ $containerNameQ python -
3782"@
3883
3984$supervisedCheck = @'
@@ -76,5 +121,11 @@ $sshArgs = @(
76121 (Quote- BashArg - Value $remoteCommand )
77122)
78123
79- & $ssh.Source @sshArgs
124+ $stdinPayload = if ($Mode -eq ' container' -or $Mode -eq ' auto' ) { $containerCheckScript } else { ' ' }
125+
126+ if ([string ]::IsNullOrEmpty($stdinPayload )) {
127+ & $ssh.Source @sshArgs
128+ } else {
129+ $stdinPayload | & $ssh.Source @sshArgs
130+ }
80131exit $LASTEXITCODE
0 commit comments