domo newbie, simple python script failing

Moderator: leecollings

Post Reply
dzaret
Posts: 3
Joined: Sunday 30 October 2016 16:50
Target OS: Linux
Domoticz version:
Contact:

domo newbie, simple python script failing

Post 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
User avatar
jvdz
Posts: 2269
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: domo newbie, simple python script failing

Post by jvdz »

Try changing that to:

Code: Select all

script:///home/dave/domoticz/scripts/python/test.py
Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
dzaret
Posts: 3
Joined: Sunday 30 October 2016 16:50
Target OS: Linux
Domoticz version:
Contact:

Re: domo newbie, simple python script failing

Post 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."
Nautilus
Posts: 722
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Finland
Contact:

Re: domo newbie, simple python script failing

Post 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:///...
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest