Hi everybody,
I hope that I overlook something. I use Home Assistant and Homegear, both dockerized. I “orchestrate” these containers by using docker-compose. I configured HA to connect to the Homegear RPC server by using this:
Unfortunately it is the case that Homegear starts up way slower than HA does and therefore HA tries to connect to Homegear and fails. It seems to me that HA does not try to connect to Homegear again, only if I restart HA. There is no easy way in Docker to let my HA container wait until Homegear container is ready, so the only viable option is that HA tries again to connect. The log entry:
2020-03-28 02:02:54 WARNING (SyncWorker_12) [pyhomematic._hm] Failed to initialize proxy
Hopefully I am wrong and I overlooked something. I can’t find a configuration parameter to specify connection retry. Can somebody help me with this issue?
The Homematic Integration unfortunately never tries to reconnect after failure or timeout. I simply added an Automation to call homematic.reconnect service 5mins after HA starts and every night at 4am
This is not a viable solution in my situation, since it would involve altering the Docker image and at least build it by myself. This is a thing that I want to avoid since I am using Docker because I don’t want to care about software updating.
There is no easy way in Docker to let my HA container wait until Homegear container is ready
Fast forward 3 years and there is a way for docker to start home assistant only after homegear finished it’s startup routine:
docker-compose.yml
services:
homegear:
# other config...
healthcheck:
test: ["CMD-SHELL", "wget --no-verbose --tries=1 --spider --post-data '{\"method\":\"getInstanceId\"}' http://localhost:2001/rpc.php || exit 1"] #Test, if the RPC server replies on port 2001, might need adjusting to the port you are using
start_period: 5m #Don't flag homegear as unhealthy in the first 5 minutes, even if health check fails
start_interval: 10s #During startup check every 10s if homegear is healthy yet
interval: 5m #If homegear is running check every 5 minutes if it is alive
homeassistant:
# other config...
depends_on:
homegear:
condition: service_healthy #Start home assistant when homegear is deamed healthy (it responds to RPC requests)
If this is a better solution for you depends on your needs.