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?