Execute Python script in dzvents  [Solved]

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

Moderator: leecollings

Post Reply
jberinga
Posts: 67
Joined: Tuesday 11 August 2015 14:20
Target OS: NAS (Synology & others)
Domoticz version: 2024.7
Location: The Netherlands
Contact:

Execute Python script in dzvents

Post by jberinga »

When trying to execute a Python script in dzvents:
Spoiler: show

Code: Select all

return {
    on = {
        devices = { 'Test' },
        },
    
    execute = function(domoticz, item)
    
    if 
        domoticz.devices('Test').state == 'On'
    then
        domoticz.devices('Test').switchOff().afterSec(5)
        domoticz.utils.osExecute("script:///usr/bin/python /volume1/@appstore/domoticz/var/scripts/python/volumeset.py 031")
    end
   
end
}
nothing is happening; it should set the volume to a certain level. There are no errors in the log.

When activating the script (script:///usr/bin/python /volume1/@appstore/domoticz/var/scripts/python/volumeset.py 031) in the On Action of the device, the volume is changed.

What am I doing wrong? :?
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Execute Python script in dzvents

Post by waaren »

jberinga wrote: Thursday 01 October 2020 20:48 What am I doing wrong? :?
You don't need the script:// part when executing from a script.
Can you try with

Code: Select all

return {
    on = {
        devices = { 'Test' },
        },
    
    logging = 
    {
    	level = domoticz.LOG_DEBUG, -- change to domoticz.LOG_ERROR when all OK
    	marker = 'Python execution',
    },
    
    execute = function(domoticz, item)
    
    if 
        domoticz.devices('Test').state == 'On'
    then
        domoticz.devices('Test').switchOff().afterSec(5)
        domoticz.utils.osExecute("/usr/bin/python /volume1/@appstore/domoticz/var/scripts/python/volumeset.py 031")
        
        -- if standard execution does not work you could try with sudo 
        -- domoticz.utils.osExecute("sudo /usr/bin/python /volume1/@appstore/domoticz/var/scripts/python/volumeset.py 031")
    end
   
end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
jberinga
Posts: 67
Joined: Tuesday 11 August 2015 14:20
Target OS: NAS (Synology & others)
Domoticz version: 2024.7
Location: The Netherlands
Contact:

Re: Execute Python script in dzvents  [Solved]

Post by jberinga »

Thanks waaren!
That did it (domoticz.utils.osExecute("/usr/bin/python /volume1/@appstore/domoticz/var/scripts/python/volumeset.py 031"))
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest