Smartthings SmartApp send downstream cloud message with Google Firebase


  1. Follow instruction at Smartthings to create and configure the SmartApp.
  2. Follow the document to subscribe the things event. An example at github shows a sample code snippet of a working SmartApp – provides a HTTP GET API interface to list all the available things and the data.
  3. Also, follow the Firebase document to setup the client device SDK and note down the client device token, and the firebase server key.
  4. Write an event data handler to process the event and send downstream message by http POST. Sample code can be seen below.
Example of Smartthings SmartApp to send downstream cloud message with Firebase
Event subscription is needed to trigger the event handler
def installed() {
def updated() {
/* Subscribe the event to the handler */
def initialize() {
/* Send event data to Google Firebase from http POST */
def sendEventToFirebase(evt){
def serverKey = "Firebase Server Key"
def clientToken = "Client Device Token"
def params = [
uri: "",
headers: [
Authorization: "key=" + serverKey
body: [
to: clientToken,
data: [
deviceId: evt.deviceId,
value: evt.stringValue]
try {
httpPostJson(params) { resp ->
resp.headers.each {
//log.debug "${} : ${it.value}"
log.debug "DEBUG (POST FIREBASE): response contentType: ${resp. contentType}"
} catch (e) {
log.debug "something went wrong: $e"