SmartThings Community

Smart Power Outlet, configure/disable energy reporting?


(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy) #19

Thanks, Bud…

But save me from diff-ing… What do did you change?


(Mike Maxwell) #20

//power config for devices with min reporting interval as 1 seconds and reporting interval if no activity as 10min (600s)
//min change in value is 01
def powerConfig() {
[
“zdo bind 0x${device.deviceNetworkId} 1 ${endpointId} 0x0B04 {${device.zigbeeId}} {}”, “delay 200”,
“zcl global send-me-a-report 0x0B04 0x050B 0x29 6400 6401 {64 0000}”, //The send-me-a-report is custom to the attribute type for CentraLite
"send 0x${device.deviceNetworkId} 1 ${endpointId}", “delay 500”
]
}


Reducing power reporting noise in a device type
(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy) #21

Excellent!

Easy enough to also add parameters to the DTH and call “config”, right?

I’ll put together a pull request on the official one … only if you @Mike_Maxwell and @simi510 don’t plan on doing so yourselves???


(Mike Maxwell) #22

Go for it, It’s all you baby!
Be bold, make it a preference option, as it should be…


(Simi510) #23

please do. it was driving me nuts all the spam.


(ilker Aktuna) #24

Hi,

I can’t see any “600” or “01” within this part. How can I configure a different setting ?
Btw, has anyone made a configurable version of this ?

Thanks.


( I hate Mondays) #25

Last I tried to do that exact same change for the same exact devices, I ended up using some back channels and nothing came out of that either ;( It’s interesting to note that the official DTH defaults the device to very noisy, possibly affecting the ST cloud but the relevant people in ST didn’t really seem interested. Good luck :wink:


(Timothy Martin) #26

Yup, I posted my code in a different thread… This gives you settings in the app to turn power logging on/off entirely or change the threshold required for reported changes.

What i really want is the ability to have the live updated “tile” but just only show the larger more important changes in the “recent activity”. If anyone knows how to send events in such a way, that’d be amazing :wink:


(ilker Aktuna) #27

Hi,

I am trying your dev. handler.
But even though I select to show changes the app does not show any changes.
when I trun back to original code it shows updates. (too frequently)

where is the complete code for your dev. handler ?

thx.


(Timothy Martin) #28

Sure. It’s here:


Power/Energy Monitoring?
(ilker Aktuna) #29

Ok. I installed this and updated my device with this dev. handler. Then I used the settings to enable “show power in activity feed” and "only if power changes by 2"
However, now it does not show any changes , neither in activity feed nor the device interface
Why ?


(Timothy Martin) #30

I dunno, i just tested it again and it works for me. This is my first DTH hack so admittedly I might not have done it right. I’d love feedback from anyone who’s more advanced than I am…


(ilker Aktuna) #31

well, the dev. handler works for turning on/off the device.
However, it does not show the power on the device interface and it does not report power on notification feed.
but here in this case I did not install it from zero. I just replaced the original device handler with this one on device page.
then I edited the device for setting up :

  1. “show power in activity feed”
  2. “only if power changes by 2”

what might I be doing wrong ?

btw my device is from UK , so its not the US type.


(Timothy Martin) #32

That’s the same way I installed it. Edit the device and pick my “published for me” DTH. I don’t see how anything I did would make a difference between UK/US. The IDE simulator and testing doesn’t work worth a darn, so I don’t have much I can do to figure out why it’s not working for you.


(Chris) #33

I’m having the exact same issue and also in the UK. Probably coincidence…

Is there any debugging we can add to the code to see how far the code is getting? It just seems to stop reporting Event Type: Power as soon as I switch to your code.

I had a bit of a fiddle and moved the event generation back into the main IF block and it only seems to generate an event if I press the refresh tile in the app. So it looks to be something supressing the event creation?

else if (finalResult.type == "power") {
		def powerValue = (finalResult.value as Integer)/10
        event = createEvent(name: "power", value: powerValue, displayed: true, descriptionText: '{{ device.displayName }} power is {{ value }} Watts', translatable: true)
        def changeValue = powerValue - state.lastPowerValue

		if (changeValue < 0) {
        	changeValue = -changeValue
		}
        
        if (prefLogPower == true) {
        	if (changeValue > prefLogPowerDelta || powerValue == 0 || state.lastPowerValue == 0) {
	            event = createEvent(name: "power", value: powerValue, displayed: true, descriptionText: '{{ device.displayName }} power is {{ value }} Watts', translatable: true)
                state.lastPowerValue = powerValue
            } else {
            	event = createEvent(name: "power", value: powerValue, displayed: false, descriptionText: '{{ device.displayName }} power is {{ value }} Watts', translatable: true)
            }
        } else {
            event = createEvent(name: "power", value: powerValue, displayed: false, descriptionText: '{{ device.displayName }} power is {{ value }} Watts', translatable: true)
        }

(Mike DeRousse) #34

I was having the same problem and I checked the live logging and noticed an exception on line 99 where the value of state.lastPowerValue is used. I added a debug statement there and found that it’s value was null.

I’m completely new to device handlers (just got my hub a couple of days ago) but I’m suspecting that the configure() method (where you first initialize the value of state.lastPowerValue) isn’t being called when we just change the device handler in the developer tools. Is it maybe only called when the switch is first added to the network or initialized?

In any case, I added an extra statement at the beginning of parse() which checks if state.lastPowerValue is null, and if so, initializes it to zero. Now, I’m not getting the exception in the logs, the events are only showing when the change exceeds my configured value, and the tile is updating normally.


(Alan Davis) #35

Hey InstantTim, have you gotten this to work on multiple outlets at the same time? I included the null statement check that derousse mentioned (thanks btw!), and am able to get the device handler working with only one outlet.


(Timothy Martin) #36

I updated my file on GitHub with the same fix… But I find testing so difficult with this environment I honestly am not sure it’s working. It appears as though it no longer works, but since the simulator doesn’t work I have really no idea how to debug device handlers worth a damn.


(Timothy Martin) #37

Okay, the publicly available DTH had a LOT of changes I hadn’t kept up with. I pulled in all those changes and cleaned up the logic for recent activity logging a bit.

I now have this installed on two devices in my house and it appears to be working fine for me. The tiles update live, but the feed only shows changes based on my preference on/off and the wattage threshold value.


Turn Off Power Notifications on SmartThings Power Outlet
#38

Are any of these settings local to the device, thus limiting network traffic, or all at the hub or cloud level? Also, not related to this DTH per se, but when you reset and reconnect, how does it know to choose the new custom handler instead of the old one? Is the reset required or just change in the IDE ok?