empty homekit config fixes

This commit is contained in:
Josh Hawkins 2026-01-14 07:35:43 -06:00
parent a6f8e1b9a9
commit 7bc2ef731b

View File

@ -69,15 +69,15 @@ function setup_homekit_config() {
local cleaned_json="/tmp/cache/homekit_cleaned.json" local cleaned_json="/tmp/cache/homekit_cleaned.json"
jq ' jq '
# Keep only the homekit section if it exists, otherwise empty object # Keep only the homekit section if it exists, otherwise empty object
if has("homekit") then {homekit: .homekit} else {homekit: {}} end if has("homekit") then {homekit: .homekit} else {} end
' "${temp_json}" > "${cleaned_json}" 2>/dev/null || { ' "${temp_json}" > "${cleaned_json}" 2>/dev/null || {
echo '{"homekit": {}}' > "${cleaned_json}" echo '{}' > "${cleaned_json}"
} }
# Convert back to YAML and write to the config file # Convert back to YAML and write to the config file
yq eval -P "${cleaned_json}" > "${config_path}" 2>/dev/null || { yq eval -P "${cleaned_json}" > "${config_path}" 2>/dev/null || {
echo "[WARNING] Failed to convert cleaned config to YAML, creating minimal config" echo "[WARNING] Failed to convert cleaned config to YAML, creating minimal config"
echo 'homekit: {}' > "${config_path}" echo '{}' > "${config_path}"
} }
# Clean up temp files # Clean up temp files