Get Device Group


#1

I want to create a Product Group called “Inventory” that keeps devices in a very ‘sleepy’ state.

The idea is that they will wake once a day, check to see if they have been moved out of the Inventory group. If they have then they will switch to a more ‘normal’ reporting frequency. (These happen to be solar powered devices).

I don’t see any device functions for doing this. Am I missing something?


#2

There is no way to obtain the device group from user firmware.

The intention is that device groups will be used to control the firmware flashed to the device, so different device groups will have different firmware, so there wouldn’t be a need to determine the group at runtime.

It’s not an unreasonable request, though because of the limited use cases and the difficulty in implementing it, it’s not clear how high of a priority it would be. But you can make a feature request by creating a Github issue in the cloud repository.

You might be able to do this with a webhook. You’d hit the devices endpoint and get the groups for the current device and return it to the device. I’m not positive this is possible, but it might be.


#3

I think it would be possible with a webhook like this:

{
    "event": "get-groups",
    "url": "https://api.particle.io/v1/products/productSlug/devices/{{{PARTICLE_DEVICE_ID}}}?access_token=MYPARTICLETOKEN",
    "requestType": "GET",
    "noDefaults": false,
    "rejectUnauthorized": true,
    "responseTemplate": "{{{groups}}}"
}