Homematic interface issue

Dear all,
thanks for the brilliant software.
I am using Home Assistant now for a while in connection to my Homegear gateway.
Connection is done via the homematic plugin.
From time to time it looses connection without any specific issue, all i can see is:
2017-05-21 20:53:59 ERROR (MainThread) [homeassistant.core] Error doing job: Fatal read error on socket transport
Traceback (most recent call last):
File “/usr/lib/python3.4/asyncio/selector_events.py”, line 582, in _read_ready
data = self._sock.recv(self.max_size)
OSError: [Errno 113] No route to host
2017-05-22 09:35:24 ERROR (MainThread) [homeassistant.core] Error doing job: Fatal read error on socket transport
Traceback (most recent call last):
File “/usr/lib/python3.4/asyncio/selector_events.py”, line 582, in _read_ready
data = self._sock.recv(self.max_size)
TimeoutError: [Errno 110] Connection timed out

Someelse a similar issue?

The problem probably is not directly related to HomeMatic. It’s just that the HomeMatic implementation doesn’t tolerate the error that’s happening. My focus currently is on the No route to host error you get, which is a pretty bad error. Could it be you’re using DHCP and the lease gets renewed from time to time, which then messes around with your network configuration?
If you’re using wifi it could also be that the wireless connection drops, and while the machine is trying to reconnect that effectively is also no route to the host (Homegear in this case).

The first error - no route to host could correlate with the renewal of the connection:
21.05.17 20:44:41 WLAN-Gerät angemeldet (2,4 GHz), 72 Mbit/s, myHomegear, IP 192.168.6.8, MAC
And you are right, my HW setup is a raspberry pi with wlan connection and dhcp

Interesting is, that home-assistant was still working after the first failure on 21.05 20:53
Later on, i received on homegear side following failure
05/21/17 21:43:45.607 Error in file RPC/RpcClient.cpp line 474 in function void Rpc::RpcClient::sendRequest(Rpc::RemoteRpcServer*, std::vector&, std::vector&, bool, bool&): Could not set socket options for server 127.0.0.1 on port 42887: Transport endpoint is not connected

which means, that home-assistant has closed the socket, or was not answering…
unfortunately there is nothing in any log for the given time.

I’m 100% certain, that the “WLAN-Gerät angemeldet…” is the source of the problem. The connection between HASS and Homegear can’t survive that, and there also is no nice workaround. Once the connection has dropped, you have to re-init the connection between HASS and Homegear. You can use the homematic.reconnect service to do that. But first you have to know that the connection has been dropped, and that’ not so easy to detect automatically.

If somehow possible, switch to a wired connection. If that’s not possible, at least use static IPs to ensure the downtime after the dropped Wi-Fi connection is as minimal as possible.

at the moment i am the trigger for the homematic.reconnect function :slight_smile:
homeassistant is not reporting the failure, so i guess there is no chance to automize the reconnect in home-assistant.
Homegear can detect the failure but not solve the problem.
But what comes to my mind - i can check from commandline the homegear log and/or the homegear cli, is there any chance to raise a homegear.reconnect from the commandline?

My personal opinion: you really shouldn’t try to work around the problem in that way. The No route to host error can lead to problems with other components in HASS as well, and for those you may not even have a service to reconnect and have to restart HASS completely to get it working again.
You should really focus on what is causing the dropped network connection. Working around the problem in that way is like cutting off your foot because you keep stepping on legos. :smiley:

ok, so lets try to solve it, but as i have three sons, i have a lot of experience with legos :slight_smile:

i need to use wlan, i have no lan cable in the near of my homegear/assistant box.
what i can do is to assign a fix ip address, is there anything else which comes to your mind?

Well, there’s no definite way of saying what’s causing the trouble. The static IP is a first step. If the issues continue, it could already help to relocate the machine to somewhere where the wifi reception is better.

ok, now with a static address i got only one issue over the last night and a no route to host in the morning

2017-05-22 18:16:58 ERROR (MainThread) [homeassistant.core] Error doing job: Fatal read error on socket transport
Traceback (most recent call last):
File “/usr/lib/python3.4/asyncio/selector_events.py”, line 582, in _read_ready
data = self._sock.recv(self.max_size)
TimeoutError: [Errno 110] Connection timed out
2017-05-23 08:17:00 ERROR (MainThread) [homeassistant.core] Error doing job: Fatal read error on socket transport
Traceback (most recent call last):
File “/usr/lib/python3.4/asyncio/selector_events.py”, line 582, in _read_ready
data = self._sock.recv(self.max_size)
OSError: [Errno 113] No route to host

half an hour later - in the fritzbox log:
23.05.17 08:54:14 WLAN-Gerät angemeldet (2,4 GHz), 72 Mbit/s, myHomegear,

but nothing in the syslog of the raspberry with home-assistant

seems i found it - i modified the /etc/network/interfaces to static ip address, but the dhcpcd was still requesting a lease and even worst, while there was a checkmark in the fritzbox to provide all time the same ip, the lease was only valid for 1 hour.

now, i set the static ip in /etc/dhcpcd.conf and removed the checkmark in the fritzbox for same ip all time.

will give an update after some day observation

Good you found that.
Besides that, I assume the myHomegear machine is a physically different machine. That’s the one that actually has lost the connection according to the log of your router. If there’s only Homegear running on that machine, then the HASS machine won’t notice any issues besides the dropped connection for HomeMatic.
The ideal setup would actually be to have Homegear and HASS running on the same machine and using 127.0.0.1 as the IP address. That would be the most stable way since the loopback-interface should never fail.

homegear and home-assistant are running on the same machine
my configuration.yaml has
homematic:
delay: 0.5
hosts:
rf:
ip: 127.0.0.1
port: 2002
resolvenames: metadata
primary: false
variables: false

home-assistant is using 2002 exclusively …

my /etc/network/interfaces regarding the lo device
auto lo
iface lo inet loopback

means, there should be no problem with the route to host?

Yes, if you are using 127.0.0.1, then the connection can’t really be be dropped. Even if your Wifi is disconnecting, 127.0.0.1 would be available. Which makes this even more confusing if you still get the dropping connections.
Although, the no route to host must have it’s source somewhere. It may not be the HomeMatic then, but something completely different your HASS machine want’s to talk to.

is there any way to get more debug details on it without opening debug for everything?

In the configuration.yaml you can configure logging the following way:

logger:
  logs:
    homeassistant.components.homematic: debug
    pyhomematic: debug

You can change the levels for pretty much anything that fits into that schema.

Hey trilu2000,

what’s been the outcome on your side?

I am experiencing the same issue and have a RaspberryPi/Fritzbox configuration as well…

Thanks

Unfortunately i still have issues with a closed or not working socket after a while.
It is working for a day or two and without any reason the socket is not responding and homegear closes the communication.
To overcome the issue and restart the socket i have wiritten a script which checks the socket and restarts if closed.

hass-socks.yaml (2.9 KB)

Datei ist natürlich keine yaml sondern ein py