Getting more out of notifications

So this isn't strictly a Hubitat thing. I currently have notifications setup to go to mine and my wife's phones when the washer or dryer finishes. I have some ideas for other notifications as well.

Notifications can be useful, but I feel like there are a few things that could make them more useful. Here is a use case: The washer finishes. A notification goes to both phones. I move the laundry to the dryer and on the "washer is finished" notification, I hit a "done" button or something similar and clears the notification from my phone AND my wife's phone. That way she isn't left wondering if the laundry has been moved. Bonus points if it can send a command back to Hubitat to press a button. Also would prefer if the notification cannot be swiped away by accident.

Does anyone know of a way to do something like this?

1 Like

I have a Notification Tile driver that I use to split out notifications and display on a dashboard tile, that may work for you. I set it to be the destination of notifications of specific applications/integrations so that I can see the last 5 at a glance; i.e. you can have HSM going to a tile, and a general tile that shows everything else.

Summary
 /*
 * Notify Tile Device
 *
 *  Licensed Virtual 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, WIyTHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
 *  for the specific language governing permissions and limitations under the License.
 *
 *  Change History:
 *
 *    Date        Who            What
 *    ----        ---            ----
 *    2021-01-06  thebearmay	 Original version 0.1.0
 *    2021-01-07  thebearmay     Fix condition causing a loss notifications if they come in rapidly
 *    2021-01-07  thebearmay     Add alternative date format
 *    2021-01-07  thebearmay     Add last5H for horizontal display
 *    2021-01-07  thebearmay     Add leading date option
 *    2021-01-22  thebearmay     Add a span tag and id to allow custom CSS on the text
 * 
 */
import java.text.SimpleDateFormat
static String version()	{  return '1.1.0'  }

metadata {
    definition (
		name: "Notify Tile Device", 
		namespace: "thebearmay", 
		description: "Simple driver to act as a destination for notifications, and provide an attribute to display the last 5 on a tile.",
		author: "Jean P. May, Jr.",
	    	importURL:"https://raw.githubusercontent.com/thebearmay/hubitat/main/notifyTile.groovy"
	) {
       		capability "Notification"
			
	    	attribute "last5", "STRING"
            	attribute "last5H", "STRING"
            	attribute "notify1", "STRING"
            	attribute "notify2", "STRING"
            	attribute "notify3", "STRING"
            	attribute "notify4", "STRING"
            	attribute "notify5", "STRING"
		attribute "notificationText", "STRING"

		command "configure"//, [[name:"notification*", type:"STRING", description:"Notification Text"]]   
            
    }   
}

preferences {
	input("debugEnable", "bool", title: "Enable debug logging?")
    input("dfEU", "bool", title: "Use Date Format dd/MM/yyyy")
    input("leadingDate", "bool", title:"Use leading date instead of trailing")
}

def installed() {
	log.trace "installed()"
    configure()
}

def updated(){
	log.trace "updated()"
	if(debugEnable) runIn(1800,logsOff)
}

def deviceNotification(notification){
    sendEvent(name:"notificationText", value: notification)
    updateLast5(notification)
}

def updateLast5(notification){
    dateNow = new Date()
    if (dfEU)
        sdf= new SimpleDateFormat("dd/MM/yyyy HH:mm:ss")
    else
        sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss")
    if (leadingDate)
        notification = sdf.format(dateNow) + " " + notification
    else
        notification += " " + sdf.format(dateNow)
    last5 = "<span id='last5'>"+notification+"<br />"+device.currentValue("notify1")+"<br />"+device.currentValue("notify2")+"<br />"+device.currentValue("notify3")+"<br />"+device.currentValue("notify4")+"</span>"
    last5H = " ** "+last5.replaceAll("<br />"," ** ")+" ** "
    sendEvent(name:"notify5", value:device.currentValue("notify4"))
    sendEvent(name:"notify4", value:device.currentValue("notify3"))
    sendEvent(name:"notify3", value:device.currentValue("notify2"))
    sendEvent(name:"notify2", value:device.currentValue("notify1"))
    sendEvent(name:"last5", value:last5)
    sendEvent(name:"last5H", value:last5H)                                
    sendEvent(name:"notify1",value:notification)

}    

def configure() {
    sendEvent(name:"notificationText", value:" ")
    sendEvent(name:"last5H", value:" ")
    sendEvent(name:"last5", value:" ")
    sendEvent(name:"notify1", value:" ")
    sendEvent(name:"notify2", value:" ")
    sendEvent(name:"notify3", value:" ")
    sendEvent(name:"notify4", value:" ")
    sendEvent(name:"notify5", value:" ")
}

void logsOff(){
     device.updateSetting("debugEnable",[value:"false",type:"bool"])
}

For such tasks I use the App Tasker, which is an events/trigger driven programming environment for Android.

With Tasker you can intercept clicks on notifications, and e.g. then do a http-get to reach Hubitat by using it's Maker API.

I found this and I think I'm going to mess around with it this weekend.

Download the Hubitat app