Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

forked for Docker-Domoticz #172

Open
RneeJ opened this issue Oct 15, 2024 · 3 comments
Open

forked for Docker-Domoticz #172

RneeJ opened this issue Oct 15, 2024 · 3 comments

Comments

@RneeJ
Copy link

RneeJ commented Oct 15, 2024

Hi, Smanar,

First : i can't code in Python and have little knowledge of github. (But i have some knowledge in other programming languages)

As i already mentioned this plugin will not work in Docker. It seemed to work but was terminated :

  • after generating the devices in Domoticz,
  • no deCONZ widget was generated in Domoticz and
  • devices where not updated.

There where several error messages which where not related to the actual problem. (like indicating missing api-key)
The missing Library's where already incorporated in the docker image.

As you already mentioned : in Docker it is al to fluent ...
And indeed it is.

So I forked this repository and made some hard coded changes.

I hardcoded some import checks, path's , IP addresses.

Docker problem: after first start from compose file , errors come up. After restart from Portainer (is Docker webinterface) these errors are gone. I still have to look into that later.

All apply to the use of this plugin in Domoticz Docker only :

  • The check for lib's was skipped. Don't know for sure if that is necessary.
  • The widget in the custom tab was not created because the (hardcoded) path used could not find the template.
  • The given IP address in the setup page was used only once. But was not used for updating. ( prob get_ip() ? )

These i hardcodded for my use and Currently, i have the widget in the customtab/deCONZ running and it is being updated every minute. So the connections are good !

There is one error logged now :

  • Error: deCONZ hardware (29) thread seems to have ended unexpectedly
  • And the corresponding devices in Domoticz are not updated.

Error must be :

  • after getting info from deCONZ but before writing to Domoticz devices.
  • the program aborts with a severe error. I thinks some external call cannot be reached ?

For now i have no clue, mabe you have any idea where the problem is ?

@RneeJ
Copy link
Author

RneeJ commented Oct 15, 2024

Next step : I moved domoticz.py to the plugin directory because it can not be loaded ?
I think only standard Python library's can be loaded directly ?

When entering the docker environment there is no PATH for library's ?:

rene@rasp5:/opt/domoticz $ sudo docker compose exec domoticz sh
# python3
Python 3.9.2 (default, Feb 28 2021, 17:03:44) 
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.environ
environ({'SSL_PORT': '443', 'HOSTNAME': '7862995aee60', 'LOG_PATH': '', 'WWW_PORT': '8080', 'EXTRA_CMD_ARG': '', 'HOME': '/root', 'TERM': 'xterm', 'PATH': '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', 'DATABASE_PATH': '', 'PWD': '/opt/domoticz', 'TZ': 'Europe/Amsterdam', 'LC_CTYPE': 'C.UTF-8'})
>>> os.getcwd()
'/opt/domoticz'
>>> 

is there much more logging now ?:

2024-10-15 17:40:53.016 deCONZ: Pushing 'onHeartbeatCallback' on to queue
2024-10-15 17:40:53.066 deCONZ: Processing 'onHeartbeatCallback' message
2024-10-15 17:40:53.066 deCONZ: Acquiring GIL for 'onHeartbeatCallback'
2024-10-15 17:40:53.067 deCONZ: Calling message handler 'onHeartbeat' on 'module' type object.
2024-10-15 17:40:53.067 deCONZ: onHeartbeat called
2024-10-15 17:40:53.067 Error: deCONZ: WebSocket Disconnected, reconnecting...
2024-10-15 17:40:53.067 deCONZ: Pushing 'ConnectDirective' on to queue
2024-10-15 17:40:53.067 deCONZ: Acquiring GIL for 'onHeartbeatCallback'
2024-10-15 17:40:53.067 deCONZ: Processing 'ConnectDirective' message
2024-10-15 17:40:53.067 deCONZ: Acquiring GIL for 'ConnectDirective'
2024-10-15 17:40:53.067 deCONZ: Transport set to: 'TCP/IP', 192.168.2.48:443.
2024-10-15 17:40:53.067 deCONZ: Connect directive received, action initiated successfully.
2024-10-15 17:40:53.067 deCONZ: Acquiring GIL for 'ConnectDirective'
2024-10-15 17:40:53.067 deCONZ: Acquiring GIL for 'CPluginTransportTCP::handleAsyncResolve'
2024-10-15 17:40:53.067 deCONZ: Acquiring GIL for 'CPluginTransportTCP::handleAsyncResolve'
2024-10-15 17:40:53.067 deCONZ: Pushing 'onConnectCallback' on to queue
2024-10-15 17:40:53.117 deCONZ: Processing 'onConnectCallback' message
2024-10-15 17:40:53.117 deCONZ: Acquiring GIL for 'onConnectCallback'
2024-10-15 17:40:53.117 deCONZ: Calling message handler 'onConnect' on 'module' type object.
2024-10-15 17:40:53.117 deCONZ: onConnect called
2024-10-15 17:40:53.117 Status: deCONZ: Launching WebSocket on port 443
2024-10-15 17:40:53.117 deCONZ: Pushing 'WriteDirective' on to queue
2024-10-15 17:40:53.117 deCONZ: Acquiring GIL for 'onConnectCallback'
2024-10-15 17:40:53.117 deCONZ: Processing 'WriteDirective' message
2024-10-15 17:40:53.117 deCONZ: Acquiring GIL for 'WriteDirective'
2024-10-15 17:40:53.117 deCONZ: Sending 225 bytes of data
2024-10-15 17:40:53.117 deCONZ: 2d 58 20 47 45 54 20 2f 20 48 54 54 50 2f 31 2e 31 0d 0a 48 -X.GET./.HTTP/1.1..H
2024-10-15 17:40:53.117 deCONZ: 6f 73 74 3a 20 31 39 32 2e 31 36 38 2e 32 2e 34 38 3a 34 34 ost:.192.168.2.48:44
2024-10-15 17:40:53.117 deCONZ: 33 0d 0a 55 73 65 72 2d 41 67 65 6e 74 3a 20 44 6f 6d 6f 74 3..User-Agent:.Domot
2024-10-15 17:40:53.117 deCONZ: 69 63 7a 2f 31 2e 30 0d 0a 53 65 63 2d 57 65 62 53 6f 63 6b icz/1.0..Sec-WebSock
2024-10-15 17:40:53.117 deCONZ: 65 74 2d 56 65 72 73 69 6f 6e 3a 20 31 33 0d 0a 4f 72 69 67 et-Version:.13..Orig
2024-10-15 17:40:53.117 deCONZ: 69 6e 3a 20 68 74 74 70 3a 2f 2f 31 39 32 2e 31 36 38 2e 32 in:.http://192.168.2
2024-10-15 17:40:53.117 deCONZ: 2e 34 38 0d 0a 53 65 63 2d 57 65 62 53 6f 63 6b 65 74 2d 4b .48..Sec-WebSocket-K
2024-10-15 17:40:53.117 deCONZ: 65 79 3a 20 71 71 4d 4c 42 78 79 79 6a 7a 39 54 6f 67 31 62 ey:.qqMLBxyyjz9Tog1b
2024-10-15 17:40:53.118 deCONZ: 6c 6c 37 4b 36 41 3d 3d 0d 0a 43 6f 6e 6e 65 63 74 69 6f 6e ll7K6A==..Connection
2024-10-15 17:40:53.118 deCONZ: 3a 20 6b 65 65 70 2d 61 6c 69 76 65 2c 20 55 70 67 72 61 64 :.keep-alive,.Upgrad
2024-10-15 17:40:53.118 deCONZ: 65 0d 0a 55 70 67 72 61 64 65 3a 20 77 65 62 73 6f 63 6b 65 e..Upgrade:.websocke
2024-10-15 17:40:53.118 deCONZ: 74 0d 0a 0d 0a .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. t....
2024-10-15 17:40:53.118 deCONZ: Acquiring GIL for 'WriteDirective'
2024-10-15 17:40:53.118 deCONZ: Acquiring GIL for 'CPluginTransportTCP::handleRead'
2024-10-15 17:40:53.118 deCONZ: Pushing 'DisconnectedEvent' on to queue
2024-10-15 17:40:53.168 deCONZ: Processing 'DisconnectedEvent' message
2024-10-15 17:40:53.168 deCONZ: Acquiring GIL for 'DisconnectedEvent'
2024-10-15 17:40:53.168 deCONZ: Disconnect event received for '192.168.2.48:443'.
2024-10-15 17:40:53.168 deCONZ: Pushing 'onDisconnectCallback' on to queue
2024-10-15 17:40:53.168 deCONZ: Acquiring GIL for 'DisconnectedEvent'
2024-10-15 17:40:53.168 deCONZ: Processing 'onDisconnectCallback' message
2024-10-15 17:40:53.168 deCONZ: Acquiring GIL for 'onDisconnectCallback'
2024-10-15 17:40:53.168 deCONZ: Calling message handler 'onDisconnect' on 'module' type object.
2024-10-15 17:40:53.168 Status: deCONZ: onDisconnect called for deCONZ_WebSocket
2024-10-15 17:40:53.168 deCONZ: Acquiring GIL for 'onDisconnectCallback'
2024-10-15 17:41:03.031 deCONZ: Pushing 'onHeartbeatCallback' on to queue



@Smanar
Copy link
Owner

Smanar commented Oct 15, 2024

Transport set to: 'TCP/IP', 192.168.2.48:443.

But your websocket is still on https port ?

The check for lib's was skipped. Don't know for sure if that is necessary.

Without this check the plugin will work but will be not able to make request.

The widget in the custom tab was not created because the (hardcoded) path used could not find the template

It's not hardcoded, and already modified for docker

    source_path = os.path.dirname(os.path.abspath(__file__)) + '/frontend'
    templates_path = os.path.abspath(source_path + '/../../../www/templates')
    #dst_plugin_path = templates_path + '/deCONZ'
    fs = False

    try:
        fs = os.path.getsize(templates_path + '/deCONZ.html')
    except:
        pass

    #Special part for dockers
    if not os.path.exists(templates_path):
        templates_path = templates_path.replace("userdata/","")

Wich one path you need ? Perhaps a new one ?

The given IP address in the setup page was used only once. But was not used for updating. ( prob get_ip() ? )

Perhps you have usefull logs at start ?


        #Check Domoticz IP
        if Parameters["Address"] != '127.0.0.1' and Parameters["Address"] != 'localhost':
            global DOMOTICZ_IP
            DOMOTICZ_IP = get_ip()
            Domoticz.Log("You are not using 127.0.0.1 as IP, so I suppose deCONZ and Domoticz aren't on same machine")
            Domoticz.Log("Taking " + DOMOTICZ_IP + " as Domoticz IP")

            if DOMOTICZ_IP == Parameters["Address"]:
                Domoticz.Status("You seem to use the IP for deCONZ and Domoticz. Why don't you use 127.0.0.1 as IP?")
        else:
            Domoticz.Log("Domoticz and deCONZ are installed on the same machine.")

@RneeJ
Copy link
Author

RneeJ commented Oct 15, 2024

Thank you for your quick reply.

Path for docker didn't work for me, maybe something further on went wrong.

I hardcoded : templates_path = os.path.abspath('/opt/domoticz/www/templates')

That worked and installed the custom/deCONZ widget in Domoticz.

Ha!While typing.

Now i think i understand where things go wrong.

I used the default docker container, this does NOT contain the EXAMPLE script mentioned on : https://www.domoticz.com/wiki/Docker.

This script copies the template to "userdata"

echo 'copying event script templates to external mapped storage /volume1/domoticz/scripts/templates
cp -r /opt/domoticz/scripts/templates  /opt/domoticz/userdata/scripts

But i don't know if that works.

Previous assumption is wrong.

See here : https://hub.docker.com/r/domoticz/domoticz

The path i used : '/opt/domoticz/www/templates' is the correct path in this Domoticz / Docker distribution.

I wil make (later this week) a new install of domoticz from that container from scratch with only this plugin and see how that goes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants