mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-01-22 20:18:30 +03:00
Improve handling of homekit config
This commit is contained in:
parent
dd1297b66b
commit
67b40d3e04
@ -55,7 +55,7 @@ function setup_homekit_config() {
|
|||||||
|
|
||||||
if [[ ! -f "${config_path}" ]]; then
|
if [[ ! -f "${config_path}" ]]; then
|
||||||
echo "[INFO] Creating empty HomeKit config file..."
|
echo "[INFO] Creating empty HomeKit config file..."
|
||||||
echo '{}' > "${config_path}"
|
echo 'homekit: {}' > "${config_path}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Convert YAML to JSON for jq processing
|
# Convert YAML to JSON for jq processing
|
||||||
@ -70,12 +70,14 @@ function setup_homekit_config() {
|
|||||||
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 {homekit: {}} end
|
||||||
' "${temp_json}" > "${cleaned_json}" 2>/dev/null || echo '{"homekit": {}}' > "${cleaned_json}"
|
' "${temp_json}" > "${cleaned_json}" 2>/dev/null || {
|
||||||
|
echo '{"homekit": {}}' > "${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 'homekit: {}' > "${config_path}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Clean up temp files
|
# Clean up temp files
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user