ilcato / homebridge-Fibaro-HC2

Homebridge plugin for Fibaro Home Center 2 (and Home Center Lite ...)
Apache License 2.0
66 stars 27 forks source link

Error getting data from Home Center: Error: connect ENETUNREACH #61

Closed vvsokolov closed 7 years ago

vvsokolov commented 7 years ago

There is always an error "[FibaroHC2] Error getting data from Home Center: Error: connect ENETUNREACH 192.168.xxx.xxx:80 " after the normal reboot of RaspberryPi (#shutdown -r now) or abnormal power off-on. But if I manually restart the service (systemctl restart homebridge) - homebridge-fibaro-hc2 starts normally. What could be the reason ?

ilcato commented 7 years ago

maybe the automatica startup is before the completion of the network setup? I do not use the systemctl stuff for automatica start.

vvsokolov commented 7 years ago

root@homekit:~#cat /etc/systemd/system/homebridge.service [Unit] Description=Node.js HomeKit Server After=syslog.target network-online.target

[Service] Type=simple User=homebridge EnvironmentFile=/etc/default/homebridge

ExecStart=/usr/bin/homebridge $HOMEBRIDGE_OPTS Restart=on-failure RestartSec=10 KillMode=process

[Install] WantedBy=multi-user.target

vvsokolov commented 7 years ago

I thought this is the best way to start the service automatically

ilcato commented 7 years ago

When did it stop working?

vvsokolov commented 7 years ago

After the last power-off

vvsokolov commented 7 years ago

Could you please add abnormal service termination on this error ? In this case systemd will detect, that "Unit homebridge.service entered failed state" and will restart it in "RestartSec=" seconds

vvsokolov commented 7 years ago

Yes. Reason is that Pi got ip-address after the home bridge start:

May 7 13:36:45 homekit homebridge[509]: [2017-05-07 13:36:45] [FibaroHC2] Server Listening... May 7 13:36:45 homekit homebridge[509]: [2017-05-07 13:36:45] Homebridge is running on port 51826. May 7 13:36:45 homekit homebridge[509]: [2017-05-07 13:36:45] [FibaroHC2] Error getting data from Home Center: Error: connect ENETUNREACH 192.168.xx.x:80 - Local (0.0.0.0:0) undefined May 7 13:36:47 homekit dhcpcd[448]: eth0: leased 192.168.xx.x for 600 seconds May 7 13:36:47 homekit dhcpcd[448]: eth0: adding route to 192.168.xx.0/24 May 7 13:36:47 homekit dhcpcd[448]: eth0: adding default route via 192.168.xx.1

vvsokolov commented 7 years ago

And after that the service simply "hangs", but the systemd "thinks" that everything is fine:

root@homekit:/var/log# systemctl status -l homebridge ● homebridge.service - Node.js HomeKit Server Loaded: loaded (/etc/systemd/system/homebridge.service; enabled) Active: active (running) since нд 2017-05-07 13:36:33 EEST; 12min ago Main PID: 509 (homebridge) CGroup: /system.slice/homebridge.service └─509 homebridge

тра 07 13:36:45 homekit homebridge[509]: [2017-05-07 13:36:45] [FibaroHC2] Configuring Accessory: t° Коридор тра 07 13:36:45 homekit homebridge[509]: [2017-05-07 13:36:45] [FibaroHC2] Configuring Accessory: Освещенность тра 07 13:36:45 homekit homebridge[509]: Scan this code with your HomeKit App on your iOS device to pair with Homebridge: тра 07 13:36:45 homekit homebridge[509]: Plugin - DidFinishLaunching тра 07 13:36:45 homekit homebridge[509]: [2017-05-07 13:36:45] [FibaroHC2] Server Listening... тра 07 13:36:45 homekit homebridge[509]: [2017-05-07 13:36:45] Homebridge is running on port 51826. тра 07 13:36:45 homekit homebridge[509]: [2017-05-07 13:36:45] [FibaroHC2] Error getting data from Home Center: Error: connect ENETUNREACH 192.168.xx.x:80 - Local (0.0.0.0:0) undefined

ilcato commented 7 years ago

https://www.freedesktop.org/wiki/Software/systemd/NetworkTarget/

vvsokolov commented 7 years ago
  1. "systemctl enable systemd-networkd-wait-online.service" was NOT resolved my issue. (I have "After=syslog.target network-online.target" in my /etc/systemd/system/homebridge.service
  2. I am convinced that the plugin should handle the error when the network is not available(unreachable), and abnormal terminate the process with an appropriate error message.
vvsokolov commented 7 years ago

I found the decigion: in /etc/network/interfaces must be: auto eth0 iface eth0 inet dhcp

network-online.target is aware of the interface eth0 now

Otherwise, eth0 was not registered to the daemons as an active ethernet device, despite it being perfectly happy receiving an IP address via DHCP.