Charmed Quark Systems, Ltd. - Support Forums and Community
SmartThings API V1 driver - Printable Version

+- Charmed Quark Systems, Ltd. - Support Forums and Community (https://www.charmedquark.com/vb_forums)
+-- Forum: General Discussion (https://www.charmedquark.com/vb_forums/forumdisplay.php?fid=3)
+--- Forum: Driver Development (https://www.charmedquark.com/vb_forums/forumdisplay.php?fid=13)
+--- Thread: SmartThings API V1 driver (/showthread.php?tid=11225)



SmartThings API V1 driver - kfly - 02-01-2022

Looks like SmartThings released a new API “V1” that can give CQC access to 5,000+ devices.

Was trying to figure out how to add new unsupported devices into CQC and extend my CQC system for many years to come. As everyone knows there is no other HA system out that compares to the configurability of the GUI interface or the back-end control you get from CQC.

Here is a first cut of a driver.
Driver install prompts:
1. SmartThings Personal access token(PAT) (see below)
2. Polling Interval (default is 5)
3. SmartThings Hub Location ID  (driver needs to lookup the device ID)
4. List of devices to poll(cloud) in device type:name,,,,  format(see below)

Note:
  • It polls the SmartThings cloud API. (hopefully a local poll of hub will come soon)
  • It does one small status poll for each device at poll time. (so keep it to a small number of devices not supported by CQC)
  • Current device types supported are: lightswitch,dimmerswitch,doorlock,floodsensor.
  • Driver creates fields based on SmartThings device Names after a one time lookup on the hub. So if no ST_ field is created you may have a typo on your device configuration during driver install.
I have a SmartThings V3 Hub and currently use CQC as a secondary zwave controller.
After a few weeks of testing. Seems to work well at 5 seconds poll times.

You need to Generate a PAT(Personal Access Token)
https://account.smartthings.com/tokens
(as you will need a Bearer Token)

To get your LocationID   (Hub ID)
https://graph.api.smartthings.com/
If you drill down into your Hubs or Devices off that ,locationID, hubID, DeviceID  will be at end of the  url “897ssd87f-bc9d-433ae-d32e-a5bcb0f2xxxx”
This is what my URL looks like.
"https://graph-na04-useast2.api.smartthings.com/device/show/897ssd87f-bb9d-433ae-d32e-a5bcb0fxxxxx"

Devices to Poll:
Format is device type: name (example below)
Note: This is the name in SmartThings app or website.
lightswitch:Garage Lights,Landscape Lights&dimmerswitch:Foyer,Liv Rm Inside&doorlock:Front  Door Lock&floodsensor:Laundry Flood Sensor

[attachment=2551]

Please feel free to fix, enhance or change driver as needed
    maybe:
  • Do one larger all device stat poll and parse instead of many small polls.
  • Transition to local hub requests.(when available)
  • Add more device types(or a more elegant lookup table of some kind)
More info:
5,000+ devices compatibility on a SmartThings Hub.
www.smartthings.com/products-list
https://developer-preview.smartthings.com/api/public/#tag/Devices

Postman resources:
www.postman.com/smartthings/workspace/smartthings-s-public-workspace/collection/

Just change in Auth Tab to Bearer Token(and put your token or variable  in)
I had to change in Headers Tab: unclick the Accept KEY.
https://developer-preview.smartthings.com/docs/automations/scenes/
https://github.com/SmartThingsDevelopers/Sample-RulesAPI


RE: SmartThings API V1 testing driver - Shaky - 02-03-2022

That sounds like great news to extend the useful life of CQC, I think. To clarify. You are using just the SH hub and look to be able to communicate to it direct via CQC driver? and then indirectly communicate to the other SH supported devices via the CQC driver? or are you using Z-wave in this equation to make it work somehow too? Sorry, I have neither a SH or Z-wave in my current setup so not too familiar with either.

Sounds like you can get status of things. Assume you can you write to them too? (Like turn something on/off)?

If true I may have to look at getting a Smart Things hub here soon.


RE: SmartThings API V1 testing driver - kfly - 02-04-2022

(02-03-2022, 03:02 PM)Shaky Wrote: That sounds like great news to extend the useful life of CQC, I think.  To clarify.  You are using just the SH hub and look to be able to communicate to it direct via CQC driver? and then indirectly communicate to the other SH supported devices via the CQC driver? or are you using Z-wave in this equation to make it work somehow too?  Sorry, I have neither a SH or Z-wave in my current setup so not too familiar with either.

Sounds like you can get status of things.  Assume you can you write to them too?  (Like turn something on/off)? 

If true I may have to look at getting a Smart Things hub here soon.

Shaky,
This is just a Proof of concept test driver for now. It currently can turn on/off a one device attached to the smartthing hub. On Smartthings Hub you can attach both Z-wave and ZigBee. Currently this test driver uses the smartthings API V1 call to the cloud but since you can just query the individual capabilities the request is very small. example:

{
    "switch": {
        "value""off",
        "timestamp""2022-02-03T23:21:10.589Z"
    }
}


At the last SDC they did say they wanted to migrate away from a cloud request to a local smartthings hub request. Not sure how that would work but would think they would maintain the new V1 api format.
K


RE: SmartThings API V1 testing driver - Dean Roddey - 02-05-2022

BTW, apparently the Hue also now has a local API, or so I read someone talking about. And I think it also provides async notifications, so you don't have to poll it relentlessly.


RE: SmartThings API V1 testing driver - kfly - 02-07-2022

(02-05-2022, 03:25 PM)Dean Roddey Wrote: BTW, apparently the Hue also now has a local API, or so I read someone talking about. And I think it also provides async notifications, so you don't have to poll it relentlessly.

Yes, must cost them a fortune for all these API requests. Most of these edge devices are now Linux systems powerful enough to service local queries. We will see if these companies can give up central control of these requests and put up with all the headaches of a distributed architecture.


RE: SmartThings API V1 driver - kfly - 02-22-2022

Updated to version 0.5
- lookup of device ID by SmartThings Name
- Implemented general device types(lightswitch,dimmerswitch,doorlock,floodsensor.)
- YMMV, UAYOR and all other Acronyms apply Smile