Skip to content

integrate with #thethingsystem #4

@mrose17

Description

@mrose17

hi. i just pushed an update to the repo for the steward that has the scaffolding you should need. i believe you can focus on the file gateway-zigbee-xstick.js

i think we need to work this in two steps:

step 1: add more scaffolding to that module so that it's ready to make calls to the internal steward APIs saying "i discovered this device" or "this device has updated its parameters"

step 2: i'll write a driver for one of these devices and hook it into the scaffolding. at that point, we can go through the list of devices that you have and i can show you how to do a driver. it's not that complicated.

ok, here's how the gateway-zigbee-xstick.js file works:

the start() function is invoked after the module is loaded. this defines the prototype function for /device/gateway/zigbee/xstick2-zb and then starts a function called scan that runs every 30 seconds.

the scan() function looks for USB devices matching a set of "fingerprints" that correspond to the digi stick. when a new one is found, it call invokes a callback within scan() that calls the internal API to discover a new device (in this case, the stick).

this results in the Gateway() function being new()'d to create an instance of the device driver. first, we have a bunch of instance assignments, then the driver subscribes to the 'actors' channel which is used to convey information about perform requests (among other things). if a perform request comes in for this particular device, then the perform() method is called.

both the validate_perform function and the perform() method are driven by Gateway.operations, an associative array. if the thing to be performed is a 'set', then this is handled internally, with devices.validate_perform, and the super method devices.perform(). otherwise, operations{} indicates how to proceed.

so, that's the scaffolding, now the part i'm clueless on. in the bottom half of the Gateway() function, there is a chained list of self.xstick.on() and self.xstick.zbee.on() handlers. this is where you need to add code that will figure out that zigbee devices are available, what kind of devices they are, and then get ready to invoke the internal API in the steward to create the corresponding instance.

does that make sense?

thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions