diyhue / diyHue

Main diyHue software repo
https://diyhue.org/
Other
1.52k stars 274 forks source link

Home assistant connection gives AttributeError: 'NoneType' object has no attribute 'get_all_lights' #916

Open BoKKeR opened 1 year ago

BoKKeR commented 1 year ago

Issue does not already exist?

No, I did search

Select Environment

Docker

Home Assistant related?

Yes

Description

I setup a connection between HA using the local ip, token and port. When I scan the following error comes up, indicating an error not in the connection but in the underlying setup. Could this be because of the type of lights I use? Some of them only have on-off

Errorlog:

scan for light
2023-07-09 16:51:01,928 - werkzeug - INFO - 10.0.0.189 - - [09/Jul/2023 16:51:01] "POST /api/8ae152b61e5911eeae1c02420a000002/lights HTTP/1.1" 200 -
2023-07-09 16:51:03,172 - werkzeug - INFO - 10.0.0.189 - - [09/Jul/2023 16:51:03] "GET /lights HTTP/1.1" 200 -
2023-07-09 16:51:03,186 - services.stateFetch - INFO - start lights sync
2023-07-09 16:51:04,641 - werkzeug - INFO - 10.0.0.189 - - [09/Jul/2023 16:51:04] "GET /api/8ae152b61e5911eeae1c02420a000002/groups/0 HTTP/1.1" 200 -
2023-07-09 16:51:05,172 - werkzeug - INFO - 10.0.0.189 - - [09/Jul/2023 16:51:05] "GET /lights HTTP/1.1" 200 -
2023-07-09 16:51:06,875 - lights.discover - INFO - [
    "10.0.0.1:80",
    "10.0.0.30:80",
    "10.0.0.32:80",
    "10.0.0.49:80",
    "10.0.0.109:80",
    "10.0.0.195:80",
    "10.0.0.213:80",
    "10.0.0.248:80"
]
2023-07-09 16:51:06,875 - lights.protocols.mqtt - INFO - MQTT discovery called
2023-07-09 16:51:07,168 - werkzeug - INFO - 10.0.0.189 - - [09/Jul/2023 16:51:07] "GET /lights HTTP/1.1" 200 -
2023-07-09 16:51:08,266 - services.homeAssistantWS - WARNING - Home Assistant Web Socket Client disconnected trying to (re)connect
[Errno 113] No route to host
2023-07-09 16:51:08,266 - services.homeAssistantWS - INFO - HomeAssistant WebSocket discovery called
2023-07-09 16:51:09,164 - werkzeug - INFO - 10.0.0.189 - - [09/Jul/2023 16:51:09] "GET /lights HTTP/1.1" 200 -
2023-07-09 16:51:09,642 - werkzeug - INFO - 10.0.0.189 - - [09/Jul/2023 16:51:09] "GET /api/8ae152b61e5911eeae1c02420a000002/groups/0 HTTP/1.1" 200 -
2023-07-09 16:51:11,171 - werkzeug - INFO - 10.0.0.189 - - [09/Jul/2023 16:51:11] "GET /lights HTTP/1.1" 200 -
2023-07-09 16:51:11,338 - services.homeAssistantWS - ERROR - Error connecting to Home Assistant WebSocket
Traceback (most recent call last):
  File "/opt/hue-emulator/services/homeAssistantWS.py", line 232, in create_websocket_client
    homeassistant_ws_client.connect()
  File "/usr/local/lib/python3.9/dist-packages/ws4py/client/__init__.py", line 217, in connect
    self.sock.connect(self.bind_addr)
OSError: [Errno 113] No route to host
Exception in thread Thread-29:
Traceback (most recent call last):
  File "/usr/lib/python3.9/threading.py", line 954, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.9/threading.py", line 892, in run
    self._target(*self._args, **self._kwargs)
  File "/opt/hue-emulator/lights/discover.py", line 116, in scanForLights
    discover(detectedLights)
  File "/opt/hue-emulator/services/homeAssistantWS.py", line 268, in discover
    homeassistant_ws_client.get_all_lights()
AttributeError: 'NoneType' object has no attribute 'get_all_lights'
2023-07-09 16:51:13,174 - werkzeug - INFO - 10.0.0.189 - - [09/Jul/2023 16:51:13] "GET /lights HTTP/1.1" 200 -
2023-07-09 16:51:14,639 - werkzeug - INFO - 10.0.0.189 - - [09/Jul/2023 16:51:14] "GET /api/8ae152b61e5911eeae1c02420a000002/groups/0 HTTP/1.1" 200 -
2023-07-09 16:51:15,173 - werkzeug - INFO - 10.0.0.189 - - [09/Jul/2023 16:51:15] "GET /lights HTTP/1.1" 200 -
2023-07-09 16:51:16,237 - services.stateFetch - INFO - start lights sync

Steps to reproduce

Connect to DIYHUE to Home Assistant 2023.7.1 Run scan Check docker logs

Please enter your operating system details here

unraid 6.12.2

What DiyHue version(branch) are you using?

master (latest)

mariusmotea commented 1 year ago

"OSError: [Errno 113] No route to host" this means you specify an invalid address.

BoKKeR commented 1 year ago

Is there any other possibility, I am 100% sure that port/ip/ssl is right, I even tried the public ip, and got this error:

2023-07-17 21:03:43,016 - services.homeAssistantWS - ERROR - Error connecting to Home Assistant WebSocket
Traceback (most recent call last):
  File "/opt/hue-emulator/services/homeAssistantWS.py", line 232, in create_websocket_client
    homeassistant_ws_client.connect()
  File "/usr/local/lib/python3.9/dist-packages/ws4py/client/__init__.py", line 217, in connect
    self.sock.connect(self.bind_addr)
  File "/usr/lib/python3.9/ssl.py", line 1342, in connect
    self._real_connect(addr, False)
  File "/usr/lib/python3.9/ssl.py", line 1333, in _real_connect
    self.do_handshake()
  File "/usr/lib/python3.9/ssl.py", line 1309, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLError: [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1123)
Exception in thread Thread-28:
Traceback (most recent call last):
  File "/usr/lib/python3.9/threading.py", line 954, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.9/threading.py", line 892, in run
    self._target(*self._args, **self._kwargs)
  File "/opt/hue-emulator/lights/discover.py", line 116, in scanForLights
    discover(detectedLights)
  File "/opt/hue-emulator/services/homeAssistantWS.py", line 268, in discover
    homeassistant_ws_client.get_all_lights()
AttributeError: 'NoneType' object has no attribute 'get_all_lights'
mariusmotea commented 12 months ago

Now the error is different "ssl.SSLError: [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1123)"

You may try to connect using ssl on a non ssl port.