Home Assistant add-on that joins the instance to a Netmaker network via netclient. Distributed as a repository add-on using a prebuilt arm64 image (gitea.savant.io/homeassistant/netmaker) to avoid local buildx. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
30 lines
1.3 KiB
Plaintext
30 lines
1.3 KiB
Plaintext
#!/command/with-contenv bashio
|
|
# shellcheck shell=bash
|
|
export LOG_FD
|
|
# ==============================================================================
|
|
# Wait for the local network (default HA interface) to be ready
|
|
# ==============================================================================
|
|
|
|
readonly WAIT_DELAY=5 # 5s
|
|
readonly WAIT_COUNT=60 # 60*5s = 300s = 5m
|
|
|
|
declare wait_counter=0
|
|
|
|
# Some services need a working local network to function properly.
|
|
# They can mark this service as dependency, and wait for the successful startup.
|
|
|
|
# Until HA has no default interface, we wait a little
|
|
while ! bashio::api.supervisor GET "/network/interface/default/info" false &> /dev/null; do
|
|
if (( wait_counter++ == WAIT_COUNT )); then
|
|
# We emit only a warning to let the app start, maybe this is the only connection to access the device, better to start than not.
|
|
# Let netclient figure out a way to connect to the network if the local network is temporarily down.
|
|
bashio::log.warning "Local network (default Home Assistant interface) is unreachable"
|
|
break
|
|
fi
|
|
bashio::log.info "Waiting for the local network (default Home Assistant interface) to be ready..."
|
|
sleep $WAIT_DELAY
|
|
done
|
|
if (( wait_counter != 0 && wait_counter <= WAIT_COUNT )); then
|
|
bashio::log.info "Local network is ready"
|
|
fi
|