One of the short comings of HomeKit is when it tells you something is offline it's 100% on you to fix it with very limited automation possiblities. In true Apple fashion the fix is typically super simple, restart a service somewhere and mdns will magically "fix it" and the device(s) will come online... until the next time it happens.
For me this is scrypted. It works 99.99% of the time, but every so often mdns goes wonky and i get a notice my doorbell is offline and i loose HomeKit recording until i restart scripted. Rinse, repeat until the next time it happens.
I recently ran into a mac app called homeclaw. No, not that one this one. It gives you scriptable command line access to HK devices and bridges you select, and it can be an MCP server too if you wish. There are a lot of possibilities with this app.
Of the possibilities the following command will use homeclaw to detect if a bridge and a device on the bridge is available. This can be scripted, habitat or any other HomeKit bridge or device. Launchd or crontab on a Mac (required) can be used to schedule it to run every few mins or as needed to poll the device for availability.
#!/bin/sh
vals=$(
/Applications/HomeClaw.app/Contents/MacOS/homeclaw-cli get "My Bridge" --json | jq -r '.reachable' && /Applications/HomeClaw.app/Contents/MacOS/homeclaw-cli get "My Device on My Bridge" --json | jq -r '.reachable, (.services[].characteristics[] | select(.name=="status_active") | .value)'
)
if echo "$vals" | grep -qxv 'true' >/dev/null; then
curl -X POST http://ipaddress:port/api/token
fi
Should the bridge/device become unavailable the curl command can be used to trigger the exported HomeKit Bridge mode switch to restart the integration or trigger an automation to do addition checks (like verify your AP is up) before restarting the needed service or device.
For whomever finds this useful, may it bring a little more stability to your HomeKit environment.