Bug 1759558 - Domoticz scripts don't run.
Summary: Domoticz scripts don't run.
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: domoticz
Version: 32
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Michael Cronenworth
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-10-08 13:44 UTC by Stefan van der Eijk
Modified: 2020-05-06 04:29 UTC (History)
2 users (show)

Fixed In Version: domoticz-2020.2-2.fc31 domoticz-2020.2-2.fc32
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-05-06 03:07:14 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Stefan van der Eijk 2019-10-08 13:44:29 UTC
Description of problem:

Scripts (dzvents / pl) don't run.

Version-Release number of selected component (if applicable):

How reproducible:

Logging of scripts being executed doesn't show up in the logfiles. Dummy devices which are supposed to be updated by the scripts aren't updated.

Steps to Reproduce:
1. Fedora domoticz package doesn't run any scripts.
2. systemctl stop domoticz 
3. Change /etc/systemd/system/multi-user.target.wants/domoticz.service, add this line:

ExecStart=/usr/bin/domoticz -f /etc/domoticz.conf

Remove these lines:

EnvironmentFile=/etc/sysconfig/domoticz
ExecStart=/usr/bin/domoticz -www $WWW_PORT -sslwww $SSL_PORT -sslcert $SSLCERT -sslpass $SSLPASS -sslmethod $SSLMETHOD -ssloptions $SSLOPTIONS -ssldhparam $SSLDHPARAM -wwwroot $WWW_ROOT -dbase $DBASE -userdata $USERDATA -log $LOG -loglevel $LOGLEVEL

Add /etc/domoticz.conf file with this content:

http_port=8081
ssl_port=0
http_root=/usr/share/domoticz/www
dbase_file=/var/lib/domoticz/domoticz.db
app_path=/usr/share/domoticz/
userdata_path=/usr/share/domoticz/

4. systemctl daemon-reload
5. systemctl start domoticz

Actual results:

<no domoticz scripts logging>

Expected results:

# tail -f /var/log/messages | grep domoticz | grep script
Oct  8 15:43:00 void domoticz[30273]: 2019-10-08 15:43:00.047  Status: dzVents: Info: ------ Start external script: luftdaten.lua:, trigger: every minute
Oct  8 15:43:00 void domoticz[30273]: 2019-10-08 15:43:00.047  Status: dzVents: Info: ------ Start external script: sunscreen.lua:, trigger: every minute

Additional info:

Comment 1 Michael Cronenworth 2019-10-08 16:56:23 UTC
I'm not going to support a custom conf file. That's why I have the /etc/sysconfig/domoticz file available.

I updated the default USERDATA path to /var/lib/domoticz to allow domoticz to read and write. Your path needs to be updated, too.

If you switch back to the package defaults you can reopen this bug, but I'm going to close it for now.

Comment 2 Stefan van der Eijk 2019-10-09 11:55:13 UTC
You do have a point. I'll try to go back to a supported configuration. On a spare computer I've installed FC30 (minimal), followed by:
- dnf install domoticz
- systemctl enable domoticz
- systemctl start domoticz

Added a tiny dzVents script in the dzVents script directory which was created by installing the package:

# cat /usr/share/domoticz/scripts/dzVents/scripts/I-am-on.lua 
return {
    active = true,
    on = {
        timer = { 'every minute' }
    },
    execute = function(domoticz)
        domoticz.log('I am on!', domoticz.LOG_INFO)
    end
}

I would then expect to see a message in the logs every minute, but this doesn't happen on the fresh install.

On the other host (with the hacked configuration) it does (copied from the domoticz event viewer):
2019-10-09 13:49:00.412 Status: dzVents: Info: ------ Start external script: I-am-on.lua:, trigger: every minute
2019-10-09 13:49:00.412 Status: dzVents: Info: I am on!
2019-10-09 13:49:00.412 Status: dzVents: Info: ------ Finished I-am-on.lua

Comment 3 Michael Cronenworth 2019-10-09 18:13:10 UTC
Because /usr/share/domoticz is not where you should store them. As stated above, /var/lib/domoticz is the new default userdata directory.

/var/lib/domoticz/scripts/dzVents/scripts is the correct path. I need to move those handful of /usr/share directories over to /var/lib.

Comment 4 Stefan van der Eijk 2019-10-09 18:48:01 UTC
Trying that now. mkdir /var/lib/domoticz/scripts ; rsync -av /usr/share/domoticz/scripts/ /var/lib/domoticz/scripts/

Increased the debug level to 5 and restarted domoticz:

2019-10-09 20:43:46.085  Starting shared server on: :::6144
2019-10-09 20:44:00.164  Error: EventSystem: in /usr/bin/dzVents/runtime/dzVents.lua: cannot open /usr/bin/dzVents/runtime/dzVents.lua: No such file or directory

Interesting why it's looking for it there...

# locate dzVents.lua
/usr/share/domoticz/dzVents/runtime/dzVents.lua

Comment 5 Michael Cronenworth 2019-10-09 22:17:48 UTC
I'm pushing an update that should fix the default scripts folder to be located in /var/lib/domoticz. It won't fix this issue, but please keep providing feedback.

Comment 6 Stefan van der Eijk 2019-10-10 08:22:02 UTC
Please add:

APP_ROOT="/usr/share/domoticz"

to /etc/sysconfig/domoticz

and add:

-approot $APP_ROOT

to the ExecStart line in the domoticz.service source file.

Permissions of the scripts directories also need to be updated. Domoticz should at least have write access to /var/lib/domoticz/scripts/dzVents/generated_scripts/

This seems to help dzVents to start, but I still don't see evidence of it executing scripts in the logs. I'll continue looking.

Comment 7 Stefan van der Eijk 2019-12-21 13:39:56 UTC
Updated to domoticz-4.11553-0.git20191207.1.fc30.x86_64 (fedora package) on my fc30 test system. dzvents scripts still don't work:

2019-12-21 14:39:00.454 Error: EventSystem: in /usr/bin/dzVents/runtime/dzVents.lua: cannot open /usr/bin/dzVents/runtime/dzVents.lua: No such file or directory

Comment 8 Stefan van der Eijk 2020-03-28 09:48:33 UTC
1/ Updated test system to fc32 beta
2/ removed domoticz package
3/ removed all domoticz files
4/ installed domoticz-2020.1-1.fc32.x86_64
5/ Setup --> More Options --> Events, added dzVents --> Minimal, replaced the text with:

return {
    active = true,
    on = {
        timer = { 'every minute' }
    },
    execute = function(domoticz)
        domoticz.log('I am on!', domoticz.LOG_INFO)
    end
}

6/ named it "I-am-on"
7/ enabled it
8/ nothing appears in the logs.
9/ file is write to disk: /var/lib/domoticz/scripts/dzVents/generated_scripts/I-am-on.lua

Conclusion: dzVents events don't work.

Comment 9 Stefan van der Eijk 2020-03-28 10:49:40 UTC
Run a strace on the domoticz process, in the mean time disable and enable the "I-am-on" dzvents event:

