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 · 13 comments
Open

forked for Docker-Domoticz #172

RneeJ opened this issue Oct 15, 2024 · 13 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.

@Smanar
Copy link
Owner

Smanar commented Oct 16, 2024

Can you give me the result of this request ?

source_path = os.path.dirname(os.path.abspath(__file__))
Domoticz.Log(source_path)

It's not a big problem, if a file don't exist, I can try another hardcoded path in the code, but need to know what to add/remove to the path.

@RneeJ
Copy link
Author

RneeJ commented Oct 17, 2024

First of all ! After following the below procedure in my " production" environment everything works now !

To come to this I installed a new container, exactly following the Domoticz instructions .

The relation between your install instructions and the relation with the Domoticz container setup where not clear to me at first sight. All my other plugins/scripts etc just worked right for copying with no hasle in the container environment.

Maybe you can add some extra instruction for Docker install :

In the compose.YAML of the Docker container should be :
if not already there, add before install Plugin but after first run of Domoticz!!!

volumes:
   - ./config/www/templates:/opt/domoticz/www/templates    

I followed your install instructions BUT now from INSIDE the containe (i don't know if this is crucial but it worked):

rene@rasp5:/opt/NewDomo $ sudo docker compose exec domoticz sh
# cd /opt/domoticz/userdata/plugins
# git clone https://github.com/Smanar/Domoticz-deCONZ.git
..
# chmod +x Domoticz-deCONZ/plugin.py

Restart of Domoticz and entering the connection details in the deCONZ-Domoticz plugin.

Add to the user in Domoticz that the Custom tab should be visible.

Then :

  • Devices in Domoticz where created !
  • Devices in Domoticz are updated !
  • Custom menu is avaiable.

Many hours where spend ...

I think crucial are owner rights and environment variables used when installing within the container.

@Smanar
Copy link
Owner

Smanar commented Oct 17, 2024

I followed your install instructions BUT now from INSIDE the containe (i don't know if this is crucial but it worked):

Here, IDK, I don't use docker, I have never check how to pull a Git on them, but it's good to know ^^

volumes:
   - ./config/www/templates:/opt/domoticz/www/templates

This is worrying, where the missing part is from ?
If it's from the docker image, I can ask to domoticz forum, but you are sure it's something needed, not possible to use another path in the plugin ?

source_path = os.path.dirname(os.path.abspath(__file__))
Domoticz.Log(source_path)

You can't check what is the result of this request by defaut ? without specific setting ? I can try to bypass this issue with python code.

@RneeJ
Copy link
Author

RneeJ commented Oct 17, 2024

You don't have to change the plugin, but for less experienced docker this can be usefull if you add some extra at the Install page.

The missing part is from the before mentioned Domoticz docker install page ie : https://hub.docker.com/r/domoticz/domoticz

This is used in the compose.yaml which starts the container and maps the outside world to the container inside world.
It is like the IP port mapping, the device(usb)port mapping used for the disk mapping.

You use that path in your plugin (userdata/):

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

This is the outside world on the disk (look at the paths used) :

rene@rasp5:/opt/domoticz/config $ ls -l
total 7564
drwxrwxrwx 5 rene rene    4096 Oct 12 18:10 backups
-rwxrwxrwx 1 rene rene    1255 Oct 15 10:51 customstart.sh
-rw------- 1 root root     717 Oct 17 20:30 domocookie.txt
-rwxrwxrwx 1 rene rene 3733504 Oct 17 20:30 domoticz.db
-rwxrwxrwx 1 rene rene   32768 Oct 17 20:30 domoticz.db-shm
-rwxrwxrwx 1 rene rene 3938416 Oct 17 20:30 domoticz.db-wal
drwxrwxrwx 6 rene rene    4096 Oct 17 10:48 plugins
drwxrwxrwx 9 rene rene    4096 Oct 12 18:10 scripts
drwxrwxrwx 5 rene rene    4096 Oct 12 18:10 venv
drwxrwxrwx 3 rene rene    4096 Oct 12 18:10 www
rene@rasp5:/opt/domoticz/config $ pwd
/opt/domoticz/config

This is the inside world as seen by the programs in the Domoticz-docker container :

rene@rasp5:/opt/domoticz/config $ sudo docker compose exec domoticz sh       ## the shell inside the container 
# ls -l
total 17808
drwxr-xr-x 122 1000 1000     4096 May  2 16:44  Config
drwxr-xr-x   6 root root     4096 Oct 17 10:56  Domoticz-deCONZ
-rw-r--r--   1 root root        0 Oct 17 11:09  FIRSTRUN
-rw-r--r--   1 1000 1000   119759 Jul 13 17:00  History.txt
-rw-r--r--   1 1000 1000    35147 Nov 29  2023  License.txt
-rw-r--r--   1 root root      899 Jun  7 14:38  customstart.sh
-rwxr-xr-x   1 1000 1000 16380784 Jul 13 17:01  domoticz
-rw-r--r--   1 1000 1000     5936 Nov 29  2023  domoticz.sh
drwxr-xr-x   4 1000 1000     4096 Nov 29  2023  dzVents
-rw-r--r--   1 root root  1627857 Oct 17 20:31 'goodwe Goodwe.log'
drwxr-xr-x   4 1000 1000     4096 Nov 29  2023  plugins
drwxr-xr-x   9 1000 1000     4096 Apr  3  2024  scripts
-rw-r--r--   1 1000 1000     3414 Nov 29  2023  server_cert.pem
-rwxr-xr-x   1 1000 1000     1810 Jan  2  2024  updatebeta
-rwxr-xr-x   1 1000 1000     1830 Jan  2  2024  updaterelease
drwxrwxrwx   7 1000 1000     4096 Oct 17 20:30  userdata
drwxr-xr-x   1 1000 1000     4096 Jun 20 07:16  www
# cd userdata
# ls -l
total 7564
drwxrwxrwx 5 1000 1000    4096 Oct 12 18:10 backups
-rwxrwxrwx 1 1000 1000    1255 Oct 15 10:51 customstart.sh
-rw------- 1 root root     717 Oct 17 20:30 domocookie.txt
-rwxrwxrwx 1 1000 1000 3733504 Oct 17 20:30 domoticz.db
-rwxrwxrwx 1 1000 1000   32768 Oct 17 20:32 domoticz.db-shm
-rwxrwxrwx 1 1000 1000 3938416 Oct 17 20:32 domoticz.db-wal
drwxrwxrwx 6 1000 1000    4096 Oct 17 10:48 plugins
drwxrwxrwx 9 1000 1000    4096 Oct 12 18:10 scripts
drwxrwxrwx 5 1000 1000    4096 Oct 12 18:10 venv
drwxrwxrwx 3 1000 1000    4096 Oct 12 18:10 www
# pwd                  
/opt/domoticz/userdata

You see, also other user/group owner.

After first run of Domoticz the inside world is created and can be referenced to .

That is why in the 'compose.yaml' only then the new mapping can be made.

If the mapping exist before the first start of the container this gives a (breaking) error because the outside world is not created.

Especially this plugin uses this special treatment, other plugins and scrips i used in Domoticz don't.
I just can copy the plugin and scripts in the outside world and they work inside also.

So this took me by surprise, i was confused because of the errors thrown by the plugin, I didn't know why.

I have (for some time now) an another docker instance running with my personal intranet. It consists of a php-apache container.
The intranet application has its own directory with programs, scripts and data in the user world. I can copy them in and out even without entering the container it self.
For the intranet application also is a complete container with PHP and Apache available, but i prefer to run it outside the container in " userland" .

I prefer the use of Docker because my intranet is the same on amd64 and arm64 (windows, Linux , Raspbian).
I only have to watch the PHP version i want to use. Docker puls the version i want automatically for the right architecture.

If you consider docker PHP ' https://hub.docker.com/_/php/tags ' there are 462 pages full of containers for 8 operating/architecture systems and from PHP 5.4 up to 8.4.xx and in different setups.
Updating / testing is so easy with docker.... Just pull an other container.

It is like a sort of the virtual environment in Python , but there you can actually see the inside world in your userland. It is only treated by Python different.

So i was surprised to find out about the inside world in the docker container.

Regards

@Smanar
Copy link
Owner

Smanar commented Oct 18, 2024

Especially this plugin uses this special treatment, other plugins and scrips i used in Domoticz don't.
I just can copy the plugin and scripts in the outside world and they work inside also.

It can come from the docker setting, some folder can be set to be persistant, but here you know docker better than me, and I think since the time you are on them, you are skilled now ^^

You don't have to change the plugin, but for less experienced docker this can be usefull if you add some extra at the Install page.

Yep, but if I can do something to prevent users having problem with their setup ...

From here the path /opt/domoticz/www/templates need to work #128 (comment)

And about

source_path = Parameters['HomeFolder'] + 'frontend'
Domoticz.Log(source_path)

This don't return good path ?

@RneeJ
Copy link
Author

RneeJ commented Oct 19, 2024

skilled ?, nah, just learned something more.
I still don't understand things, some are even disturbing.

And about
source_path = Parameters['HomeFolder'] + 'frontend'
Domoticz.Log(source_path)
This don't return good path ?

I tried several setups , every time there are errors, and i don't know about Python to solve this .

Placing the above at line 1048 in fonctions.py , this log :

 2024-10-19 11:04:33.237 Status: Domoticz V2024.7 (c)2012-2024 GizMoCuz
2024-10-19 11:04:33.237 Status: Build Hash: b317cfab1, Date: 2024-07-13 16:59:31
2024-10-19 11:04:33.237 Status: Startup Path: /opt/domoticz/
2024-10-19 11:04:33.254 Error: Default admin password has NOT been changed! Change it asap!
2024-10-19 11:04:33.283 Status: PluginSystem: Started, Python version '3.9.2', 1 plugin definitions loaded.
2024-10-19 11:04:33.285 Active notification Subsystems: fcm, http (2/13)
2024-10-19 11:04:33.285 Status: WebServer(HTTP) startup failed on address :: with port: 8080: resolve: Host not found (authoritative) [asio.netdb:1 at /usr/local/include/boost/asio/detail/resolver_service.hpp:84 in function 'resolve'], trying ::
2024-10-19 11:04:33.286 Status: WebServer(HTTP) startup failed on address :: with port: 8080: resolve: Host not found (authoritative) [asio.netdb:1 at /usr/local/include/boost/asio/detail/resolver_service.hpp:84 in function 'resolve'], trying 0.0.0.0
2024-10-19 11:04:33.286 Status: WebServer(HTTP) started on address: 0.0.0.0 with port 8080
2024-10-19 11:04:33.288 Status: WebServer(SSL) startup failed on address :: with port: 443: resolve: Host not found (authoritative) [asio.netdb:1 at /usr/local/include/boost/asio/detail/resolver_service.hpp:84 in function 'resolve'], trying ::
2024-10-19 11:04:33.289 Status: WebServer(SSL) startup failed on address :: with port: 443: resolve: Host not found (authoritative) [asio.netdb:1 at /usr/local/include/boost/asio/detail/resolver_service.hpp:84 in function 'resolve'], trying 0.0.0.0
2024-10-19 11:04:33.290 Status: WebServer(SSL) started on address: 0.0.0.0 with port 443
2024-10-19 11:04:33.291 Starting shared server on: 0.0.0.0:6144
2024-10-19 11:04:33.291 Status: TCPServer: shared server started...
2024-10-19 11:04:33.291 Status: RxQueue: queue worker started...
2024-10-19 11:04:35.291 Status: NotificationSystem: thread started...
2024-10-19 11:04:35.292 Status: EventSystem: reset all events...
2024-10-19 11:04:35.292 Status: EventSystem: reset all device statuses...
2024-10-19 11:04:35.301 Status: Python EventSystem: Initializing event module.
2024-10-19 11:04:35.301 Status: EventSystem: Started
2024-10-19 11:04:35.301 Status: EventSystem: Queue thread started...
2024-10-19 11:05:36.056 deCONZ: Worker thread started.
2024-10-19 11:05:36.056 Status: deCONZ: Started.
2024-10-19 11:05:36.056 Status: deCONZ: Entering work loop.
2024-10-19 11:05:36.265 Status: deCONZ: Initialized version 1.0.31, author 'Smanar'
2024-10-19 11:05:36.265 deCONZ: You are not using 127.0.0.1 as IP, so I suppose deCONZ and Domoticz aren't on same machine
2024-10-19 11:05:36.265 deCONZ: Taking 172.21.0.2 as Domoticz IP
2024-10-19 11:05:36.265 deCONZ: Creation of Info Widget.
2024-10-19 11:05:36.266 deCONZ: Adding banned device : 00:15:8d:00:02:36:c2:3f-01-0500
2024-10-19 11:05:36.266 Error: deCONZ: Call to function 'onStart' failed, exception details:
2024-10-19 11:05:36.267 Error: deCONZ: Traceback (most recent call last):
2024-10-19 11:05:36.267 Error: deCONZ: File "/opt/domoticz/userdata/plugins/Domoticz-deCONZ/plugin.py", line 1217, in onStart
2024-10-19 11:05:36.267 Error: deCONZ: _plugin.onStart()
2024-10-19 11:05:36.267 Error: deCONZ: File "/opt/domoticz/userdata/plugins/Domoticz-deCONZ/plugin.py", line 183, in onStart
2024-10-19 11:05:36.267 Error: deCONZ: installFE()
2024-10-19 11:05:36.267 Error: deCONZ: File "/opt/domoticz/userdata/plugins/Domoticz-deCONZ/fonctions.py", line 1049, in installFE
2024-10-19 11:05:36.267 Error: deCONZ: source_pathA = Parameters['HomeFolder'] + 'frontend'
2024-10-19 11:05:36.267 Error: deCONZ: NameError: name 'Parameters' is not defined
2024-10-19 11:05:46.078 deCONZ: ### Request config
2024-10-19 11:05:46.085 Status: deCONZ: Firmware version: 0x26720700
2024-10-19 11:05:46.085 Status: deCONZ: Websocketnotifyall: True
2024-10-19 11:05:46.085 Status: deCONZ: You have 13 API keys memorised, some of them are probably useless, can use the API_KEY.py tool or the Front end to clean them
2024-10-19 11:05:46.085 deCONZ: ### Request lights
2024-10-19 11:05:46.089 deCONZ: ### Device > 1 Name:On/Off light 1 Type:On/Off light Details:{'alert': 'none', 'on': False, 'reachable': True} and {'groups': ['0', '1']}
2024-10-19 11:05:46.090 Status: deCONZ: ### Create Device a4:c1:38:80:2d:44:83:5b-01 > On/Off light 1 (On/Off light) as Unit 2
2024-10-19 11:05:46.092 deCONZ: ### Device > 2 Name:On/Off light 2 Type:On/Off light Details:{'alert': 'none', 'on': False, 'reachable': True} and {'groups': ['0', '1']}
2024-10-19 11:05:46.092 Status: deCONZ: ### Create Device a4:c1:38:f1:42:d4:78:dc-01 > On/Off light 2 (On/Off light) as Unit 3
2024-10-19 11:05:46.094 deCONZ: ### Device > 3 Name:On/Off light 3 Type:On/Off light Details:{'alert': 'none', 'on': False, 'reachable': True} and {'groups': ['0', '1']}
2024-10-19 11:05:46.094 Status: deCONZ: ### Create Device a4:c1:38:a5:be:09:d3:f9-01 > On/Off light 3 (On/Off light) as Unit 4
2024-10-19 11:05:46.096 deCONZ: ### Request sensors
2024-10-19 11:05:46.100 deCONZ: ### Device > 1 Name:Daylight Type:Daylight Details:{'dark': False, 'daylight': True, 'lastupdated': '2024-10-19T07:02:05.030', 'status': 160, 'sunrise': '2024-10-19T06:14:14', 'sunset': '2024-10-19T16:38:40'} and {'configured': True, 'on': True, 'sunriseoffset': 30, 'sunsetoffset': -30}
2024-10-19 11:05:46.101 Status: deCONZ: ### Create Device 00:21:2e:ff:ff:09:d4:02-01 > Daylight (Daylight) as Unit 5
2024-10-19 11:05:46.103 deCONZ: ### Device > 10 Name:Humidity 10 Type:ZHAHumidity Details:{'humidity': 9210, 'lastupdated': '2024-10-19T09:05:16.554'} and {'battery': 100, 'offset': 0, 'on': True, 'reachable': True}
2024-10-19 11:05:46.103 Status: deCONZ: ### Create Device a4:c1:38:d9:bb:21:3e:20-01-0405 > Humidity 10 (ZHAHumidity) as Unit 6
2024-10-19 11:05:46.105 deCONZ: ### Device > 11 Name:Humidity 11 Type:ZHAHumidity Details:{'humidity': 7450, 'lastupdated': '2024-10-19T09:05:19.302'} and {'battery': 100, 'offset': 0, 'on': True, 'reachable': True}
2024-10-19 11:05:46.105 Status: deCONZ: ### Create Device a4:c1:38:7f:23:8f:e8:be-01-0405 > Humidity 11 (ZHAHumidity) as Unit 7
2024-10-19 11:05:46.107 deCONZ: ### Device > 6 Name:TS0201 (2) Type:ZHATemperature Details:{'lastupdated': '2024-10-19T09:05:19.439', 'temperature': 2100} and {'battery': 100, 'offset': 0, 'on': True, 'reachable': True}
2024-10-19 11:05:46.107 Status: deCONZ: ### Create Device a4:c1:38:7f:23:8f:e8:be-01-0402 > TS0201 (2) (ZHATemperature) as Unit 8
2024-10-19 11:05:46.109 deCONZ: ### Device > 8 Name:TS0202 Type:ZHAPresence Details:{'lastupdated': '2024-10-19T08:09:28.349', 'lowbattery': False, 'presence': False} and {'battery': 92, 'duration': None, 'on': True, 'pending': [], 'reachable': True}
2024-10-19 11:05:46.109 Status: deCONZ: ### Create Device a4:c1:38:3b:30:ca:ef:1c-01-0500 > TS0202 (ZHAPresence) as Unit 9
2024-10-19 11:05:46.112 deCONZ: ### Device > 9 Name:TS0201 Type:ZHATemperature Details:{'lastupdated': '2024-10-19T09:05:16.672', 'temperature': 1490} and {'battery': 100, 'offset': 0, 'on': True, 'reachable': True}
2024-10-19 11:05:46.112 Status: deCONZ: ### Create Device a4:c1:38:d9:bb:21:3e:20-01-0402 > TS0201 (ZHATemperature) as Unit 10
2024-10-19 11:05:46.114 deCONZ: ### Request groups
2024-10-19 11:05:46.117 deCONZ: ### Groupe > 1 Name:Phoscon_All_Off
2024-10-19 11:05:46.118 Status: deCONZ: ### Create Device GROUP_Phoscon_All_Off > Phoscon_All_Off (LightGroup) as Unit 11
2024-10-19 11:05:46.118 deCONZ: ### Groupe > 2 Name:1e groep
2024-10-19 11:05:46.118 Status: deCONZ: ### Create Device GROUP_1e_groep > 1e groep (LightGroup) as Unit 12
2024-10-19 11:05:46.118 deCONZ: ### Request alarmsystems
2024-10-19 11:05:46.123 Status: deCONZ: Alarm System configured :False
2024-10-19 11:05:46.123 Status: deCONZ: Number of devices inside :0
2024-10-19 11:05:46.123 Status: deCONZ: ### deCONZ ready
2024-10-19 11:05:46.123 Status: deCONZ: ### Found 3 Operators, 6 Sensors, 2 Groups, 0 Scenes and 0 others, with 0 Ignored
2024-10-19 11:05:46.123 Status: deCONZ: ### You can still create 243 widgets in domoticz
2024-10-19 11:05:46.123 Status: deCONZ: ### Device DeconzInfo(deCONZ - Status) Not in deCONZ ATM, the device is deleted or not ready.
2024-10-19 11:05:46.174 Status: deCONZ: Launching WebSocket on port 443
2024-10-19 11:05:46.224 deCONZ: WebSocket Handshake : HTTP/1.1 101 Switching Protocols ***Upgrade: websocket ***Connection: Upgrade ***Sec-WebSocket-Accept: V0htEbn5FhIA1xfQRyG3yU1aG9c= ***Server: deconz ***Access-Control-Allow-Credentials: false ***Access-Control-Allow-Methods: GET ***Access-Control-Allow-Headers: content-type ***Access-Control-Allow-Origin: http://172.21.0.2 ***Date: Sat, 19 Oct 2024 09:05:46 GMT *** ***

But it works for now in my operational system so after weeks of fiddling around with the CONBEE II and software, i go and enjoy my Domoticz et all.

I thank you for your patience.

@Smanar
Copy link
Owner

Smanar commented Oct 19, 2024

I tried several setups , every time there are errors, and i don't know about Python to solve this .

I have updated the beta branch to use Domoticz native fonction for path, it need to work with and without docker now, if you want to make a try.
There is too some more debug at start

2024-10-19 12:29:33.753 Status: Deconz: Source path : /home/pi/domoticz/plugins/Domoticz-deCONZ/frontend
2024-10-19 12:29:33.753 Status: Deconz: Template path : /home/pi/domoticz/www/templates
2024-10-19 12:29:33.753 Status: Deconz: Plugin custom pages in date 

@RneeJ
Copy link
Author

RneeJ commented Oct 19, 2024

I downloaded the beta zip and extracted right in my local /opt/NewDomo/config/plugins directory.
So nothing fancy about installing in the container, just from the normal user environment..
This worked right out of the box.

The Docker domoticz container is the same instance i already had running
.
After 1st run (install) the Domoticz-deCONZ was not visible in Domoticz.

The instructions on the Domoticz docker page are NOT clear/confusing about where to install plugins, they say :

Python Plugins

When launching the docker container for the first time, a plugin folder is created in the userdata folder You need to place your python plugins is folder

But here is the logging.

2024-10-19 18:43:22.069 Status: deCONZ: Started.
2024-10-19 18:43:22.069 Status: NotificationSystem: thread started...
2024-10-19 18:43:22.069 Status: EventSystem: reset all events...
2024-10-19 18:43:22.069 Status: EventSystem: reset all device statuses...
2024-10-19 18:43:22.078 Status: Python EventSystem: Initializing event module.
2024-10-19 18:43:22.078 Status: EventSystem: Started
2024-10-19 18:43:22.078 Status: EventSystem: Queue thread started...
2024-10-19 18:43:22.246 Status: deCONZ: Initialized version 1.0.32, author 'Smanar'
2024-10-19 18:43:22.247 deCONZ: You are not using 127.0.0.1 as IP, so I suppose deCONZ and Domoticz aren't on same machine
2024-10-19 18:43:22.247 deCONZ: Taking 172.21.0.2 as Domoticz IP
2024-10-19 18:43:22.247 deCONZ: Debug logging mask set to: PYTHON PLUGIN QUEUE IMAGE DEVICE CONNECTION MESSAGE
2024-10-19 18:43:22.247 deCONZ: Adding banned device : 00:15:8d:00:02:36:c2:3f-01-0500
2024-10-19 18:43:22.247 Status: deCONZ: Source path : /opt/domoticz/userdata/plugins/Domoticz-deCONZ-beta/frontend
2024-10-19 18:43:22.247 Status: deCONZ: Template path : /opt/domoticz/www/templates
2024-10-19 18:43:22.247 Status: deCONZ: Plugin custom pages in date
2024-10-19 18:43:22.247 deCONZ: Acquiring GIL for 'onStartCallback'
2024-10-19 18:43:22.546 Status: PluginSystem: 1 plugins started.
2024-10-19 18:43:32.013 deCONZ: Pushing 'onHeartbeatCallback' on to queue

Local source path for the frontend is /opt/NewDomo/config/plugins/Domoticz-deCONZ-beta/frontend
so it is found by the plugin.

Problems arise when installing as things are not clear, as i mentioned before in docker - domoticz documentation
Like adding (or un#) the path mapping - ./config/www/templates:/opt/domoticz/www/templates in compose.yaml
This is important for this plugin to function well.

@Smanar
Copy link
Owner

Smanar commented Oct 19, 2024

Local source path for the frontend is /opt/NewDomo/config/plugins/Domoticz-deCONZ-beta/frontend
so it is found by the plugin.

But from log it use

2024-10-19 18:43:22.247 Status: deCONZ: Source path : /opt/domoticz/userdata/plugins/Domoticz-deCONZ-beta/frontend

And you are right, I m reading it on the documentation

Custom Templates

If you want to use custom templates, remove the remark in the folder mapping as show below. (After you have started the container at least one time!!)

- ./config/www/templates:/opt/domoticz/www/templates

So for this part I can do nothing.

@Smanar
Copy link
Owner

Smanar commented Oct 20, 2024

Long time I haven't updated the code.
So have just updated the master branch with your comment, thx for yours tests ^^.

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