XBMC Notifications

I am attempting to have XBMC display notifications with direct ST integration, but am having some difficulties in writing the SmartApp. Currently I have XBMC displaying notifications from SmartThings by sending http get requests to my EventGhost web server which triggers an XBMC Notification action, but I thought it could be cleaned up a bit.

This is the URL that would need to be triggered

http://Username:Password@Enter.IP.Address.Here:Port/jsonrpc?request={%22jsonrpc%22:%222.0%22,%22method%22:%22GUI.ShowNotification%22,%22params%22:{%22title%22:%22SmartThings%22,%22message%22:%22Front%20Door%20Opened%22},%22id%22:1}

Is there any way to change a space to %20 after a custom message string has been input? For instance - replacing the spaces in between the words Front, Door, & Opened in the URL snippet below

%22message%22:%22Front%20Door%20Opened%22

This is the Smartapp (heavily borrowed from @scottinpollock, thanks!)

definition(
    name: "XBMC Notifier",
    namespace: "",
    author: "Cassidy Nelemans",
    description: "Sends notifications to XBMC when certain things happen",
    category: "My Apps",
    iconUrl: "http://i59.tinypic.com/2zqyhs2.png",
    iconX2Url: "http://i59.tinypic.com/2zqyhs2.png"
)


preferences {
	section("Choose one or more, when..."){
		input "motion", "capability.motionSensor", title: "Motion Here", required: false, multiple: true
		input "contact", "capability.contactSensor", title: "Contact Opens", required: false, multiple: true
		input "contactClosed", "capability.contactSensor", title: "Contact Closes", required: false, multiple: true
		input "acceleration", "capability.accelerationSensor", title: "Acceleration Detected", required: false, multiple: true
		input "mySwitch", "capability.switch", title: "Switch Turned On", required: false, multiple: true
		input "mySwitchOff", "capability.switch", title: "Switch Turned Off", required: false, multiple: true
		input "arrivalPresence", "capability.presenceSensor", title: "Arrival Of", required: false, multiple: true
		input "departurePresence", "capability.presenceSensor", title: "Departure Of", required: false, multiple: true
		input "smoke", "capability.smokeDetector", title: "Smoke Detected", required: false, multiple: true
		input "water", "capability.waterSensor", title: "Water Sensor Wet", required: false, multiple: true
	}
	section("Send this custom notification to XBMC"){
		input "XBMCcommand", "text", title: "Notification to send", required: true
	}
	section("Server address and XBMC webserver port number"){
    	input "username", "text", title: "Username", description: "Your XBMC webserver username", required: true
        input "password", "text", title: "Password", description: "Your XBMC webserver password", required: true
		input "server", "text", title: "Server IP", description: "Your WAN Server IP", required: true
		input "port", "number", title: "Port", description: "XBMC webserver port number", required: true
	}
}

def installed() {
	log.debug "Installed with settings: ${settings}"
	subscribeToEvents()
}

def updated() {
	log.debug "Updated with settings: ${settings}"
	unsubscribe()
	subscribeToEvents()
}

def subscribeToEvents() {
	subscribe(contact, "contact.open", eventHandler)
	subscribe(contactClosed, "contact.closed", eventHandler)
	subscribe(acceleration, "acceleration.active", eventHandler)
	subscribe(motion, "motion.active", eventHandler)
	subscribe(mySwitch, "switch.on", eventHandler)
	subscribe(mySwitchOff, "switch.off", eventHandler)
	subscribe(arrivalPresence, "presence.present", eventHandler)
	subscribe(departurePresence, "presence.not present", eventHandler)
	subscribe(smoke, "smoke.detected", eventHandler)
	subscribe(smoke, "smoke.tested", eventHandler)
	subscribe(smoke, "carbonMonoxide.detected", eventHandler)
	subscribe(water, "water.wet", eventHandler)
}

def eventHandler(evt) {
	sendHttp()
}
def sendHttp() {
def ip = "${settings.username}:${settings.password}@${settings.server}:${settings.port}"
def deviceNetworkId = "XBMC"
// sendHubCommand(new physicalgraph.device.HubAction("""GET /?${settings.XBMCcommand} HTTP/1.1\r\nHOST: $ip\r\n\r\n""", physicalgraph.device.Protocol.LAN, "${deviceNetworkId}"))
}

I am unsure of where I could input the URL to send the XBMC notification. I seem to get errors when trying to input the above URL hardcoded into the Smartapp inside the parentheses of sendHttp()

Anyone have any suggestions on how this could be accomplished?

Try the following to encode url:

URLEncoder.encode(url, "UTF-8")

Not sure about the actual hub command…

@nelemansc

Does XBMC really want to see that JSON passed via a GET request?

@scottinpollock
It may not require it to be passed as a GET request, but when testing it by firing the command off from a web browser it did display the XBMC notification as expected. Do you have a better idea of how to approach it?

If you did it from the browser’s address bar, then it is a GET. You should be able to run it through the sendHubCommand. Have you tried sending it to HAM Bridge just to check the log to see if you’re url is being received by the host as expected?

Thanks for the suggestion scott, it’s getting closer to working.

It looks like it passes through the HAM Bridge correctly -

Received from 192.168.1.1 at 8:29:11 PM on 6/16/14
GET /jsonrpc?request={%22jsonrpc%22:%222.0%22,%22method%22:%22GUI.ShowNotification%22,%22params%22:{%22title%22:%22Motion%20Detected%22,%22message%22:%22Front%20Door%22},%22id%22:1} HTTP/1.1

Below is the code in the Smartapp -

def sendHttp() {
def ip = "${settings.username}:${settings.password}@${settings.server}:${settings.port}"
def deviceNetworkId = "XBMC"
sendHubCommand(new physicalgraph.device.HubAction("""GET /jsonrpc?request={%22jsonrpc%22:%222.0%22,%22method%22:%22GUI.ShowNotification%22,%22params%22:{%22title%22:%22Motion%20Detected%22,%22message%22:%22Front%20Door%22},%22id%22:1} HTTP/1.1\r\nHOST: $ip\r\n\r\n""", physicalgraph.device.Protocol.LAN, "${deviceNetworkId}"))
}

And this is the output from the SmartThings log -

xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx 9:24:15 PM: debug Executing GET /jsonrpc?request={%22jsonrpc%22:%222.0%22,%22method%22:%22GUI.ShowNotification%22,%22params%22:{%22title%22:%22Motion%20Detected%22,%22message%22:%22Front%20Door%22},%22id%22:1} HTTP/1.1
HOST: username:password@My.WAP.IP.Address:8081

on Home Hub via sendHubCommand

Not sure why the notification isn’t triggering in XBMC considering it triggers just fine from a web browser… I’m sure it is a typo somewhere

Looks like the last two lines are missing in the HAM Bridge log. \r\n\r\nHOST: blah blah blah.

Can you send this successfully from curl in Terminal.app?

When sending once via the curl command in Terminal to the HAM Bridge, it is showing as 5 separate GET calls. It looks like the commas are breaking the command

curl command

curl http://My.WAN.IP.Address:8080/jsonrpc?request={%22jsonrpc%22:%222.0%22,%22method%22:%22GUI.ShowNotification%22,%22params%22:{%22title%22:%22Motion%20Detected%22,%22message%22:%22Front%20Door%22},%22id%22:1}

HAM Bridge output -

Received from 192.168.1.1 at 8:14:27 AM on 6/17/14
GET /jsonrpc?request=%22jsonrpc%22:%222.0%22 HTTP/1.1



Authorization: Basic eGJtYzp4Ym1j

User-Agent: curl/7.30.0

Host: My.WAN.IP.Address:8080

Accept: */*








Received from 192.168.1.1 at 8:14:27 AM on 6/17/14
GET /jsonrpc?request=%22method%22:%22GUI.ShowNotification%22 HTTP/1.1



Authorization: Basic eGJtYzp4Ym1j

User-Agent: curl/7.30.0

Host: My.WAN.IP.Address:8080

Accept: */*








Received from 192.168.1.1 at 8:14:27 AM on 6/17/14
GET /jsonrpc?request=%22params%22:%22title%22:%22Motion%20Detected%22 HTTP/1.1



Authorization: Basic eGJtYzp4Ym1j

User-Agent: curl/7.30.0

Host: My.WAN.IP.Address:8080

Accept: */*








Received from 192.168.1.1 at 8:14:27 AM on 6/17/14
GET /jsonrpc?request=%22params%22:%22message%22:%22Front%20Door%22 HTTP/1.1



Authorization: Basic eGJtYzp4Ym1j

User-Agent: curl/7.30.0

Host: My.WAN.IP.Address:8080

Accept: */*








