diyhue / hassio-addon

33 stars 11 forks source link

Hue Essentials wants to link, displays "Bridge is not reachable" for a split second #9

Closed EpicLPer closed 1 year ago

EpicLPer commented 1 year ago

When trying to connect via Hue Essentials to the Bridge it does correctly ask for pressing the Link button, after doing so it almost instantly, for a split second, shows a message along the lines of "Bridge is not reachable" and to check my network, then boots me back to the Link screen and indefinitely stays there.

Is there any way I can provide better logs for you to check this?

mariusmotea commented 1 year ago

Probably you have a complicated setup with multiple interfaces or docker running with wrong env variables (most likely IP env in bridge network mode)

EpicLPer commented 1 year ago

Probably you have a complicated setup with multiple interfaces or docker running with wrong env variables (most likely IP env in bridge network mode)

I'm simply running the Hass AddOn and configuring that one.

mariusmotea commented 1 year ago

You enabled host network mode?

EpicLPer commented 1 year ago

I'm using the HassOS VM on ESXi, I'm not running Hass inside a Docker environment.

mariusmotea commented 1 year ago

Diyhue need to know the IP of the host since in the pair process it provide this ip to the application and future requests are made to that ip. In diyhue docker version there are two ways to meet this requirement. One is to run diyhue in host network mode and the IP will be automatically detected, or to provide the IP in env variable.

EpicLPer commented 1 year ago

The AddOn does correctly detect the Host-IP tho in the logs: Using Host 10.0.0.234:80

mariusmotea commented 1 year ago

Can you show diyhue container logs during pair process?

EpicLPer commented 1 year ago

Trying to gather the debug version of this log is a bit of a nightmare since it moves so fast, but I doubt this log alone is enough:

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 00-banner.sh: executing... 
-----------------------------------------------------------
 Add-on: diyHue
 Emulate a Hue Bridge, add lights, sensors etc. from different vendors into one Ecosystem
-----------------------------------------------------------
 Add-on version: 2.0.4
 You are running the latest version of this add-on.
 System: Home Assistant OS 8.2  (amd64 / qemux86-64)
 Home Assistant Core: 2022.7.6
 Home Assistant Supervisor: 2022.07.0
-----------------------------------------------------------
 Please, share the above information when looking for help
 or support in, e.g., GitHub, forums or the Discord chat.
