Using Docker and userscripts (Lua, DzVents, Python) Topic is solved

On various Hardware and OS systems: pi / windows / routers / nas, etc

Moderator: leecollings

User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Using Docker and userscripts (Lua, DzVents, Python)

Post by waaren »

Gravityz wrote: Friday 09 April 2021 18:37 lot's of other errors which look like an old problem. i am using the latest docker build 13149
The JSON.lua file does reside in <domoticz dir>/scripts/lua/
Same for similar xml2lua.lua, XmlParser.lua and subdirectory xmlhandler
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Gravityz
Posts: 587
Joined: Wednesday 16 December 2015 19:13
Target OS: NAS (Synology & others)
Domoticz version: 2022.2
Location: Netherlands
Contact:

Re: Using Docker and userscripts (Lua, DzVents, Python)

Post by Gravityz »

yes i know but apparently the container can not find it

when i login the container it is in
/opt/domoticz/scripts/lua

the path /opt/domoticz/userdata also contains a script directory but that one is missing the lua directory.

the errors i am getting is it tries to search in the userdata directory instead of the default directory

maybe there is a problem with the docker build because i am testing with a clean image with a brand new database

edit: i think the mapping outside the container is screwing up the default path inside the container.
if i place a copy of the JSON.lua outside the container in /docker/domoticz/scripts/dzvents the problem is gone.

it still is strange that mapping is causing this
i believe the opt/domoticz/scripts and the opt/domoticz/userdata/scripts inside the container image should be the same to avoid these problems
Last edited by Gravityz on Wednesday 21 April 2021 12:39, edited 1 time in total.
smaus
Posts: 84
Joined: Sunday 18 February 2018 9:32
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Using Docker and userscripts (Lua, DzVents, Python)

Post by smaus »

where can i find my domoticz dir in docker, i cant find it.
Gravityz
Posts: 587
Joined: Wednesday 16 December 2015 19:13
Target OS: NAS (Synology & others)
Domoticz version: 2022.2
Location: Netherlands
Contact:

Re: Using Docker and userscripts (Lua, DzVents, Python)

Post by Gravityz »

/opt/domoticz

you get there by selecting the container from synology
press details
press terminal
presh create (a bash entry appears)
click the bash entry and you are inside the container and can modify stuff, copy things and install packages with apt-get
smaus
Posts: 84
Joined: Sunday 18 February 2018 9:32
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Using Docker and userscripts (Lua, DzVents, Python)

Post by smaus »

when i look with winCSP i dont have /opt/domoticz/ i have only containerd
EddyG
Posts: 1042
Joined: Monday 02 November 2015 5:54
Target OS: -
Domoticz version:

Re: Using Docker and userscripts (Lua, DzVents, Python)

Post by EddyG »

smaus wrote: Saturday 24 April 2021 15:52 when i look with winCSP i dont have /opt/domoticz/ i have only containerd
Carefully read the above and do those steps, don't use WinSCP but DSM

Code: Select all

you get there by .....
Gravityz
Posts: 587
Joined: Wednesday 16 December 2015 19:13
Target OS: NAS (Synology & others)
Domoticz version: 2022.2
Location: Netherlands
Contact:

Re: Using Docker and userscripts (Lua, DzVents, Python)

Post by Gravityz »

read the instructions again. you can not get to the container from winscp(at least not easy)

you need to login the container through the terminal function in docker

so from the synology
goto docker
container
select the container domoticz

select details
select terminal
press create(bash will appear)
click on bash and you are logged into the container
smaus
Posts: 84
Joined: Sunday 18 February 2018 9:32
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Using Docker and userscripts (Lua, DzVents, Python)

Post by smaus »

Reading the instructions attentively, and it works. :oops: :oops:
Gravityz
Posts: 587
Joined: Wednesday 16 December 2015 19:13
Target OS: NAS (Synology & others)
Domoticz version: 2022.2
Location: Netherlands
Contact:

Re: Using Docker and userscripts (Lua, DzVents, Python)

Post by Gravityz »

nice.
now you can change things inside the container and they will be kept.

i use curl in my scripts but because docker continers can not start things outside the container it needs to be inside the container.

apt-get -qq update
apt-get -qq -y install curl

also my normal synology scripts use ash but docker uses bash so you need to xhange that in your old linux scripts




smaus wrote: Sunday 25 April 2021 16:19 Reading the instructions attentively, and it works. :oops: :oops:
knireis
Posts: 16
Joined: Wednesday 09 April 2014 14:44
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Using Docker and userscripts (Lua, DzVents, Python)

Post by knireis »

I changed my docker from the demydiuk/domoticz repo to the new official domoticz/domoticz one.

I had to import the database but further all ok exept i also have the issue that a simple DzVents script i created (to switch on a device after start of domoticz) is not running. I read this topic and the topic about the docker version but i have no clue what to do about this.

Is there a solution? If yes, can someone explain in simple steps how to achieve this?
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Using Docker and userscripts (Lua, DzVents, Python)

Post by waaren »

knireis wrote: Tuesday 27 April 2021 17:48 A simple DzVents script i created (to switch on a device after start of domoticz) is not running. I read this topic and the topic about the docker version but i have no clue what to do about this.
Did you create the dzVents script using the internal event editor? If not copy paste your script into the event editor, save it and try again.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
knireis
Posts: 16
Joined: Wednesday 09 April 2014 14:44
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Using Docker and userscripts (Lua, DzVents, Python)

Post by knireis »

yes it is made with the internal editor

before the change to the new docker image i see this in the log of the switch: EventSystem//opt/domoticz/dzVents/runtime/dzVents.lua
now there is nothing exept for when i turn it on manual.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Using Docker and userscripts (Lua, DzVents, Python)

Post by waaren »

knireis wrote: Wednesday 28 April 2021 18:54 yes it is made with the internal editor
Can you share the loglines from domoticz start and from around the time you would expect the script to be executed?
Do you have other dzVents scripts that do work?
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
knireis
Posts: 16
Joined: Wednesday 09 April 2014 14:44
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Using Docker and userscripts (Lua, DzVents, Python)

Post by knireis »

sorry, where can i find the log? there is nothing in the /config or /userdata
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Using Docker and userscripts (Lua, DzVents, Python)

Post by waaren »

knireis wrote: Thursday 29 April 2021 10:43 sorry, where can i find the log? there is nothing in the /config or /userdata
If you have not configured it, you can only see it in the GUI. [Setup][Log]
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
knireis
Posts: 16
Joined: Wednesday 09 April 2014 14:44
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Using Docker and userscripts (Lua, DzVents, Python)

Post by knireis »

2021-04-28 19:14:56.883 Status: Domoticz V2021.1 (build 13240) (c)2012-2021 GizMoCuz
2021-04-28 19:14:56.883 Status: Build Hash: d626bc52f, Date: 2021-04-28 07:52:07
2021-04-28 19:14:56.883 Status: Startup Path: /opt/domoticz/
2021-04-28 19:14:56.916 Status: PluginSystem: Started, Python version '3.7.3'.
2021-04-28 19:14:56.916 Status: : Using poll interval of 2 secs.
2021-04-28 19:14:56.919 Status: WebServer(HTTP) started on address: 0.0.0.0 with port 8080
2021-04-28 19:14:56.923 Status: WebServer(SSL) started on address: 0.0.0.0 with port 443
2021-04-28 19:14:56.925 Status: Proxymanager started.
2021-04-28 19:14:56.926 Status: TCPServer: shared server started...
2021-04-28 19:14:56.926 Status: RxQueue: queue worker started...
2021-04-28 19:14:58.926 Status: (Evohome) Worker started...
2021-04-28 19:14:58.926 Status: rfxcom: Worker started...
2021-04-28 19:14:58.926 Status: Hue: Worker started...
2021-04-28 19:14:58.927 Status: NotificationSystem: thread started...
2021-04-28 19:14:58.927 Status: EventSystem: reset all events...
2021-04-28 19:14:58.932 Status: dzVents: Write file: /opt/domoticz/userdata/scripts/dzVents/generated_scripts/linphone-init.lua
2021-04-28 19:14:58.932 Status: EventSystem: reset all device statuses...
2021-04-28 19:14:58.975 Status: Python EventSystem: Initalizing event module.
2021-04-28 19:14:58.975 Status: EventSystem: Started
2021-04-28 19:14:58.975 Status: EventSystem: Queue thread started...
2021-04-28 19:14:59.927 Status: rfxcom: Using serial port: /dev/ttyUSB0
2021-04-28 19:15:08.927 Status: (Evohome) connect to Evohome server
2021-04-28 19:15:27.058 Status: PROXY: Authenticate result: success.
2021-04-28 19:16:18.958 Status: (Evohome) connect to Evohome server
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Using Docker and userscripts (Lua, DzVents, Python)

Post by waaren »

knireis wrote: Thursday 29 April 2021 10:50 2021-04-28 19:14:58.932 Status: dzVents: Write file: /opt/domoticz/userdata/scripts/dzVents/generated_scripts/linphone-init.lua
So I assume linphone-init.lua is the script you refer to. Can you share it?
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
knireis
Posts: 16
Joined: Wednesday 09 April 2014 14:44
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Using Docker and userscripts (Lua, DzVents, Python)

Post by knireis »

Code: Select all

return
{
    on =
    {
        system =
        {
            'start',
        },
    },

    logging =
    {   
        level = domoticz.LOG_DEBUG,
        marker = 'start',
    },

    execute = function(dz)
        dz.devices('Linphone-S').switchOn().afterSec(10)
    end
}
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Using Docker and userscripts (Lua, DzVents, Python)

Post by waaren »

This should work, or at least show some loglines.

Is dzVents still enabled in [Setup][Setttings][Other]?
dzVents .png
dzVents .png (16.41 KiB) Viewed 1933 times
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
knireis
Posts: 16
Joined: Wednesday 09 April 2014 14:44
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Using Docker and userscripts (Lua, DzVents, Python)

Post by knireis »

2021-04-29 11:42:14.346 Error: EventSystem: problem writing file: /opt/domoticz/userdata/scripts/dzVents/generated_scripts/linphone-init.lua

Seems to be an access issue?
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest