Issues with making selector switch execute script (Windows)

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

Post Reply
calania
Posts: 20
Joined: Friday 17 April 2020 21:02
Target OS: Windows
Domoticz version:
Contact:

Issues with making selector switch execute script (Windows)

Post by calania »

Hello! I am having some issues making domoticz run a script when I change the level of a selector switch. I have a few parameters that I want to run the script with so I have done as suggested on the forum and written the script with three forward slashes under "Selector actions".

script:///C:\Users\server\Desktop\MyAir2.py 192.168.0.201 --mode Favorite

But domoticz thinks the third forward slash is part of the path and I'm getting this error (without the parameters)

Error: SQLHelper: Error script not found '/C:\Users\server\Desktop\MyAir2.py

When that didn't work I also found a dzvents script that I modified

Code: Select all

return 
{ 
    on = 
    { 
        devices = 
        { 
            331,          -- MI robot Control
        }, 
    }, 

    logging =
    {
        level = domoticz.LOG_DEBUG,
        marker = 'cleaner',
    },
    
	execute = function(dz, device)
        local lodash = dz.utils._
        
		dz.log('Device ' .. device.name .. ' was updated', dz.LOG_DEBUG)
        dz.log('LevelNames: ' .. lodash.str(device.levelNames), dz.LOG_DEBUG)
        
        if device.levelName == 'Auto' then
            os.execute("C:\\Users\\server\\Desktop\\MyAir2.py 192.168.0.201 --mode Favorite")
        end
        
        dz.log(lodash.str(dz.globalData),dz.LOG_DEBUG)
	end
}
And when I change the switch I see the following in the log but the script doesn't seem to run. This is what's shown in the log

2022-12-30 17:47:40.981 Status: dzVents: Info: cleaner: ------ Start internal script: Script #3: Device: "Air purifer (Custom Sensors)", Index: 331
2022-12-30 17:47:40.982 Status: dzVents: Debug: cleaner: Device Air purifer was updated
2022-12-30 17:47:40.982 Status: dzVents: Debug: cleaner: LevelNames: {"Off", "Auto"}
2022-12-30 17:47:41.091 Status: dzVents: Debug: cleaner: {}
2022-12-30 17:47:41.091 Status: dzVents: Info: cleaner: ------ Finished Script #3

Does anybody know how I could make it work?
User avatar
psubiaco
Posts: 222
Joined: Monday 20 August 2018 9:38
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Italy
Contact:

Re: Issues with making selector switch execute script (Windows)

Post by psubiaco »

What about placing the script into DOMOTICZDIR/scrips/python and call it using the path "scripts/python/MyAir2.py" ?
I'm not familiar with windows, but with linux relative path is ok, starting from DOMOTICZ dir.
Paolo
--
I use DomBus modules to charge EV car, get a full alarm system, control heat pump, fire alarm detection, lights and much more. Video
Facebook page - Youtube channel
calania
Posts: 20
Joined: Friday 17 April 2020 21:02
Target OS: Windows
Domoticz version:
Contact:

Re: Issues with making selector switch execute script (Windows)

Post by calania »

The problem with doing it that way is that it seems ignores my arguments
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest