Notify Me When app - change of text

Hello, is there anyway to modify the Notify Me When app to change the text? For example i am getting Garage door sensor contact is open. How can i have this as Garage sensor - open. I dont want the type or the word is in there
Another example : Motion Sensors motion is active. I want that to say Motion Sensors - active
Thanks for the help

When you install the application there should have been an error where you can edit the alerts based on the items that you are receiving the alerts from. It should have been on the main page you just need to scroll down after selecting the senors.

You will need to modify the code to remove the hard coded words like ‘motion’ or ‘contact’. It is set like ‘your sensor name’ + ‘contact’. If you are uncomfortable playing with the code, I’ll help you tomorrow.

Thanks Bobby, it looks like the message is coming from somewhere else? I cannot easily see where i would do the modification.
The smartapp code is here:

/**
 *  Copyright 2015 SmartThings
 *
 *  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.
 *
 *  Notify Me When
 *
 *  Author: SmartThings
 *  Date: 2013-03-20
 *
 * Change Log:
 *    1. Todd Wackford
 *    2014-10-03:    Added capability.button device picker and button.pushed event subscription. For Doorbell.
 */
definition(
    name: "Notify Me When",
    namespace: "smartthings",
    author: "SmartThings",
    description: "Receive notifications when anything happens in your home.",
    category: "Convenience",
    iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/window_contact.png",
    iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/window_contact@2x.png"
)

preferences {
    section("Choose one or more, when..."){
        input "button", "capability.button", title: "Button Pushed", required: false, multiple: true //tw
        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 message (optional, sends standard status message if not specified)"){
        input "messageText", "text", title: "Message Text", required: false
    }
    section("Via a push notification and/or an SMS message"){
        input("recipients", "contact", title: "Send notifications to") {
            input "phone", "phone", title: "Phone Number (for SMS, optional)", required: false
            input "pushAndPhone", "enum", title: "Both Push and SMS?", required: false, options: ["Yes", "No"]
        }
    }
    section("Minimum time between messages (optional, defaults to every message)") {
        input "frequency", "decimal", title: "Minutes", required: false
    }
}

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

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

def subscribeToEvents() {
    subscribe(button, "button.pushed", eventHandler) //tw
    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) {
    log.debug "Notify got evt ${evt}"
    if (frequency) {
        def lastTime = state[evt.deviceId]
        if (lastTime == null || now() - lastTime >= frequency * 60000) {
            sendMessage(evt)
        }
    }
    else {
        sendMessage(evt)
    }
}

private sendMessage(evt) {
    def msg = messageText ?: defaultText(evt)
    log.debug "$evt.name:$evt.value, pushAndPhone:$pushAndPhone, '$msg'"

    if (location.contactBookEnabled) {
        sendNotificationToContacts(msg, recipients)
    }
    else {

        if (!phone || pushAndPhone != "No") {
            log.debug "sending push"
            sendPush(msg)
        }
        if (phone) {
            log.debug "sending SMS"
            sendSms(phone, msg)
        }
    }
    if (frequency) {
        state[evt.deviceId] = now()
    }
}

private defaultText(evt) {
    if (evt.name == "presence") {
        if (evt.value == "present") {
            if (includeArticle) {
                "$evt.linkText has arrived at the $location.name"
            }
            else {
                "$evt.linkText has arrived at $location.name"
            }
        }
        else {
            if (includeArticle) {
                "$evt.linkText has left the $location.name"
            }
            else {
                "$evt.linkText has left $location.name"
            }
        }
    }
    else {
        evt.descriptionText
    }
}

private getIncludeArticle() {
    def name = location.name.toLowerCase()
    def segs = name.split(" ")
    !(["work","home"].contains(name) || (segs.size() > 1 && (["the","my","a","an"].contains(segs[0]) || segs[0].endsWith("'s"))))
}

Ok, so the default message is pretty straight forward. For contacts it throws this default message - “your sensor name” was opened and for motion sensors, it generates this message “your sensor name” detected motion. I can change the app to say: “your sensor name” - open and “your sensor name” - active. Alternatively, if you install one instance of the app for each sensor you want to be notified, then you can fill in the “message text” box with the custom message you’d like to get, and that will overwrite the default message (so you don’t need to change the name of your devices).

I see, so i think the best idea is to do this:
make 1 app, and depending the event (ie, motion, switch or contact) using an if statement it would say :smile: “your sensor name” - open and “your sensor name” - active.
Could you help me with this?
Thannks

Sure but I think you’d be happier to set up multiple instances of the app, because it sounds like the name of the devices is not what you want to see. If you add a message you could say “garage open” instead of garage door sensor - open.

i see.
But couldnt i do something like:
if event.name “garageDoor” then text = Garagedoor - & state
if event.name “MotionsLivingRoom” then text = Living room motions - & state
if event.type “switch” then text = event.name - & state

?

ok so i found out how to do it:

private defaultText(evt) {
    if (evt.name == "presence") {
        if (evt.value == "present") {
            if (includeArticle) {
                "$evt.linkText has arrived at the $location.name"
            }
            else {
                "$evt.linkText has arrived at $location.name"
            }
        }
        else {
            if (includeArticle) {
                "$evt.linkText has left the $location.name"
            }
            else {
                "$evt.linkText has left $location.name"
            }
        }
    }
    else {
        //evt.descriptionText
        if (evt.name == "contact"){
            log.debug " its a contact event"
            log.debug "$evt.displayName is now $evt.value"
            "$evt.displayName is now $evt.value"
        } 
        else if (evt.name == "switch"){
            log.debug " its a switch event"
            log.debug "$evt.displayName is now $evt.value"
            "$evt.displayName is now $evt.value"
        } 
        else if (evt.name == "motion"){
            log.debug " its a motion event"
            log.debug "$evt.displayName is now $evt.value"
            "$evt.displayName detected a movement"
        }            
    }
}

What do you think?
It works without issues