Kind ST Community:
I’ve spent several days now trying to self-service this question, and pored over many threads ranging from the Architecture documentation, completed the SmartApp Tutorial (and have a working instance of the sample REST Web Service SmartApp which lists and allows controls of switches – but I’m having real trouble making the leap from this working / documented example - to interfacing with the powerMeter and energyMeter capabilities available from several of my devices.
I’m using the AeoTec Smart Switch 6, the ZooZ ZEN06, AeoTec SmartStrip, etc - and would be stoked to make any of them work (e.g. expose a REST endpoint allowing me to poll the Energy/Power Metering functions.
I’ve installed and am successfully using relevant custom DTH’s for each of the above devices - and they’re working as expected when viewed in the SmartThings mobile app (meaning - I know the DTH is properly communicating with the device, and that the data is available). I can also see this by watching the LiveLogging in the IDE, and seeing the results from each device (volts, amps, watts, KwH) on the configured interval.
Where I’m tripped up is on the syntax. I’m not a coder, by trade - and definitely have no previous experience with Groovy. As I’m looking at the syntax in the sample Web Service SmartApp - I’m struggling to discern what might be standard Groovy syntax, and what might be “SmartThings convention” - specifically, for reading attributes like:
it.displayName or it.currentValue
I’d be happy to RTFM - if I could only find the right manual. I’ve pored over my GitHub repos than I care to admit, and have found multiple examples that are close to what I want - but with differences significant enough to throw me off the scent. One example achieved what I wanted, but published (pushed) events to an API, rather than exposing an API endpoint to query them, etc.
I’m certain that all the information I need is there - included in the DTH that I’m using (which describes all the capabilities, including:
as well as device.energy, device.power, etc. Yet, somehow - I’m missing the puzzle pieces (e.g. the specific syntax I would use in a SmartApp) to query / return these values.
I’m managed to modify the sample Web Services SmartApp enough such that, in the simulator (or mobile app) it will present me a list of my four devices which have (for example) PowerMeter capabilities. I can publish the app, select one (or more) of them, and see them in a list (in the Simulator) - but no clue as to the code required to query / respond with the powerMeter values.
I’m hoping I don’t have to get so deep down the rabbit hole as to have to grok the low-level Z-Wave commands, ala:
0x32 COMMAND_CLASS_METER V3 Implemented
to achieve my goal - but if that’s what it takes, I’m ready to have a go. Would welcome / deeply appreciate any pointers to sample/example code, documentation, other forum threads, or anything which might help me on this journey. I can certainly share a link to / copy of my current (modified) Web Services Smart App, if that would prove helpful.
Thanks in advance for any guidance / hand-holding / 2x4 to the forehead,