Received from 192.168.1.1 at 8:14:28 AM on 6/17/14
GET /jsonrpc?request=%22id%22:1 HTTP/1.1



Authorization: Basic eGJtYzp4Ym1j

User-Agent: curl/7.30.0

Host: My.WAN.IP.Address:8080

Accept: */*

I also tried without the commas, but it didn’t seem to like that

curl My.WAN.IP.Address:8080/jsonrpc?request={%22jsonrpc%22:%222.0%22%22method%22:%22GUI.ShowNotification%22%22params%22:%22title%22:%22Motion%20Detected%22%22message%22:%22Front%20Door%22%22id%22:1}
curl: (3) [globbing] nested braces not supported at pos 109

I meant can you send it via curl to the XBMC successfully?

Nope, I haven’t been able to. I’ve only been able to send it to XBMC through a web browser.

Try this:

curl -i -X POST -H "Content-Type: application/json" -d "{\"jsonrpc\": \"2.0\", \"method\": \"GUI.ShowNotification\", \"params\": {\"title\": \"Motion Detected\", \"message\": \"Front Door\"}, \"id\": 1}" http://My.WAN.IP.Address:8080/jsonrpc

Yup, that works perfect. The XBMC notification is displayed. Now how does the curl command get translated into something groovy friendly?

Thanks for all your help on this, I can see this coming in handy with both Plex & XBMC users that want on-screen notifications when something happens, and possibly down the road it can display live feeds like described in this post - http://homeawesomation.wordpress.com/2013/02/18/doorbell-ipcam-xbmc-update/

No clue as of yet, at least locally (still trying to figure that out). If you don’t mind opening a port on your router and going outside your LAN, there is a httpPostJson example in the docs.

You could also send this from HAM Bridge, triggered by a simple get request. Of course if you need to send live params and parse them HAM Bridge does not support that yet (and may never).

I decided to dig up this old thread and get XBMC notifications working through a Smartapp. Notifications work on any version of XBMC newer than 12.0 (Gotham) on Windows, OS X, or Linux. I have not gotten sendHubCommand to work, so currently all the traffic passed to XBMC has to come from the ST cloud instead of local. You will have to open up a port on your network to get this working at its current state.

/**
 *  XBMC Notifications
 *
 *  Author: nelemansc@gmail.com
 *  Date: 2014-11-18
 *
 *  
 *	This will display a pop-up notification in XBMC to alert you of anything you deem beneficial.		
 *						
 *	Requirements:
 *	XBMC (Kodi) 12.0 or newer
 *  Port open on network to allow traffic from SmartThings cloud to XBMC 
 *  Enable the XBMC webserver found in Settings > Network > Webserver
 *
 *  Set the following settings in XBMC:
 *  Allow control of XBMC via HTTP - Yes
 *  Port - your choice
 *  Username - your choice
 *  Password - your choice
 *
 *  
 */

definition(
    name: "XBMC Notifier",
    namespace: "nelemansc",
    author: "nelemansc@gmail.com",
    description: "Get a notification in XBMC when any of a variety of SmartThings are activated.  Supports motion, contact, acceleration, presence, smoke, moisture, and switches.",
    category: "Convenience",
    iconUrl: "http://i59.tinypic.com/2zqyhs2.png",
    iconX2Url: "http://i59.tinypic.com/2zqyhs2.png",
    iconX3Url: "http://i59.tinypic.com/2zqyhs2.png")

preferences {
	section("Choose one or more, when..."){
		input "motion", "capability.motionSensor", title: "Motion Here", required: false
		input "contact", "capability.contactSensor", title: "Contact Opens", required: false
		input "acceleration", "capability.accelerationSensor", title: "Acceleration Detected", required: false
		input "mySwitch", "capability.switch", title: "Switch Turned On", required: false
		input "arrivalPresence", "capability.presenceSensor", title: "Arrival Of", required: false
		input "departurePresence", "capability.presenceSensor", title: "Departure Of", required: false
		input "smoke", "capability.smokeDetector", title: "Smoke Detected", required: false
		input "water", "capability.waterSensor", title: "Water Sensor Wet", required: false
    }
	section("Enter WAN IP address"){
		input "IPAddress", "text", title: "IP Address", required: true
	}
	section("XBMC webserver port"){
		input "Port", "text", title: "Port", required: true
	}
 	section("XBMC webserver Credentials") {
        input "Username", "text", title: "Username", required: true
        input "Password", "text", title: "Password", required: true
  	}
}

def installed() {
	log.debug "Installed with settings: ${settings}"
	subscribeToEvents()
}

def updated() {
	log.debug "Updated with settings: ${settings}"
	unsubscribe()
	subscribeToEvents()
}

def subscribeToEvents() {
	subscribe(contact, "contact.open", sendMessage)
	subscribe(acceleration, "acceleration.active", sendMessage)
	subscribe(motion, "motion.active", sendMessage)
	subscribe(mySwitch, "switch.on", sendMessage)
	subscribe(arrivalPresence, "presence.present", sendMessage)
	subscribe(departurePresence, "presence.not present", sendMessage)
    subscribe(smoke, "smoke.detected", sendMessage)
	subscribe(smoke, "smoke.tested", sendMessage)
	subscribe(smoke, "carbonMonoxide.detected", sendMessage)
	subscribe(water, "water.wet", sendMessage)
}
    

def sendMessage(evt) {

if (evt.name == "contact") {
	log.debug "Event - contact"
	def contactName = "$contact"
	def contactNameEncoded = "$contactName".encodeAsURL()
	def contactNameEncoded2 = "$contactNameEncoded".replaceAll(/%5B/,"")
	def contactNameEncodedFinal = "$contactNameEncoded2".replaceAll(/%5D/,"")
    def contactState = "$evt.value"
	def contactStateEncoded = "$contactState".encodeAsURL()
    log.debug "$contactNameEncodedFinal"
    httpGet("http://$Username:$Password@$IPAddress:$Port/jsonrpc?request=%7B%22jsonrpc%22:%222.0%22%2C%22method%22:%22GUI.ShowNotification%22%2C%22params%22:%7B%22title%22:%22SmartThings%22%2C%22message%22:%22$contactNameEncodedFinal%20$contactStateEncoded%22%7D%2C%22id%22:1%7D", successClosure)
	}
    
if (evt.name == "motion") {
log.debug "Event - motion"
	def motionName = "$motion"
	def motionNameEncoded = "$motionName".encodeAsURL()
	def motionNameEncoded2 = "$motionNameEncoded".replaceAll(/%5B/,"")
	def motionNameEncodedFinal = "$motionNameEncoded2".replaceAll(/%5D/,"")
    def motionState = "$evt.value"
	def motionStateEncoded = "$motionState".encodeAsURL()
    log.debug "$motionNameEncodedFinal"
    httpGet("http://$Username:$Password@$IPAddress:$Port/jsonrpc?request=%7B%22jsonrpc%22:%222.0%22%2C%22method%22:%22GUI.ShowNotification%22%2C%22params%22:%7B%22title%22:%22SmartThings%22%2C%22message%22:%22$motionNameEncodedFinal%20$motionStateEncoded%22%7D%2C%22id%22:1%7D", successClosure)
    }
    
if (evt.name == "acceleration") {
	log.debug "Event - acceleration"
	def accelerationName = "$acceleration"
	def accelerationNameEncoded = "$accelerationName".encodeAsURL()
	def accelerationNameEncoded2 = "$accelerationNameEncoded".replaceAll(/%5B/,"")
	def accelerationNameEncodedFinal = "$accelerationNameEncoded2".replaceAll(/%5D/,"")
    def accelerationState = "$evt.value"
	def accelerationStateEncoded = "$accelerationState".encodeAsURL()
    log.debug "$accelerationNameEncodedFinal"
    httpGet("http://$Username:$Password@$IPAddress:$Port/jsonrpc?request=%7B%22jsonrpc%22:%222.0%22%2C%22method%22:%22GUI.ShowNotification%22%2C%22params%22:%7B%22title%22:%22SmartThings%22%2C%22message%22:%22$accelerationNameEncodedFinal%20$accelerationStateEncoded%22%7D%2C%22id%22:1%7D", successClosure)
    }
    
if (evt.name == "switch") {
	log.debug "Event - switch"
	def switchName = "$mySwitch"
	def switchNameEncoded = "$switchName".encodeAsURL()
	def switchNameEncoded2 = "$switchNameEncoded".replaceAll(/%5B/,"")
	def switchNameEncodedFinal = "$switchNameEncoded2".replaceAll(/%5D/,"")	
    def switchState = "$evt.value"
	def switchStateEncoded = "$switchState".encodeAsURL()
    log.debug "$switchNameEncodedFinal"
    httpGet("http://$Username:$Password@$IPAddress:$Port/jsonrpc?request=%7B%22jsonrpc%22:%222.0%22%2C%22method%22:%22GUI.ShowNotification%22%2C%22params%22:%7B%22title%22:%22SmartThings%22%2C%22message%22:%22$switchNameEncodedFinal%20$switchStateEncoded%22%7D%2C%22id%22:1%7D", successClosure)

	}
    
if (evt.name == "presence") {
	log.debug "Event - presence"
	def presenceName = "$presence"
	def presenceNameEncoded = "$presenceName".encodeAsURL()
	def presenceNameEncoded2 = "$presenceNameEncoded".replaceAll(/%5B/,"")
	def presenceNameEncodedFinal = "$presenceNameEncoded2".replaceAll(/%5D/,"")
    def presenceState = "$evt.value"
	def presenceStateEncoded = "$presenceState".encodeAsURL()
    log.debug "$presenceNameEncodedFinal"
    httpGet("http://$Username:$Password@$IPAddress:$Port/jsonrpc?request=%7B%22jsonrpc%22:%222.0%22%2C%22method%22:%22GUI.ShowNotification%22%2C%22params%22:%7B%22title%22:%22SmartThings%22%2C%22message%22:%22$presenceNameEncodedFinal%20$presenceStateEncoded%22%7D%2C%22id%22:1%7D", successClosure)
    }
    
if (evt.name == "smoke") {
	log.debug "Event - smoke"
	def smokeName = "$smoke"
	def smokeNameEncoded = "$smokeName".encodeAsURL()
	def smokeNameEncoded2 = "$smokeNameEncoded".replaceAll(/%5B/,"")
	def smokeNameEncodedFinal = "$smokeNameEncoded2".replaceAll(/%5D/,"")
    def smokeState = "$evt.value"
	def smokeStateEncoded = "$smokeState".encodeAsURL()
    log.debug "$smokeNameEncodedFinal"
    httpGet("http://$Username:$Password@$IPAddress:$Port/jsonrpc?request=%7B%22jsonrpc%22:%222.0%22%2C%22method%22:%22GUI.ShowNotification%22%2C%22params%22:%7B%22title%22:%22SmartThings%22%2C%22message%22:%22$smokeNameEncodedFinal%20$smokeStateEncoded%22%7D%2C%22id%22:1%7D", successClosure)
    }
    
if (evt.name == "water") {
	log.debug "Event - water"
	def waterName = "$water"
	def waterNameEncoded = "$waterName".encodeAsURL()
	def waterNameEncoded2 = "$waterNameEncoded".replaceAll(/%5B/,"")
	def waterNameEncodedFinal = "$waterNameEncoded2".replaceAll(/%5D/,"")
    def waterState = "$evt.value"
	def waterStateEncoded = "$waterState".encodeAsURL()
    log.debug "$waterNameEncodedFinal"
    httpGet("http://$Username:$Password@$IPAddress:$Port/jsonrpc?request=%7B%22jsonrpc%22:%222.0%22%2C%22method%22:%22GUI.ShowNotification%22%2C%22params%22:%7B%22title%22:%22SmartThings%22%2C%22message%22:%22$waterNameEncodedFinal%20$waterStateEncoded%22%7D%2C%22id%22:1%7D", successClosure)
    }
    

	def successClosure = { response ->
	  log.debug " Request was successful, $response"
	}
}
3 Likes

