lazcad / homeassistant

Home Assistant Development
249 stars 83 forks source link

Can only connect to gateway after power cycle. #58

Closed niai closed 7 years ago

niai commented 7 years ago

Hi i can get the gateway to connect after a power cycle I can seen all my sensors read the temps, button presses etc, but after about 2 mins they will stop updating I can't turn on the gateways light it's as if its not connected. This error is thrown if I have

xiaomi:
  gateways:
    - sid: [MAC all lowercase no :]
      key: [key from the app on android]

and i have not power cycled

The following errors have been logged this session:

2017-05-31 02:45:23 WARNING (MainThread) [homeassistant.setup] Setup of xiaomi is taking over 10 seconds.
2017-05-31 02:45:28 ERROR (Thread-1) [custom_components.xiaomi] No gateway discovered
2017-05-31 02:45:28 ERROR (MainThread) [homeassistant.setup] Setup failed for xiaomi: Component failed to initiali
Jun 04 00:18:44 hassbian hass[735]: 2017-06-04 00:18:44 INFO (Thread-12) [custom_components.xiaomi] Gateway finding finished in 5 seconds
Jun 04 00:18:44 hassbian hass[735]: 2017-06-04 00:18:44 INFO (Thread-12) [custom_components.xiaomi] Discovering Xiaomi Gateways (Try 2)
Jun 04 00:18:49 hassbian hass[735]: 2017-06-04 00:18:49 WARNING (MainThread) [homeassistant.setup] Setup of xiaomi is taking over 10 seconds.
Jun 04 00:18:49 hassbian hass[735]: 2017-06-04 00:18:49 INFO (Thread-12) [custom_components.xiaomi] Gateway finding finished in 5 seconds
Jun 04 00:18:49 hassbian hass[735]: 2017-06-04 00:18:49 INFO (Thread-12) [custom_components.xiaomi] Discovering Xiaomi Gateways (Try 3)

If i power cycle and then restart HASS it works but after about 2 mins I get Jun 04 00:38:37 hassbian hass[735]: 2017-06-04 00:38:37 ERROR (Thread-11) [custom_components.xiaomi] Got error element in data {"error":"Invalid key"}

If I use this in my config

xiaomi:
  gateways:
    - sid: [MAC all lowercase no :]
      key: [key from the app on android]
  interface: [the gateways static ip]

then HASS throws this error

The following errors have been logged this session:

2017-06-03 17:52:29 ERROR (MainThread) [homeassistant.setup] Error during setup of component xiaomi
Traceback (most recent call last):
File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/setup.py", line 188, in asyncsetup_component
None, component.setup, hass, processed_config)
File "/usr/lib/python3.4/asyncio/futures.py", line 388, in iter
yield self # This tells Task to wait for completion.
File "/usr/lib/python3.4/asyncio/tasks.py", line 286, in _wakeup
value = future.result()
File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
raise self._exception
File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
result = self.fn(*self.args, **self.kwargs)
File "/home/homeassistant/.homeassistant/custom_components/xiaomi.py", line 75, in setup
PY_XIAOMI_GATEWAY = PyXiaomiGateway(hass, gateways, interface)
File "/home/homeassistant/.homeassistant/custom_components/xiaomi.py", line 178, in init
self._socket.bind((interface, 0))
OSError: [Errno 99] Cannot assign requested address

I have been trying for weeks to get this working and haven't really gotten anywhere I have tried with pycrypto and pycryptodome both installed in the virtual env.

Thank you if you can finally help me.

firmware 1.4.1_146.0141 Running Hassbian v1.23 python3 --version Python 3.4.2 for both pi and virtual env HASS version 0.46

niai commented 7 years ago

It seems the router that my ISP provided doesn't play well with the gateways multicast, and to top it off the "Don't support 3rd party modems", your allowed to use them, but they don't provide the settings to connect to the internet. Any way I it working now with a very janky solution using my spare DSL router as an access point.

It seems a lot of people having the problems I had is down to their router you may want to at a note to the readme.