I removed anything I could find for color on the device type yet it still crashed Smartthings. Even tried it with 2 other energy monitor devices
Was anyone be able to get this to work? I had the same exact problem. The app keeps crashing and restarting over
It looks like the current app crashes when you have the preference in there to set the icon
section("Select Icon") {
icon(title: "Pick an icon for the notification", required: true)
}
This code is lifted right from their documentation
I will push my changes to github later today.
James
Code has been updated in github
So even if required
is false
, this crashes the phone application if you do not pick an icon.
Iâve just installed this today and it worked great at notifying me when power usage on an Aeon Labs Smart Energy Switch (DSC06106-ZWUS) dropped below the threshold. I didnât change the default values for Enable Polling (off), polling interval (5 minutes), or Enable Debug Logging (off). The activity feed for SmartThings is getting filled every 5 minutes with the message âDryer Monitor sent poll command to Dryerâ. (Dryer Monitor is what I named the SmartApp and Dryer is the name of the Aeon switch.) Is that supposed to be happening? Is there a way to prevent the message from cluttering the feed? Thanks!
There was a bug in the code that always enabled polling. I have fixed it.
Try the latest code from github
I keep getting an internal error when trying to select this in devices
I am sorry. I donât understand your question.
This is a SmartApp. While I wrote it to work with the Aeon Labs DSC05106, it will work with any device type that provides the âpowerâ capability.
Are you having trouble with the SmartApp or a device type? There are instructions for adding this SmartApp above in this thread.
If you are having trouble with a device type, I would suggest posting in a thread about the device type you are having trouble with.
Itâs probably something on my end or smartthings back end . I canât change the device type in ide. Keep getting internal server error.
If you have added to code correctly in the IDE, go to the phone app and set it up there.
That should work.
Support is saying thatâs itâs something on their possibly. Has anyone else had luck changing to this device type?
This is a smartapps not a device handler (device type). You are getting the error because you are trying to create a device handler with this smartapps code.
Yea, Iâm dumbâŚ
Thanks, so used to doing to device types I just added there.
Thank you
So can this smart app with the aeon smart energy switch be set up to notify of a power outage?
My modem, router, and smartthings are on a UPS
I have this setup to monitor my washer and dryer to notify me when loads are done. I do laundry on a regular basis a few times a week so it is nice to have this functionality, however i have a suggestion.
It seems ineffective to continue to poll constantly when the devices are off and not consuming any power. It is however important to have the app poll the devices when they are on, in order to know when they turn off.
Is it possible to have a âlow stateâ poll for the time when the device is off, and once it notices the device is on, switch into a higher frequency polling state?
If you have a good device type, there is no reason to poll the device. so the polling option can be turned off. That option is in there for device types that donât use events to report their power consumption.
I have written a few device types for the Aeon Labs devices, if you are using one of my device types then they will report values when the power changes.
I hope you donât mind, I wrote a 1.3.0 version to utilize Contact Book for notifications.
Thanks for the great app!
/**
* Yet Another Power Monitor
*
* Copyright 2015 Elastic Development
*
* 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.
*
* The latest version of this file can be found at:
* https://github.com/jpansarasa/SmartThings/blob/master/SmartApps/YetAnotherPowerMonitor.groovy
*
* Revision History
* ----------------
*
* 2015-01-04: Version: 1.0.0
* Initial Revision
* 2015-01-05: Version: 1.0.1
* Reorganized preferences section
* 2015-01-18: Version: 1.1.0
* Added option to disable polling
* 2015-10-02: Version: 1.2.0
* Removed the code to set the icon since it crashed the app on the phone
* 2016-07-11: Version: 1.3.0
* Switched to using contact book for notifications
*
*/
definition(
name: "Yet Another Power Monitor",
namespace: "elasticdev",
author: "James P",
description: "Using power monitoring switch, monitor for a change in power consumption, and alert when the power draw stops.",
category: "Convenience",
iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png",
iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png",
iconX3Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png")
preferences {
section("About") {
paragraph "Using power monitoring switch, monitor for a change in power consumption, and alert when the power draw stops."
paragraph "Version 1.3"
}
section ("When this device stops drawing power") {
input "meter", "capability.powerMeter", multiple: false, required: true
}
section ("Advanced options", hidden: true, hideable: true) {
input "upperThreshold", "number", title: "start when power raises above (W)", description: "10", defaultValue: 10, required: true
input "lowerThreshold", "number", title: "stop when power drops below (W)", description: "5", defaultValue: 5, required: true
}
section ("Send this message") {
input "message", "text", title: "Notification message", description: "Washer is done!", required: true
}
section ("Notification method") {
input("recipients", "contact", title: "Send notifications to") {
input "phone", "phone", title: "Notify with text message (optional)",
description: "Phone Number", required: false
}
}
section ("Additionally", hidden: hideOptionsSection(), hideable: true) {
input "enablePolling", "boolean", title: "Enable polling?", defaultValue: false
input "interval", "number", title: "Polling interval in minutes:", description: "5", defaultValue: 5
input "debugOutput", "boolean", title: "Enable debug logging?", defaultValue: false
}
}
def installed() {
log.trace "Installed with settings: ${settings}"
initialize()
}
def updated() {
log.trace "Updated with settings: ${settings}"
unsubscribe()
initialize()
}
/**
* Initialize the script
*
* Create the scheduled event subscribe to the power event
*/
def initialize() {
//Set the initial state
state.cycleOn = false
state.cycleStart = null
state.cycleEnd = null
state.debug = (debugOutput) ? debugOutput.toBoolean() : false
//Schedule the tickler to run on the defined interval
def pollingInterval = (interval) ? interval : 5
def ticklerSchedule = "0 0/${pollingInterval} * * * ?"
if (state.debug) {
if (enablePolling && enablePolling.toBoolean()) {
log.debug "Polling every ${pollingInterval} minutes"
}
else {
log.debug "Polling disabled"
}
}
if (enablePolling && enablePolling.toBoolean()) {
schedule(ticklerSchedule, tickler)
}
subscribe(meter, "power", powerHandler)
}
/**
* Scheduled event handler
*
* Called at the specified interval to poll the metering switch.
* This keeps the device active otherwise the power events do not get sent
*
* evt The scheduler event (always null)
*/
def tickler(evt) {
meter.poll()
def currPower = meter.currentValue("power")
if (state.debug && currPower > upperThreshold) {
log.debug "Power ${currPower}W above threshold of ${upperThreshold}W"
}
else if (state.debug && currPower <= lowerThreshold) {
log.debug "Power ${currPower}W below threshold of ${lowerThreshold}W"
}
}
/**
* Power event handler
*
* Called when there is a change in the power value.
*
* evt The power event
*/
def powerHandler(evt) {
if (state.debug) {
log.debug "power evt: ${evt}"
log.debug "state: ${state}"
}
def currPower = meter.currentValue("power")
log.trace "Power: ${currPower}W"
//If cycle is not on and power exceeds upper threshold, start the cycle
if (!state.cycleOn && currPower > upperThreshold) {
state.cycleOn = true
state.cycleStart = now()
log.trace "Cycle started."
}
// If the device stops drawing power, the cycle is complete, send notification.
else if (state.cycleOn && currPower <= lowerThreshold) {
send(message)
state.cycleOn = false
state.cycleEnd = now()
def duration = state.cycleEnd - state.cycleStart
log.trace "Cycle ended after ${duration} minutes."
}
}
/**
* Sends the messages to the subscribers
*
* msg The string message to send to the subscribers
*/
private send(msg) {
if (location.contactBookEnabled && recipients) {
sendNotificationToContacts(msg, recipients)
} else if (phone) { // check that the user did select a phone number
sendSms(phone, msg)
}
if (state.debug) {
log.debug msg
}
}
/**
* Enables/Disables the optional section
*/
private hideOptionsSection() {
(interval || debugOutput) ? false : true
}
//EOF
Thanks for the update!
Mind if I merge it into my git repo?
Absolutely! Thanks!