Log multiple actions...?


(Tim Slagle) #1

Hey guys,

Need some help here. I am looking for a way to log multiple actions in an app i created/modified. I took the scenes app i found on here and added thermostat capability to it. But what i would like to do is add logging that would post to the “Hello, Home” log. I was thinking something like this…

def message(Hi, i turned off the Dinning Room, Upstairs Office, and Kitchen Lights)
sendNotificationEvent(message)
def message(Hi, I Tuned on the Porch Light as well as the Basement Light)
sendNotificationEvent(message)

What i need help with is how to create the string that will make the message up. The app i am going to be adding this logging to is below. I can’t figure out how to collect the multiple lights I select in the various sections to a string so they will pull the lights i select from each section into the string when the app runs. Any help would be appreciated!!

preferences {
	section("When I Change To This Mode") {
	input "newMode", "mode", title: "Mode?"       
    }
	section("Dim These Lights") {
	input "MultilevelSwitch", "capability.switchLevel", multiple: true, required: false 
    input "number", "number", title: "Percentage, 0-99", required: false
    }    
	section("Turn On These Switches"){
	input "switcheson", "capability.switch", multiple: true, required: false
	}
	section("Turn Off These Switches"){
	input "switchesoff", "capability.switch", multiple: true, required: false
	}
    section("Choose thermostat... ") {
		input "thermostat", "capability.thermostat"
		input "heatingSetpoint", "number", title: "Heat - Degrees Fahrenheit?"
		input "coolingSetpoint", "number", title: "Cool - Degrees Fahrenheit?"
	}
}

def installed() {
subscribe(thermostat, "heatingSetpoint", heatingSetpointHandler)
subscribe(thermostat, "coolingSetpoint", coolingSetpointHandler)
subscribe(thermostat, "temperature", temperatureHandler)
subscribe(location)
subscribe(app)
}

def updated() {
unsubscribe()
subscribe(thermostat, "heatingSetpoint", heatingSetpointHandler)
subscribe(thermostat, "coolingSetpoint", coolingSetpointHandler)
subscribe(thermostat, "temperature", temperatureHandler)
subscribe(location)
subscribe(app)
}

def uninstalled() {
unsubscribe()
}

def changedLocationMode(evt) {
    switcheson?.on()
    switchesoff?.off()
    settings.MultilevelSwitch?.setLevel(number)
    thermostat.setHeatingSetpoint(heatingSetpoint)
	thermostat.setCoolingSetpoint(coolingSetpoint)
}

def appTouch(evt) {
    switcheson?.on()
    switchesoff?.off()
    settings.MultilevelSwitch?.setLevel(number)
    thermostat.setHeatingSetpoint(heatingSetpoint)
	thermostat.setCoolingSetpoint(coolingSetpoint)
}

(Steve S) #2

@tslagle13 - I believe all you need to do is something like:

sendNotificationEvent(“I turned on the ${switcheson} lights.”)

I don’t think the grammar will be 100% correct because it will look like:

“I Turned on the bedroom, office, kitchen lights.”

If you wanted to get fancier, you’d have to create a list and loop through it putting an “and” before the last one.


(Tim Slagle) #3

yeah i was trying to get fancier but it might be too much trouble for what its worth. im just going to stick with what you gave me. Thanks @stevesell