Page 1 of 1
Custom HTTP/Action for Notifications
Posted: Saturday 16 January 2016 23:11
by jackisidore
I have a script /home/pi/sendsms.sh
which runs ok from the console
for instance
/home/pi/sensdsms.sh test123
send a sms (with gammu)
If I try to call the same script from the notifications settings web page in domoticz with:
URL action script:///home/pi/sendsms.sh #MESSAGE
I see the following error in log if I press the Test button
Error: Error executing script command (/home/pi/sendsms.sh). returned: 26624
I must be overlooking something...
Re: Custom HTTP/Action for Notifications
Posted: Saturday 16 January 2016 23:49
by nayr
your script needs an exit code, 0 for success >0 for failure.. looks like its returning a number greater than 0
try adding exit 0 to the end of your script
I am not sure about command arguments in the script:// URI, never tried it personally it may not work as expected, might try wrapper scripts with pre-defined messages.
also make sure you have #!/bin/bash as the top line, if you omit it and your using bash logic you may get a failure that you dont see from a command line (because your cli is bash and the default shell is not)
Re: Custom HTTP/Action for Notifications
Posted: Sunday 17 January 2016 11:45
by jackisidore
Thanks for your help
My Script
Code: Select all
#!/bin/bash
gammu --sendsms TEXT +316xxxxxxx -text "test"
exit 0
Tried it form a on action of a domoticz device
script:///home/pi/domoticz/scripts/sendsms.sh
The script runs from the console. It now executes from a domoticz device without errors in the domoticz log. From Domoticz gammu doesn't do it's magic.
Must be something really silly I'm overlooking
Re: Custom HTTP/Action for Notifications
Posted: Sunday 17 January 2016 12:15
by jackisidore
Solved
Script
Code: Select all
#!/bin/bash
sms=$1" "$2
/usr/bin/gammu --config /home/pi/.gammurc --sendsms TEXT +316xxxxxxx -text "$sms"
exit 0
Notification setup
URL/Action
Code: Select all
script:///home/pi/domoticz/scripts/sendsms.sh "#SUBJECT" "#MESSAGE"
Small bug: If a device sends a notification #SUBJECT and #MESSAGE are identical. The Test button sends "Domoticz test" as #SUBJECT and "Domoticz test message!" as #MESSAGE