Hey nelemansc here is my xbmc/kodi notification app using sendHubCommand.

/**
 *  XBMC Notification
 *
 *  Copyright 2014 Richard
 *
 *  Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 *  in compliance with the License. You may obtain a copy of the License at:
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
 *  on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
 *  for the specific language governing permissions and limitations under the License.
 *
 */
definition(
    name: "XBMC Notification",
    namespace: "",
    author: "Richard",
    description: "Sends status of smartthings Device to XBMC",
    category: "",
    iconUrl: "https://cdn2.iconfinder.com/data/icons/pack3-baco-flurry-icons-style/512/XBMC.png",
    iconX2Url: "https://cdn2.iconfinder.com/data/icons/pack3-baco-flurry-icons-style/512/XBMC.png")

import groovy.json.JsonBuilder


preferences {
	section("Choose one or more, when..."){
		input "motion", "capability.motionSensor", title: "Motion Here", required: false, multiple: true
		input "contactOpen", "capability.contactSensor", title: "Contact Opens", required: false, multiple: true
		input "contactClosed", "capability.contactSensor", title: "Contact Closes", required: false, multiple: true
		input "acceleration", "capability.accelerationSensor", title: "Acceleration Detected", required: false, multiple: true
		input "mySwitchOn", "capability.switch", title: "Switch Turned On", required: false, multiple: true
		input "mySwitchOff", "capability.switch", title: "Switch Turned Off", required: false, multiple: true
		input "arrivalPresence", "capability.presenceSensor", title: "Arrival Of", required: false, multiple: true
		input "departurePresence", "capability.presenceSensor", title: "Departure Of", required: false, multiple: true
		input "smoke", "capability.smokeDetector", title: "Smoke Detected", required: false, multiple: true
		input "water", "capability.waterSensor", title: "Water Sensor Wet", required: false, multiple: true
		input "locksLocked", "capability.lock", title: "Lock Locked?",  required: false, multiple:true
        input "locksUnlocked", "capability.lock", title: "Lock Unlock?",  required: false, multiple:true

        
	}
    
    section("Run when SmartThings is set to") {
		input "setMode", "mode", title: "Mode?",  required: false, multiple:true
	}
    
    section("XBMC Notifications LivingRoom:") {
    input "xbmcserver", "text", title: "XBMC IP", description: "IP Address", required: false
    input "xbmcport", "number", title: "XBMC Port", description: "Port", required: false
    }
    
    section("XBMC Notifications Bedroom:") {
    input "xbmcserver2", "text", title: "XBMC IP", description: "IP Address", required: false
    input "xbmcport2", "number", title: "XBMC Port", description: "Port", required: false
    }
    
}

