#!/usr/bin/env bash set -euo pipefail fail() { printf 'Home Assistant helper contract: %s\n' "$1" >&2 exit 1 } project_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" helper="$project_root/config/dot/quickshell/scripts/panama-home-assistant" [[ -x "$helper" ]] || fail 'helper is missing or not executable' catalog="$($helper catalog)" jq -e ' .ok == true and .configured == true and .error == "" and (.entities | type == "array" and length > 0) and ([.entities[] | (keys | sort) == (["active", "available", "brightnessPct", "dimmable", "id", "sourceName", "state"] | sort)] | all) and ([.entities[] | (.id | startswith("light.")) and (.brightnessPct >= 0 and .brightnessPct <= 100)] | all) and (.legacyEntityIds | type == "array") ' <<<"$catalog" >/dev/null || fail 'live catalog shape is invalid' printf 'Home Assistant helper contract: PASS (configured=true, %s lights; contents redacted)\n' \ "$(jq '.entities | length' <<<"$catalog")"