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.currentValue('power')
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?
@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
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.
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.
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.
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.
The simple answer to this problem of “losing” the decimal portion is this (from my own Aeon HEMv2+):
Add attribute "powerDisp", "string" to the header of the device code
Change the tile’s name from “power” to “powerDisp”
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.