I previously talked a using
Kodi to show CCTV pop-ups, but I wanted to extend this to show on all active Kodi nodes (I have 4).
(Caveat - I'm no programmer, so most of this stuff is a hack, I'm sure there are better ways to do this, but this works to start with).
The first challenge was finding which nodes were active, to avoid timeouts to nodes which may be suspended. I found a package called 'avahi' which does local network discovery, so with a bit of tweaking, I was able to use this to spit out a list IP's
$ avahi-browse -raptl 2>/dev/null | egrep '_xbmc-jsonrpc.*192' | awk '{split($0,a,";"); print a[8]}' | sort | uniq
then it was a case of looping through the IP's and making the JSON RPC call to each Kodi node:
for line in iter(proc.stdout.readline, ''):
str = '/jsonrpc?request={"jsonrpc":"2.0","id":1,"method":"Addons.ExecuteAddon","params":{"addonid":"script.securitycam","params":{"cam":"replace_with_your_cam_IP"}}}'
req = urllib2.Request('http://' + line.replace("\n", "") + str)
try: f = urllib2.urlopen(req)
except urllib2.URLError as e:
print e.reason
except urllib2.HTTPError as e:
print e.reason
print f.read()
As mentioned, there are probably tidier ways to do this, but it's a minimum solution right now.