def installed() {
	log.debug "Installed with settings: ${settings}"
	subscribeToEvents()
}

def updated() {
	log.debug "Updated with settings: ${settings}"
	unsubscribe()
	subscribeToEvents()
}

def subscribeToEvents() {
	subscribe(contactOpen, "contact.open", eventHandler)
	subscribe(contactClosed, "contact.closed", eventHandler)
	subscribe(acceleration, "acceleration.active", eventHandler)
    subscribe(Noacceleration, "acceleration.inactive", eventHandler)
	subscribe(motion, "motion.active", eventHandler)
    subscribe(Nomotion, "motion.inactive", eventHandler)
	subscribe(mySwitchOn, "switch.on", eventHandler)
	subscribe(mySwitchOff, "switch.off", eventHandler)
	subscribe(arrivalPresence, "presence.present", eventHandler)
	subscribe(departurePresence, "presence.not present", eventHandler)
	subscribe(smoke, "smoke.detected", eventHandler)
	subscribe(smoke, "smoke.tested", eventHandler)
	subscribe(smoke, "carbonMonoxide.detected", eventHandler)
	subscribe(water, "water.wet", eventHandler)
    subscribe(locksLocked, "lock.locked", eventHandler)
    subscribe(locksUnlocked, "lock.unlocked", eventHandler)
    subscribe(location, modeChangeHandler)

}

def eventHandler(evt) {
	sendmessage(evt)
    sendmessage1(evt)

}

def sendmessage(evt) {
        def lanaddress = "${settings.xbmcserver}:${settings.xbmcport}"
        def deviceNetworkId = "1234"
        def toReplace = evt.displayName
		def replaced = toReplace.replaceAll(' ', '%20')
        def name = replaced
    	def value = evt.value
        def img = "http://static.squarespace.com/static/5129591ae4b0fd698ebf65c0/51384d05e4b079b8225cdf28/51384d06e4b000a8acbd05b5/1362644479952/smartthings.png"
        def json = new JsonBuilder()
        json.call("jsonrpc":"2.0","method":"GUI.ShowNotification","params":[title: "${name}",message: "${value}",image: "${img}"],"id":1)
        def xbmcmessage = "/jsonrpc?request="+json.toString()
        def result = new physicalgraph.device.HubAction("""GET $xbmcmessage HTTP/1.1\r\nHOST: $lanaddress\r\n\r\n""", physicalgraph.device.Protocol.LAN, "${deviceNetworkId}")
        sendHubCommand(result)
}

