I’m very new to writing smartapp using nodeJS smartapp SDK.
I’m trying to get the power usage data from a smart light bulb, and displaying it on smartapp.
Is it possible? I don’t have devices like smart plug but only lightbulb. And I wonder how can I get data only using smart light bulb. If it is possible, would anyone provide me any advice or sample code about doing this?
Welcome to the SmartThings Community, @marui!
The data that you can get from the devices depend on its handler. This is because the device’s metadata is defined there (capabilities, presentation, etc.)
You can check which capabilities your device includes by making a query to the ST API, follow the steps below:
Create a Personal Access Token (PAT). It must include at least the Devices scope. Note: Once it’s created, save it securely as it won’t appear again.
Get a client to make REST API requests, eg. Postman
In the Authorization tab, select a Bearer Token type and enter your PAT
Enter the URL and corresponding type of the request
Get the list of all the installed devices, this includes the list of supported
capabilities in each device. For example:
I suppose there could be one, but I don’t know of any smart lightbulbs that have an energy monitoring feature. Most of these devices draw under 10 W at maximum anyway, so the energy cost of observing and reporting energy use would probably cost more than any potential savings.
For example, there aren’t even any clusters for Zigbee lightbulbs to report energy use.
You can tell if the bulb is on or off, and in many cases you can get the brightness level setting, but not the actual energy draw.
In contrast, there are quite a few smart plugs and a few smart switches that can report energy draw. So in those cases, your example would apply: if the DTH/edge driver exposes the energy draw values, you would be able to access them.
So it comes down to the specific use case, but for most bulbs you would just use “on” as a proxy for the maximum draw.