-----------------------------------------------------------
[cont-init.d] 00-banner.sh: exited 0.
[cont-init.d] 01-log-level.sh: executing... 
[cont-init.d] 01-log-level.sh: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
/config/diyhue exists.
Your Architecture is = amd64
No serve HTTPS
2022-07-23 16:10:31,431 - configManager.argumentHandler - INFO - Using Host 10.0.0.234:80
2022-07-23 16:10:31,432 - configManager.argumentHandler - INFO - Host MAC given as redacted
2022-07-23 16:10:31,433 - configManager.argumentHandler - INFO - IP range for light discovery: 0-255
2022-07-23 16:10:31,433 - configManager.argumentHandler - INFO - Deconz IP given as 10.0.0.15
2022-07-23 16:10:31,434 - configManager.argumentHandler - INFO - Online Discovery/Remote API Enabled!
2022-07-23 16:10:31,435 - configManager.argumentHandler - INFO - HTTPS Port Disabled
2022-07-23 16:10:31,446 - configManager.argumentHandler - INFO - Using Host 10.0.0.234:80
2022-07-23 16:10:31,446 - configManager.argumentHandler - INFO - Host MAC given as redacted
2022-07-23 16:10:31,447 - configManager.argumentHandler - INFO - IP range for light discovery: 0-255
2022-07-23 16:10:31,448 - configManager.argumentHandler - INFO - Deconz IP given as 10.0.0.15
2022-07-23 16:10:31,449 - configManager.argumentHandler - INFO - Online Discovery/Remote API Enabled!
2022-07-23 16:10:31,449 - configManager.argumentHandler - INFO - HTTPS Port Disabled
2022-07-23 16:10:31,455 - configManager.argumentHandler - INFO - Debug logging disabled!
2022-07-23 16:10:32,729 - configManager.configHandler - INFO - Config loaded
2022-07-23 16:10:33,095 - services.remoteDiscover - INFO - Starting discovery service
2022-07-23 16:10:33,111 - services.stateFetch - INFO - start lights sync
2022-07-23 16:10:33,129 - services.ssdp - INFO - starting ssdp...
2022-07-23 16:10:33,135 - services.ssdp - INFO - start ssdp broadcast
2022-07-23 16:10:33,138 - services.mdns - INFO - <MDNS> listener started
 * Serving Flask app 'HueEmulator3' (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
 * Running on all addresses.
   WARNING: This is a development server. Do not use it in a production deployment.
 * Running on http://10.0.0.234:80/ (Press CTRL+C to quit)
10.0.0.95 - - [23/Jul/2022 16:10:34] "GET /api/config HTTP/1.1" 200 -
10.0.0.134 - - [23/Jul/2022 16:10:34] "GET / HTTP/1.1" 200 -
10.0.0.134 - - [23/Jul/2022 16:10:34] "GET /static/css/3.482bc700.chunk.css HTTP/1.1" 304 -
10.0.0.134 - - [23/Jul/2022 16:10:34] "GET /static/css/main.bb68dc29.chunk.css HTTP/1.1" 304 -
10.0.0.134 - - [23/Jul/2022 16:10:34] "GET /static/js/3.7bf25959.chunk.js HTTP/1.1" 304 -
10.0.0.134 - - [23/Jul/2022 16:10:34] "GET /static/js/main.304c6128.chunk.js HTTP/1.1" 304 -
10.0.0.134 - - [23/Jul/2022 16:10:35] "GET /static/media/background.db8a83c2.jpg HTTP/1.1" 304 -
10.0.0.134 - - [23/Jul/2022 16:10:35] "GET /static/js/12.b22bce35.chunk.js HTTP/1.1" 304 -
10.0.0.134 - - [23/Jul/2022 16:10:35] "GET /get-key HTTP/1.1" 200 -
10.0.0.134 - - [23/Jul/2022 16:10:35] "GET /static/media/logo.bd3b4e90.svg HTTP/1.1" 304 -
10.0.0.134 - - [23/Jul/2022 16:10:35] "GET /static/favicon.ico HTTP/1.1" 304 -
10.0.0.134 - - [23/Jul/2022 16:10:35] "GET /api/keyredacted/groups/0 HTTP/1.1" 200 -
10.0.0.134 - - [23/Jul/2022 16:10:35] "GET /static/favicon.ico HTTP/1.1" 304 -
10.0.0.134 - - [23/Jul/2022 16:10:35] "GET /static/favicon-32x32.png HTTP/1.1" 304 -
2022-07-23 16:10:35,968 - services.deconz - INFO - {"config":{"battery":100,"duration":7,"on":true,"reachable":true},"e":"changed","id":"42","r":"sensors","t":"event","uniqueid":"00:15:8d:00:05:7b:3b:31-01-0406"}
2022-07-23 16:10:36,012 - services.deconz - INFO - {"config":{"battery":95,"duration":7,"on":true,"reachable":false},"e":"changed","id":"10","r":"sensors","t":"event","uniqueid":"00:15:8d:00:05:22:92:5c-01-0406"}
2022-07-23 16:10:36,048 - services.deconz - INFO - {"config":{"battery":100,"duration":7,"on":true,"reachable":true},"e":"changed","id":"32","r":"sensors","t":"event","uniqueid":"00:15:8d:00:05:2d:14:0d-01-0406"}
10.0.0.95 - - [23/Jul/2022 16:10:36] "POST /api/ HTTP/1.1" 200 -
10.0.0.95 - - [23/Jul/2022 16:10:37] "POST /api/ HTTP/1.1" 200 -
10.0.0.134 - - [23/Jul/2022 16:10:38] "PUT /api/keyredacted/config HTTP/1.1" 200 -
10.0.0.95 - - [23/Jul/2022 16:10:39] "POST /api/ HTTP/1.1" 200 -
2022-07-23 16:10:41,089 - services.deconz - INFO - {"config":{"battery":100,"duration":7,"on":true,"reachable":true},"e":"changed","id":"42","r":"sensors","t":"event","uniqueid":"00:15:8d:00:05:7b:3b:31-01-0406"}
2022-07-23 16:10:41,132 - services.deconz - INFO - {"config":{"battery":95,"duration":7,"on":true,"reachable":false},"e":"changed","id":"10","r":"sensors","t":"event","uniqueid":"00:15:8d:00:05:22:92:5c-01-0406"}
2022-07-23 16:10:41,175 - services.deconz - INFO - {"config":{"battery":100,"duration":7,"on":true,"reachable":true},"e":"changed","id":"32","r":"sensors","t":"event","uniqueid":"00:15:8d:00:05:2d:14:0d-01-0406"}
mariusmotea commented 1 year ago

This bring me some attention:

2022-07-23 16:10:31,449 - configManager.argumentHandler - INFO - HTTPS Port Disabled Very likely the Hue Essentials try to communicate on https since http is considered deprecated. Your phone ip is from 10.0.0.0 subnet ?

EpicLPer commented 1 year ago

That's a good point actually, I disabled it cause the Wiki said I should if I use SSL for my Home Assistant, but I only use SSL for my reverse proxy which I wouldn't need then :)

I enabled it, tried again and now I'm getting the message: Unexpected answer from bridge: Missing config field!

EpicLPer commented 1 year ago

Here's the log too, seems like some Python error occurred in there too:

10.0.0.233 - - [23/Jul/2022 20:08:11] "GET /description.xml HTTP/1.1" 200 -
10.0.0.233 - - [23/Jul/2022 20:08:11] "GET /description.xml HTTP/1.1" 200 -
10.0.0.233 - - [23/Jul/2022 20:08:11] "GET /description.xml HTTP/1.1" 200 -
10.0.0.176 - - [23/Jul/2022 20:08:12] "GET /api/keyredacted/groups/0 HTTP/1.1" 200 -
....
....
....
10.0.0.95 - - [23/Jul/2022 20:08:14] "GET /api/config HTTP/1.1" 200 -
10.0.0.95 - - [23/Jul/2022 20:08:15] "POST /api/ HTTP/1.1" 200 -
10.0.0.95 - - [23/Jul/2022 20:08:16] "POST /api/ HTTP/1.1" 200 -
10.0.0.176 - - [23/Jul/2022 20:08:17] "GET /api/keyredacted/groups/0 HTTP/1.1" 200 -
10.0.0.95 - - [23/Jul/2022 20:08:17] "POST /api/ HTTP/1.1" 200 -
....
....
....
10.0.0.95 - - [23/Jul/2022 20:08:18] "POST /api/ HTTP/1.1" 200 -
10.0.0.176 - - [23/Jul/2022 20:08:19] "PUT /api/keyredacted/config HTTP/1.1" 200 -
10.0.0.95 - - [23/Jul/2022 20:08:20] "POST /api/ HTTP/1.1" 200 -
[2022-07-23 20:08:20,588] ERROR in app: Exception on /api/hueess340ab2REDACTED [GET]
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1516, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1502, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
  File "/usr/local/lib/python3.8/site-packages/flask_restful/__init__.py", line 467, in wrapper
    resp = resource(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/flask/views.py", line 84, in view
    return current_app.ensure_sync(self.dispatch_request)(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/flask_restful/__init__.py", line 582, in dispatch_request
    resp = meth(*args, **kwargs)
  File "/opt/hue-emulator/flaskUI/restful.py", line 116, in get
    result[resource][resource_id] = bridgeConfig[resource][resource_id].getV1Api(
  File "/opt/hue-emulator/HueObjects/__init__.py", line 1667, in getV1Api
    result = sensorTypes[self.modelid][self.type]["static"]
KeyError: 'ZHAPresence'
10.0.0.95 - - [23/Jul/2022 20:08:20] "GET /api/hueess340ab2REDACTED HTTP/1.1" 500 -
2022-07-23 20:08:20,621 - services.stateFetch - INFO - start lights sync
mariusmotea commented 1 year ago

This seams to be the issue. What devices are imported in DiyHue and from what integration?

EpicLPer commented 1 year ago

I've only connected deConz so far, and I have a bunch of Switches, Lights and one Blind in there

mariusmotea commented 1 year ago

May be an issue with Deconz api not correctly replicating the hue api (ex: https://github.com/diyhue/diyHue/pull/759). Do you have the knowledge to inspect the Deconz api and see the full output of the sensor that has the type ZHAPresence ? That looks to be a motion sensor but the error is generated because it match a switch from this list https://github.com/diyhue/diyHue/blob/master/BridgeEmulator/sensors/sensor_types.py

GitHub
diyHue/sensor_types.py at master · diyhue/diyHue
Main diyHue software repo. Contribute to diyhue/diyHue development by creating an account on GitHub.
mariusmotea commented 1 year ago

I think i know what is the error. Is very similar with the Hue Dimmer Switch.

Instead to expose the model ZLLPresence it is ZHAPresence. It seems the same is for the temperature sensor (https://github.com/ebaauw/homebridge-hue/issues/849). Are you able to edit a file in the container to test if it will work?

EpicLPer commented 1 year ago

Are you able to edit a file in the container to test if it will work?

Not entirely sure how to do that for a Home Assistant AddOn?

mariusmotea commented 1 year ago

You can apply the same trick from here https://github.com/diyhue/diyHue/blob/master/BridgeEmulator/sensors/sensor_types.py#L10 that made Hue Switches paired with Deconz to work correctly with DiyHue.

Just append some lines:

sensorTypes["SML001"]["ZHATemperature"] = sensorTypes["SML001"]["ZLLTemperature"]
sensorTypes["SML001"]["ZHAPresence"] = sensorTypes["SML001"]["ZLLPresence"]
sensorTypes["SML001"]["ZHALightLevel"] = sensorTypes["SML001"]["ZLLLightLevel"]
GitHub
diyHue/sensor_types.py at master · diyhue/diyHue
Main diyHue software repo. Contribute to diyhue/diyHue development by creating an account on GitHub.
EpicLPer commented 1 year ago

As said, sadly not sure how I can edit internal Docker files on Home Assistant without messing with my setup too much.

mariusmotea commented 1 year ago

ok, let me commit these and you can pull the last docker image

mariusmotea commented 1 year ago

monitor the docker image build process here: https://github.com/diyhue/diyHue/actions/runs/2724693197 . May be necessary to fallback manually in sensors.yaml file the type of the Hue Motions Sensors if Hue Essentials don't display them.

GitHub
Fix Deconz integration for motion sensor. · diyhue/diyHue@d756823
Main diyHue software repo. Contribute to diyhue/diyHue development by creating an account on GitHub.
EpicLPer commented 1 year ago

That seems to have fixed the Linking issue now! Linked without any issues on the first try :) Even hueDynamic works now which before that refused to talk to both the Emulated Hue bridge from Home Assistant and deConz's implementation too, so that's the only one that properly works now. Top! Thanks! 👍

EpicLPer commented 1 year ago

hueDynamic just started to report problems again, but I think diyhue is simply not made to update the lights via a screencapture agent according to its colors, sends about 1-2 request per second to the bridge. Think that simply is too much :) Worked with the original Hue bridge still.

mariusmotea commented 1 year ago

Diyhue can handle lot of requests per second, important is for end integration to support. Unfortunately Deconz is not a solution that can handle too many requests per second.