def sendmessage1(evt) {
        def lanaddress = "${settings.xbmcserver2}:${settings.xbmcport2}"
        def deviceNetworkId = "1234"
        def toReplace = evt.displayName
		def replaced = toReplace.replaceAll(' ', '%20')
        def name = replaced
        def value = evt.value
        def img = "http://static.squarespace.com/static/5129591ae4b0fd698ebf65c0/51384d05e4b079b8225cdf28/51384d06e4b000a8acbd05b5/1362644479952/smartthings.png"
        def json = new JsonBuilder()
        json.call("jsonrpc":"2.0","method":"GUI.ShowNotification","params":[title: "${name}",message: "${value}",image: "${img}"],"id":1)
        def xbmcmessage = "/jsonrpc?request="+json.toString()
        def result = new physicalgraph.device.HubAction("""GET $xbmcmessage HTTP/1.1\r\nHOST: $lanaddress\r\n\r\n""", physicalgraph.device.Protocol.LAN, "${deviceNetworkId}")
        sendHubCommand(result)

}
def modeChangeHandler(evt) {
	sendmessage3(evt)
    sendmessage4(evt)

}

def sendmessage3(evt) {
        def lanaddress = "${settings.xbmcserver}:${settings.xbmcport}"
        def deviceNetworkId = "1234"
        def mode = evt.value
        def msg = "Mode%20Activated"
        def img = "http://static.squarespace.com/static/5129591ae4b0fd698ebf65c0/51384d05e4b079b8225cdf28/51384d06e4b000a8acbd05b5/1362644479952/smartthings.png"
        def json = new JsonBuilder()
        json.call("jsonrpc":"2.0","method":"GUI.ShowNotification","params":[title: "${mode}",message: "${msg}",image: "${img}"],"id":1)
        def xbmcmessage = "/jsonrpc?request="+json.toString()
        def result = new physicalgraph.device.HubAction("""GET $xbmcmessage HTTP/1.1\r\nHOST: $lanaddress\r\n\r\n""", physicalgraph.device.Protocol.LAN, "${deviceNetworkId}")
        sendHubCommand(result)
}

def sendmessage4(evt) {
        def lanaddress = "${settings.xbmcserver2}:${settings.xbmcport2}"
        def deviceNetworkId = "1234"
        def mode = evt.value
        def msg = "Mode%20Activated"
        def img = "http://static.squarespace.com/static/5129591ae4b0fd698ebf65c0/51384d05e4b079b8225cdf28/51384d06e4b000a8acbd05b5/1362644479952/smartthings.png"
        def json = new JsonBuilder()
        json.call("jsonrpc":"2.0","method":"GUI.ShowNotification","params":[title: "${mode}",message: "${msg}",image: "${img}"],"id":1)
        def xbmcmessage = "/jsonrpc?request="+json.toString()
        def result = new physicalgraph.device.HubAction("""GET $xbmcmessage HTTP/1.1\r\nHOST: $lanaddress\r\n\r\n""", physicalgraph.device.Protocol.LAN, "${deviceNetworkId}")
        sendHubCommand(result)
        
}
4 Likes

@rog Wow, this is awesome! Ability to send the notification to multiple XBMC instances, sendHubCommand, and the SmartThings image on top of it all. You win, lol. Thanks a lot for sharing!

Hey nelemansc, glad i could share the code with you. I made some small changes so you can get the latest version on my here. If you have an IP camera you can also check my smartapp that runs a security camera addon when motion is detected.

1 Like

I used both XBMC notifier and the KODI notifier with multiple rooms.Unfortunately no event showed up in my kodi instance!
Any ideas?I also opened the web server port with port forwarding to my router but nothing changed.

If you have any solution please reply!

Are you using my version from github? if so you don’t need to use your external ip/port forwarding. Just use the local ip and port setup of the machine running Kodi.

I am using yours.I had username and password on all kodi installations.I removed them but still nothing.Any ideas?