Page 1 of 1

domo newbie, simple python script failing

Posted: Sunday 30 October 2016 17:04
by dzaret
hi there, i'm looking for a bit of guidance. i'm new to domo, but not to python, and i'm trying to get a simple python script connected so that i can start building proper logic with the JSON APIs and such...

i'm in ubuntu, latest version of domo. simple dummy hardware, simple dummy switch. in the scripts/python directory i've made test.py:

Code: Select all

#!usr/bin/python
import domoticz
domoticz.log("script")
domoticz.error("error")
doesn't get more simple than that. on the switch i have on/off wired:

script://home/dave/domoticz/scripts/python/test.py

script is set to executable:
-rwxrwxrwx 1 dave dave 225 Oct 29 22:10 test.py

"which python" shows py 2.7 installed appropriately at /usr/bin/python
python --version shows 2.7.12

i get *nothing* when i click the switch in the UI. i see it's clicking, because there are log entries, but i get no indication my script is being run.

i changed the URL of the script to have three slashes, and that throws a script error 32512 which i believe means it's not finding the script appropriately, so back to double slashes. the log shows:

2016-10-30 12:01:43.025 User: dz initiated a switch command (1/test switch/Off)
2016-10-30 12:01:43.025 (test) Light/Switch (test switch)
2016-10-30 12:01:47.510 User: dz initiated a switch command (1/test switch/On)
2016-10-30 12:01:47.510 (test) Light/Switch (test switch)

this is the most simple of the simple. yet, i'm stuck.

i'd appreciate some guidance, apologies for such a dumb one.

--- dz

Re: domo newbie, simple python script failing

Posted: Sunday 30 October 2016 17:15
by jvdz
Try changing that to:

Code: Select all

script:///home/dave/domoticz/scripts/python/test.py
Jos

Re: domo newbie, simple python script failing

Posted: Sunday 30 October 2016 20:49
by dzaret
thanks for the response. i tried that already, and mentioned such:

2016-10-30 15:48:01.603 Executing script: /home/dave/domoticz/scripts/python/test.py
sh: 1: /home/dave/domoticz/scripts/python/test.py: not found
2016-10-30 15:48:01.605 Error: Error executing script command (/home/dave/domoticz/scripts/python/test.py). returned: 32512

my understanding is that 32512 means "i can't find the script."

Re: domo newbie, simple python script failing

Posted: Sunday 30 October 2016 22:28
by Nautilus
Have you tried from command line if it is working? Because if you copied the actual script to the first post, isn't there a fault in the shebang:

Code: Select all

#!usr/bin/python
should be:

Code: Select all

#!/usr/bin/python
For the rest of the lines I'm not sure should they work, I guess they should :) For me it has always needed to be three slashes in the script:///...