$ sudo strace -f -p 628 2>&1 | grep -i dzvents
[pid   680] openat(AT_FDCWD, "/usr/bin/dzVents/runtime/dzVents.lua", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid   670] openat(AT_FDCWD, "/var/lib/domoticz/scripts/dzVents/generated_scripts/", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 31
[pid   670] unlink("/var/lib/domoticz/scripts/dzVents/generated_scripts/I-am-on.lua") = 0
[pid   670] openat(AT_FDCWD, "/var/lib/domoticz/scripts/dzVents/generated_scripts/", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 30
[pid   670] openat(AT_FDCWD, "/var/lib/domoticz/scripts/dzVents/generated_scripts/I-am-on.lua", O_RDWR|O_CREAT|O_TRUNC, 0666) = 30
[pid   680] openat(AT_FDCWD, "/usr/bin/dzVents/runtime/dzVents.lua", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid   680] openat(AT_FDCWD, "/usr/bin/dzVents/runtime/dzVents.lua", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid   680] openat(AT_FDCWD, "/usr/bin/dzVents/runtime/dzVents.lua", O_RDONLY) = -1 ENOENT (No such file or directory)

Notice that it can't find /usr/bin/dzVents/runtime/dzVents.lua. This file is located here: /usr/share/domoticz/dzVents/runtime/dzVents.lua and is part of the domoticz package.

Add the approot configuration:

$ diff /etc/sysconfig/domoticz.rpmorig /etc/sysconfig/domoticz -ur
--- /etc/sysconfig/domoticz.rpmorig	2020-03-28 11:28:49.288383921 +0100
+++ /etc/sysconfig/domoticz	2020-03-28 11:29:33.091924422 +0100
@@ -10,4 +10,5 @@
 USERDATA="/var/lib/domoticz/"
 LOG="/var/log/domoticz.log"
 LOGLEVEL="1"
+APP_ROOT="/usr/share/domoticz"

$ diff domoticz.service /usr/lib/systemd/system/domoticz.service  -ur
--- domoticz.service	2020-03-28 11:39:16.607232336 +0100
+++ /usr/lib/systemd/system/domoticz.service	2020-03-28 11:39:50.327860056 +0100
@@ -5,7 +5,7 @@
 User=domoticz
 Group=domoticz
 EnvironmentFile=/etc/sysconfig/domoticz
-ExecStart=/usr/bin/domoticz -www $WWW_PORT -sslwww $SSL_PORT -sslcert $SSLCERT -sslpass $SSLPASS -sslmethod $SSLMETHOD -ssloptions $SSLOPTIONS -ssldhparam $SSLDHPARAM -wwwroot $WWW_ROOT -dbase $DBASE -userdata $USERDATA -log $LOG -loglevel $LOGLEVEL
+ExecStart=/usr/bin/domoticz -www $WWW_PORT -sslwww $SSL_PORT -sslcert $SSLCERT -sslpass $SSLPASS -sslmethod $SSLMETHOD -ssloptions $SSLOPTIONS -ssldhparam $SSLDHPARAM -approot $APP_ROOT -wwwroot $WWW_ROOT -dbase $DBASE -userdata $USERDATA -log $LOG -loglevel $LOGLEVEL
 WorkingDirectory=/usr/share/domoticz
 # Give the right to open priviliged ports. This allows you to run on a port <1024 without root permissions (user/group setting above)
 #CapabilityBoundingSet=CAP_NET_BIND_SERVICE


$ ps -ef | grep domoti
domoticz    1461       1  9 11:40 ?        00:00:00 /usr/bin/domoticz -www 8080 -sslwww 8443 -sslcert /var/lib/domoticz/domoticz.pem -sslpass -sslmethod -ssloptions -ssldhparam -approot /usr/share/domoticz -wwwroot /usr/share/domoticz/www -dbase /var/lib/domoticz/domoticz.db -userdata /var/lib/domoticz/ -log /var/log/domoticz.log -loglevel 1
stefan      1482     855  0 11:40 pts/0    00:00:00 grep --color=auto domoti
[stefan@ion sysconfig]$ sudo strace -f -p 1461 2>&1 | grep -i dzvents
[pid  1468] openat(AT_FDCWD, "/var/lib/domoticz/scripts/dzVents/generated_scripts/", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 31
[pid  1468] unlink("/var/lib/domoticz/scripts/dzVents/generated_scripts/I-am-on.lua") = 0
[pid  1468] openat(AT_FDCWD, "/var/lib/domoticz/scripts/dzVents/generated_scripts/", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 31
[pid  1468] openat(AT_FDCWD, "/var/lib/domoticz/scripts/dzVents/generated_scripts/I-am-on.lua", O_RDWR|O_CREAT|O_TRUNC, 0666) = 31
[pid  1478] openat(AT_FDCWD, "/usr/share/domoticz/dzVents/runtime/dzVents.lua", O_RDONLY) = 31
[pid  1492] openat(AT_FDCWD, "/var/lib/domoticz/scripts/dzVents/EventHelpers.lua", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid  1492] openat(AT_FDCWD, "/usr/share/domoticz/dzVents/runtime/EventHelpers.lua", O_RDONLY) = 32
[pid  1492] openat(AT_FDCWD, "/usr/share/domoticz/dzVents/runtime/EventHelpers.lua", O_RDONLY) = 31
[pid  1492] openat(AT_FDCWD, "/var/lib/domoticz/scripts/dzVents/lodash.lua", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid  1492] openat(AT_FDCWD, "/usr/share/domoticz/dzVents/runtime/lodash.lua", O_RDONLY) = 31
[pid  1492] openat(AT_FDCWD, "/usr/share/domoticz/dzVents/runtime/lodash.lua", O_RDONLY) = 31
[pid  1492] openat(AT_FDCWD, "/var/lib/domoticz/scripts/dzVents/Utils.lua", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid  1492] openat(AT_FDCWD, "/usr/share/domoticz/dzVents/runtime/Utils.lua", O_RDONLY) = 31
[pid  1492] openat(AT_FDCWD, "/usr/share/domoticz/dzVents/runtime/Utils.lua", O_RDONLY) = 31
[pid  1492] openat(AT_FDCWD, "/var/lib/domoticz/scripts/dzVents/JSON.lua", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid  1492] openat(AT_FDCWD, "/usr/share/domoticz/dzVents/runtime/JSON.lua", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid  1492] openat(AT_FDCWD, "/usr/share/domoticz/dzVents/runtime/device-adapters/JSON.lua", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid  1492] openat(AT_FDCWD, "/var/lib/domoticz/scripts/dzVents/dzVents/JSON.lua", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid  1492] openat(AT_FDCWD, "/var/lib/domoticz/scripts/dzVents/scripts/JSON.lua", O_RDONLY <unfinished ...>
[pid  1492] openat(AT_FDCWD, "/var/lib/domoticz/scripts/dzVents/../lua/JSON.lua", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid  1492] openat(AT_FDCWD, "/var/lib/domoticz/scripts/dzVents/scripts/modules/JSON.lua", O_RDONLY <unfinished ...>
[pid  1492] openat(AT_FDCWD, "/var/lib/domoticz/scripts/dzVents/JSON.lua", O_RDONLY <unfinished ...>
[pid  1492] openat(AT_FDCWD, "/var/lib/domoticz/scripts/dzVents/generated_scripts/JSON.lua", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid  1492] openat(AT_FDCWD, "/var/lib/domoticz/scripts/dzVents/data/JSON.lua", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid  1492] openat(AT_FDCWD, "/var/lib/domoticz/scripts/dzVents/modules/JSON.lua", O_RDONLY) = -1 ENOENT (No such file or directory)

JSON.lua is located /usr/share/domoticz/scripts/lua/JSON.lua, if the scripts are stored in /usr/share/domoticz, it would have been found with searching for ../lua/

Similar issue is also open on the domoticz issue tracker: https://github.com/domoticz/domoticz/issues/2580

Comment 10 Michael Cronenworth 2020-04-20 19:33:04 UTC
I took some time to try and debug a solution, but I cannot get dzVents to "Enable" in the Settings dialogue. I would like to test it prior to pushing a package update. It appears that 'webem' handling has broke in the 2020 update and I can't save settings. I'll see what upstream says.

Comment 11 Michael Cronenworth 2020-04-21 13:29:06 UTC
After being able to test I am now pushing an update. Please make sure your /etc/sysconfig/domoticz file gets updated to have APP_DATA defined. I am dropping the WWW_ROOT variable as it is now redundant. Thanks for the help looking into this.

Comment 12 Michael Cronenworth 2020-04-21 13:29:44 UTC
s/APP_DATA/APP_ROOT

Comment 13 Fedora Update System 2020-04-21 13:43:27 UTC
FEDORA-2020-0bafc02eac has been submitted as an update to Fedora 32. https://bodhi.fedoraproject.org/updates/FEDORA-2020-0bafc02eac

Comment 14 Fedora Update System 2020-04-21 13:43:52 UTC
FEDORA-2020-29d74fb34b has been submitted as an update to Fedora 31. https://bodhi.fedoraproject.org/updates/FEDORA-2020-29d74fb34b

Comment 15 Fedora Update System 2020-04-21 18:43:36 UTC
FEDORA-2020-0bafc02eac has been pushed to the Fedora 32 testing repository.
In short time you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2020-0bafc02eac`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2020-0bafc02eac

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 16 Stefan van der Eijk 2020-04-22 11:02:36 UTC
I've backported your changes into my package (current github version). It works. Thank you! 

There are some other small cosmetic issues which could be addressed. Shall I send an e-mail for those?

Comment 17 Michael Cronenworth 2020-04-22 13:17:51 UTC
Yes, I will look at them.

Looks like I've been banned from the upstream github. Sigh. I wish upstream was not so combative. This project could really take off.

Comment 18 Fedora Update System 2020-04-22 20:28:39 UTC
FEDORA-2020-29d74fb34b has been pushed to the Fedora 31 testing repository.
In short time you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2020-29d74fb34b`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2020-29d74fb34b

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 19 Fedora Update System 2020-04-27 14:30:30 UTC
FEDORA-2020-0bafc02eac has been submitted as an update to Fedora 32. https://bodhi.fedoraproject.org/updates/FEDORA-2020-0bafc02eac

Comment 20 Fedora Update System 2020-04-27 14:31:42 UTC
FEDORA-2020-29d74fb34b has been submitted as an update to Fedora 31. https://bodhi.fedoraproject.org/updates/FEDORA-2020-29d74fb34b

Comment 21 Fedora Update System 2020-04-28 03:23:27 UTC
FEDORA-2020-0bafc02eac has been pushed to the Fedora 32 testing repository.
In short time you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2020-0bafc02eac`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2020-0bafc02eac

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 22 Fedora Update System 2020-04-28 03:51:52 UTC
FEDORA-2020-29d74fb34b has been pushed to the Fedora 31 testing repository.
In short time you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2020-29d74fb34b`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2020-29d74fb34b

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 23 Fedora Update System 2020-05-06 03:07:14 UTC
FEDORA-2020-29d74fb34b has been pushed to the Fedora 31 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 24 Fedora Update System 2020-05-06 04:29:21 UTC
FEDORA-2020-0bafc02eac has been pushed to the Fedora 32 stable repository.
If problem still persists, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.