diyHue Add-on

diyhue needs to be on 80 cause all apps expect it to be on 80 as far as i know :confused:

Thanks, will try on another machine

Hey @MaxBec92,

I’ve quickly checked the API response for “/lights”, but it’s returning an empty array. But I guess this might be an issue within diyhue and has nothing to do with this addon

Is it posssible to install your container on another linux without HA? Because other diyhue do not have homeassistant integration

Hey @joselito1,

unfortunately not. diyhue offers docker containers for a separate install. This addon is only for ha.

Hi @MaxBec92,

I’m using the add-on, and works very nice, but only when I configure http (plain) as protocol to access to HA, if I configure https (SSL/TLS) with duckdns, the add-on can’t connect.

It’s possible to add https connections between the add-on and HA?

Thank you for your work.

Hey,

on what connection happens the issue exactly? And can you send me the diyhue Logs of that moment?

Thank you!

Hi,

The error happens between add-on and HA with this config, and duckdns integration enabled.

        "homeassistant": {
            "enabled": true,
            "homeAssistantIncludeByDefault": true,
            "homeAssistantIp": "192.168.x.x",
            "homeAssistantPort": 8123,
            "homeAssistantToken": "my token"
        },

The log when add-on starts is:

[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-beta
 Philips Hue Bridge Emulator BETA
-----------------------------------------------------------
 Add-on version: 1.2.0
 You are running the latest version of this add-on.
 System: Home Assistant OS 5.9  (armv7 / raspberrypi3)
 Home Assistant Core: 2020.12.2
 Home Assistant Supervisor: 2020.12.7
-----------------------------------------------------------
 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 = BUILD_ARCH
/opt/hue-emulator/functions/entertainment.py:97: SyntaxWarning: "is not" with a literal. Did you mean "!="?
  if len(nativeLights) is not 0:
/opt/hue-emulator/functions/entertainment.py:104: SyntaxWarning: "is not" with a literal. Did you mean "!="?
  if len(esphomeLights) is not 0:
/opt/hue-emulator/protocols/esphome.py:180: SyntaxWarning: "is not" with a literal. Did you mean "!="?
  if address["esphome_model"] is not "ESPHome-Toggle":
2021-01-04 12:29:26,209 - root - INFO - Using Host 192.168.x.x:80
Host MAC given as AABBAABBAABB
2021-01-04 12:29:26,215 - root - INFO - AABBAABBAABB
Docker Setup Initiated
SSL certificate found
Config file found
Docker Setup Complete
2021-01-04 12:29:26,217 - root - INFO - IP range for light discovery: 0-255
2021-01-04 12:29:26,218 - root - INFO - 127.0.0.1
2021-01-04 12:29:26,219 - root - INFO - Online Discovery/Remote API Enabled!
2021-01-04 12:29:26,222 - root - INFO - Config loaded
2021-01-04 12:29:26,243 - root - WARNING - Home Assistant Web Socket Client disconnected trying to (re)connect
2021-01-04 12:29:26,250 - root - ERROR - Error connecting to Home Assistant WebSocket
Traceback (most recent call last):
  File "/opt/hue-emulator/protocols/homeassistant_ws.py", line 223, in create_websocket_client
    homeassistant_ws_client.connect()
  File "/usr/local/lib/python3.8/site-packages/ws4py/client/__init__.py", line 233, in connect
    raise HandshakeError("Invalid response")
ws4py.exc.HandshakeError: Invalid response
2021-01-04 12:29:26,258 - root - DEBUG - starting ssdp...
2021-01-04 12:29:26,259 - root - DEBUG - start ssdp broadcast
2021-01-04 12:29:26,263 - root - INFO - sync with lights
Exception in thread Thread-7:
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/usr/local/lib/python3.8/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/opt/hue-emulator/HueEmulator3.py", line 1990, in run
    httpd = server_class(server_address, handler_class)
  File "/usr/local/lib/python3.8/socketserver.py", line 452, in __init__
    self.server_bind()
  File "/usr/local/lib/python3.8/http/server.py", line 138, in server_bind
2021-01-04 12:29:26,335 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): discovery.diyhue.org:443
    socketserver.TCPServer.server_bind(self)
  File "/usr/local/lib/python3.8/socketserver.py", line 466, in server_bind
    self.socket.bind(self.server_address)
OSError: [Errno 98] Address in use
2021-01-04 12:29:26,352 - root - INFO - Starting ssl httpd...
2021-01-04 12:29:26,695 - urllib3.connectionpool - DEBUG - https://discovery.diyhue.org:443 "POST / HTTP/1.1" 200 6
{"ok"}

DuckDns configuration.yaml

# Uncomment this if you are using SSL/TLS, running in Docker container, etc.
# http:
#   base_url: example.duckdns.org:8123
http:
  base_url: https://xxxxxxx.duckdns.org:8123
  ssl_certificate: /ssl/fullchain.pem
  ssl_key: /ssl/privkey.pem

IP address and MAC has been masked. I only can access to HA frontend via HTTPS.

The log says the address is already in use! :confused:

Sorry, the native emulation was running at the same time, my fault.

Anyway the behaviour is the same. Here is the correct log:

[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-beta
 Philips Hue Bridge Emulator BETA
-----------------------------------------------------------
 Add-on version: 1.2.0
 You are running the latest version of this add-on.
 System: Home Assistant OS 5.9  (armv7 / raspberrypi3)
 Home Assistant Core: 2020.12.2
 Home Assistant Supervisor: 2020.12.7
-----------------------------------------------------------
 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 = BUILD_ARCH
/opt/hue-emulator/functions/entertainment.py:97: SyntaxWarning: "is not" with a literal. Did you mean "!="?
  if len(nativeLights) is not 0:
/opt/hue-emulator/functions/entertainment.py:104: SyntaxWarning: "is not" with a literal. Did you mean "!="?
  if len(esphomeLights) is not 0:
/opt/hue-emulator/protocols/esphome.py:180: SyntaxWarning: "is not" with a literal. Did you mean "!="?
  if address["esphome_model"] is not "ESPHome-Toggle":
2021-01-04 18:38:49,078 - root - INFO - Using Host 192.168.x.x:80
Host MAC given as AABBAABBAABB
2021-01-04 18:38:49,080 - root - INFO - AABBAABBAABB
Docker Setup Initiated
SSL certificate found
Config file found
Docker Setup Complete
2021-01-04 18:38:49,083 - root - INFO - IP range for light discovery: 0-255
2021-01-04 18:38:49,084 - root - INFO - 127.0.0.1
2021-01-04 18:38:49,085 - root - INFO - Online Discovery/Remote API Enabled!
2021-01-04 18:38:49,088 - root - INFO - Config loaded
2021-01-04 18:38:49,107 - root - WARNING - Home Assistant Web Socket Client disconnected trying to (re)connect
2021-01-04 18:38:49,189 - root - ERROR - Error connecting to Home Assistant WebSocket
Traceback (most recent call last):
  File "/opt/hue-emulator/protocols/homeassistant_ws.py", line 223, in create_websocket_client
    homeassistant_ws_client.connect()
  File "/usr/local/lib/python3.8/site-packages/ws4py/client/__init__.py", line 233, in connect
    raise HandshakeError("Invalid response")
ws4py.exc.HandshakeError: Invalid response
2021-01-04 18:38:49,199 - root - DEBUG - start ssdp broadcast
2021-01-04 18:38:49,203 - root - DEBUG - starting ssdp...
2021-01-04 18:38:49,206 - root - INFO - sync with lights
2021-01-04 18:38:49,222 - root - INFO - Starting httpd...
2021-01-04 18:38:49,251 - root - INFO - Starting ssl httpd...
2021-01-04 18:38:49,253 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): discovery.diyhue.org:443
2021-01-04 18:38:50,599 - urllib3.connectionpool - DEBUG - https://discovery.diyhue.org:443 "POST / HTTP/1.1" 200 6
{"ok"}

@Jaime did you specify the correct port 443 in the diyhue Add-on config?

This is my add-on port config, without changes:

Network
Container	Host	Description
1900/udp	1901 ssdp discover
1982/udp	1982 Yeelight detection
2100/udp	2100 Hue Entertainment
443/tcp	443 Hue API SSL
80/tcp	80 Hue API

@larsf96 and anyone who can’t get lights to display in Hue Essentials app: visit http://diyhue_ip/scan endpoint to trigger manual scanning for lights, for some reason the scan process may not be triggered properly at start (I think it is only triggered if other integrations are active).

Sorry all - for no response my side I thought I’d get emails if people were mentioning me but I don’t seem to have that set up or it isn’t possible…

So I’ll scroll through and reply to a few posts.

Hi Jamie - the DiyHue/Home Assistant integration uses the Home Assistant REST API which is http only (REST API | Home Assistant Developer Docs). If you are using my DiyHue HA integration and Max’s Add on they should all be on the same box - so how much of a deal breaker is it being plain HTTP for you ?

All for instructions on setting up the DiyHue/Home Assistant see details here:

https://diyhue.readthedocs.io/en/latest/lights/homeassistant.html

The one thing the page doesn’t list is that after doing the config you need to open up Hue Essentials/Hue App and scan for new lights. I think you can also do it by hitting this URL: http://diyhue_ip/scan as pointed out by @gbdlin

The reason is I only get to tell diyhue about new lights when you initiate a scan - whilst the logs will show the connection to HA at start up and will list out the lights it has detected this needs a scan to add them to diyhue. You will also need a scan on every change you make.

To do this “automatically” (ish) see the docs linked above

Whilst I’ve tested this locally and it works for me I’ve not tested every permutation of lights being in a Group/Zone/Room so let me know of any issues and it will only allow you to add a light to one of each.

Thank you @foxy82 for the clarifications about http REST API.

I’m using https not http as I’m accessing to my HA from a different network. Therefore, http is not available in my HA, but the add-on, due to REST API limitation, doesn’t support https.

Then, I guess that I have to make available my HA through http and https at the sametime. I’ll research a bit on how to do it.

I’ve looked at the library in use for the REST API connection and it might be able to do SSL. I’ll see if I can create a version for you but I’m not sure how quickly I’ll be able to do it

1 Like

Thank you very much @foxy82, I can wait. :grinning:

Does anyone know where I can find the add ons config.json on the host machine?