Properly create event for outlet power

We were not properly creating the event before returning it, causing us
to not actually generate the power event.

This resolves: https://smartthings.atlassian.net/browse/PROB-1518
This commit is contained in:
Zach Varberg
2017-02-15 13:22:43 -06:00
parent 81550ee25c
commit c6d6ba85f5
2 changed files with 5 additions and 5 deletions

View File

@@ -79,7 +79,8 @@ def parse(String description) {
*/
event.value = event.value / 10
}
return event
return event ? createEvent(event) : event
}
def setLevel(value) {

View File

@@ -83,9 +83,8 @@ def parse(String description) {
if (event) {
if (event.name == "power") {
event.value = event.value / 10
event.descriptionText = '{{ device.displayName }} power is {{ value }} Watts'
event.translatable = true
def value = (event.value as Integer) / 10
event = createEvent(name: event.name, value: value, descriptionText: '{{ device.displayName }} power is {{ value }} Watts', translatable: true)
} else if (event.name == "switch") {
def descriptionText = event.value == "on" ? '{{ device.displayName }} is On' : '{{ device.displayName }} is Off'
event = createEvent(name: event.name, value: event.value, descriptionText: descriptionText, translatable: true)
@@ -106,7 +105,7 @@ def parse(String description) {
log.debug "${cluster}"
}
}
return event
return event ? createEvent(event) : event
}
def off() {