Power vs. Energy

(Jody) #1

There are two capabilities listed in the taxonomy. power Meter and energy Meter. What is the difference? @ben or @urman?

Also when I try and use


It throws this error: java.lang.NumberFormatException

@wackware it appears the numberFormatException is because your tcp device type is returning a string “21.8 Watt(S)” for the current value. Is there a way to get just the decimal value?

(Paul) #2

I believe powerMeter reports real time power in Watts, and energyMeter reports kWh usage since the last the it was refreshed on the device.

currentValue(“power”) should return a decimal value… make sure you’re using (“power”) and not (‘power’)

(Jody) #3

@NorCalLights figured it out. @wackware might be able to resolve this. The currentValue for power on the tcp bulbs is returning a string. My smart outlet works fine with this code, returning a decimal value. In the logs the currentValue for the tcp bulb is returning the string “21.8 Watt(s)” rather than just the decimal 21.8

(Jody) #4

The problem is on lines 244-245

 def reportPower = calcPower.round(1) as String
 reportPower += " Watt(s)"

This should just return a the decimal value.

Changing it to

def reportPower = calcPower.round(1) 

Resolves the issue, but I would have to redo my entire light setup.

(Todd Wackford) #5

Hi @jodyalbritton,

Thanks for pointing it out. I have changed all of the power consumption calcs for the upcoming release. The only downside is the display of the power. Now the font size is super small and only displays the value to the left of the decimal.

(Jody) #6

I could not find the device type code for the tcp bulb, but it could be fixed at the tile.

(Todd Wackford) #7

I fixed the power on my current version. But, by making it number instead of a string, it no longer will display the decimal point value. So now you see:
4 watts, instead of
3.6 watts.
Also the font size varies on iOS devices.

Do I make sense?

(Jody) #8

Is the smart app spawning new child devices? I would remove the decimal rounding in the smart app, and parse it in the child device type if you have those.

(Jody) #9

Took a look at your code, but since I can’t see the child device type here is my best guess. Remove the rounding then in the device type fix the tile like this.

valueTile("power", "device.power", inactiveLabel: false) {
        	state "default", label:'${currentValue} ${unit}', unit: "Watts"

(Andrew Urman) #10

power - current draw
energy - total cumulative draw

(Barry) #11

The simple answer to this problem of “losing” the decimal portion is this (from my own Aeon HEMv2+):

  1. Add attribute "powerDisp", "string" to the header of the device code
  2. Change the tile’s name from “power” to “powerDisp”
  3. Now, add TWO sendEvents where the value is calculated: one for name “power” (the decimal value) and one for name “powerDisp” (the formatted value, with Watts, if desired.

This sends a formatted string to update the tile, and the raw decimal value for use/collection by other applications.

While rather lengthy, you can see how I use this approach here: SANdood’s GitHub for Aeon HEMv2+

(Jody) #12

Very nice work @storageanarchy. My Aeon HEM will be here on Thursday, so this was perfect timing.

(Todd Wackford) #13


Thanks for the workaround. I submitted a ticket to support to display values as passed.