external script won't run from dzventsz

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
User avatar
Hansh
Posts: 22
Joined: Sunday 17 February 2019 14:07
Target OS: Raspberry Pi / ODroid
Domoticz version: 2025.1
Location: Rotterdam
Contact:

external script won't run from dzventsz

Post by Hansh »

I hope I'm asking this question in the right place.

I have a problem with starting a script from dzvents. The script won't start no matter what I've done so far, even consulting ai hasn't provided a solution. (I end up in a cricel of solutions).
This is my latest version of the script.

Code: Select all

return {
	on = {
		devices = {
			'3d printen'
		}
	},
	logging =   
    {
        level = domoticz.LOG_INFO, -- set to LOG_ERROR when tested and OK
        marker = '3D printen', 
    },
	execute = function(domoticz, device)
	    if device.state== 'On' then
	        domoticz.devices('3D systeem').switchOn()
	    end
	    if device.state== 'Off' then
		domoticz.log("3D systeem is shutting down in progres")
	        --python3 /home/pi/scripts/octopi_shutdown.py  (
	        domoticz.utils.osExecute("/bin/bash octopi_shutdown.sh")
	        --domoticz.utils.osExecute("ssh [email protected] 'sudo poweroff'")
	        domoticz.devices('3D systeem').switchOff().afterSec(30)
		domoticz.log("3D systeem is down")
		end
	end
}
in an earlier version of domoticz the command ( now in use 2025-1)
domoticz.utils.osExecute("ssh [email protected] 'sudo poweroff'")
worked fine and stopped octopi

What I tried / did:

the two raspberries can log in via ssh without passwords also for the sudo commands no passwords are needed anymore. If I enter "ssh [email protected] 'sudo poweroff'" in a terminal then the octopi.local stops as expected. But not via dzvents. (tried as user pi and root)
tried with python intermediate step. When running this python script from a terminal the octipi.local also stops here but also not via dzvents

You would think it's a rights problem. Domoticz is executed by the owner PI and all rights are set so that the owner pi can access everything and can start all relevant folders and files have the rights 777.
Even after "sudo chmod 777 -R ./home/pi" it doesn't work from dzvents

os.Execute is recognized by domoticz.

Messages from the domoticz log are and remain the same no matter what I do. And I don't get a single message from the scripts, not even that it's running. (the scripts are full of log messages also to log files)

2025-06-15 11:22:26.786 Status: User: Hans (IP: 192.168.0.xxx) initiated a switch command (148/3d printen/Off)
2025-06-15 11:22:26.814 dzVents: Handling events for: "3d printing", value: "Off"
2025-06-15 11:22:26.814 dzVents: 3D printing: 3D system is shutting down in progress
2025-06-15 11:22:26.816 dzVents: 3D printing: 3D system is down

I'm out of options
Anyone have any ideas
All my texts are translated from Dutch to English by Google translate>
Sorry for weird sentence structure
willemd
Posts: 642
Joined: Saturday 21 September 2019 17:55
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.1
Location: The Netherlands
Contact:

Re: external script won't run from dzventsz

Post by willemd »

So clearly your script is triggered and runs as expected, except for this line
domoticz.utils.osExecute("/bin/bash octopi_shutdown.sh")

You did not mention you tried running exactly this command from a command line but I assume this also works?
Can you put more debugging into that shell script? Can you get any error logging from that shell script? Is that shell script executed but maybe some statements that are within the shell script are not?
User avatar
Hansh
Posts: 22
Joined: Sunday 17 February 2019 14:07
Target OS: Raspberry Pi / ODroid
Domoticz version: 2025.1
Location: Rotterdam
Contact:

Re: external script won't run from dzventsz

Post by Hansh »

thanks for the reply

yes i had already executed it via a command line. i called this a terminal in my post.
The scripts are provided with extensive log options. When executing the script in a command line i get all ok messages that i expect and the script does what it should do.
If i do it via dzvents then nothing happens at all not even a log output. only a message in the domoticz log as mentioned in the post.
it seems like a security problem but i have allowed and released everything and still it does not work from domoticz. . possibly an option in domoticz is not set right. But which one
All my texts are translated from Dutch to English by Google translate>
Sorry for weird sentence structure
User avatar
jvdz
Posts: 2328
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: external script won't run from dzventsz

Post by jvdz »

You also set the Execute (x) bit on the file with chmod +x ?
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
User avatar
Hansh
Posts: 22
Joined: Sunday 17 February 2019 14:07
Target OS: Raspberry Pi / ODroid
Domoticz version: 2025.1
Location: Rotterdam
Contact:

Re: external script won't run from dzventsz

Post by Hansh »

jvdz wrote: Sunday 15 June 2025 22:16 You also set the Execute (x) bit on the file with chmod +x ?
thanks for the reply

i had set the Executebit (+x) in both files and folders with "sudo chmod 777 -R ./home/pi" (777 stands for rwxrwxrwx) and that didn't help either

It remains a mystery to me :?:
All my texts are translated from Dutch to English by Google translate>
Sorry for weird sentence structure
User avatar
madpatrick
Posts: 667
Joined: Monday 26 December 2016 12:17
Target OS: Linux
Domoticz version: 2025.1
Location: Netherlands
Contact:

Re: external script won't run from dzventsz

Post by madpatrick »

maybe this helps a bit

viewtopic.php?t=35237

Here they are using "os.execute" and not "domoticz.utils.osExecute"

and

https://wiki.domoticz.com/DzVents:_next ... _execution
https://wiki.domoticz.com/DzVents:_next ... _execution
-= HP server GEN11 =- OZW -=- Toon2 (rooted) -=- Domoticz v2025.1 -=- Dashticz v3.14b on Tab8" =-
User avatar
waltervl
Posts: 5842
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: external script won't run from dzventsz

Post by waltervl »

Also make sure you use full paths in the scripts, also in the sub-scripts. Like for example
/bin/bash /home/pi/octopi_shutdown.sh
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
jannl
Posts: 673
Joined: Thursday 02 October 2014 6:36
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: Geleen
Contact:

Re: external script won't run from dzventsz

Post by jannl »

Are you using docker?
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest