Add a Notification OnScreen when a Script is launched with RunScript() function
#1
Hi all!

I maded a simple python script to send a command to my DIY domotic system. This script just sends an http command and works ok.

I assigned a key on keyboard.xml with the function RunScript(path/file.py) and when I press the key the command it's sended OK.

Now I need to show a notification on screen like (command sended)

Any help?

I tried to add import xbmc and do an xbmc.executebuiltin(Notification('Comand Sended')

But i get

import xbmc
ImportError: No module named xbmc
Reply
#2
you cannot run it outside xbmc
Read/follow the forum rules.
For troubleshooting and bug reporting, read this first
Interested in seeing some YouTube videos about Kodi? Go here and subscribe
Reply
#3
Ok, then I'll try to do an addon, I used this "guide" to add a plugin that shows a notification. (maybe this could be a script, you think?)
http://www.element14.com/community/commu...ello-world

Now I need to bind a key that calls the script with arguments.

Now on keymap.xml I have:

<two>RunScript(/home/pi/.xbmc/addons/plugin.video.helloworld/souliss.py,0,11,1)</two>

Here is souliss.py, simply gets 3 values and send an HTTP command to an IP:

import urllib2
import sys

id = sys.argv[1]
slot = sys.argv[2]
val = sys.argv[3]

url = 'http://192.168.1.10:8080/force?id=' + id + '&slot=' + slot + '&val=' + val

response = urllib2.urlopen(url)
Reply
#4
you can send notifications to xbmc from outside via json
Reply
#5
(2014-09-24, 12:52)wsnipex Wrote: you can send notifications to xbmc from outside via json

I searched many examples but I can't make it work Sad

I tryed with:

#curl -v -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"id":1,"jsonrpc":"2.0","method":"GUI.ShowNotification","params":{"title":"0Dough","message":"Gotcha"}}' http://127.0.0.1:8080/jsonrpc

or:

curl --header 'Content-Type: application/json' --data-binary '{"id":1,"jsonrpc":"2.0","method":"GUI.ShowNotification","params":{"title":"Souliss","message":"Accion realizada","displaytime":5000,"image":"/home/pi/.xbmc/addons/plugin.video.helloworld/icon.png"}}' http://localhost:8080/jsonrpc

with no results, any help?
Reply

Logout Mark Read Team Forum Stats Members Help
Add a Notification OnScreen when a Script is launched with RunScript() function0