Subscription example

Is there an example of either a webthing or an add-on subscribing to changes of a property in another thing?

I’m interested in having a watcher that subscribes to property status changes in a thing and reacts (possibly by propagating that change to other things).

I see the websocket API defines this, but I’m wondering if there’s something in webthing or gateway_addon or similar that helps with doing so. If not, it’d be helpful to see an example that actually makes this request.

The Azure IoT Bridge add-on (from @t1m1) does this. See here: https://github.com/tim-hellhake/azure-iot-bridge/blob/master/src/azure-iot-bridge.ts

That’s really helpful, thank you!

I see since it’s an adapter it can reference localhost:8080${device.href}.

I’d love to start experimenting with an add-on that had some custom virtual things. Is there any advice on how to develop an add-on locally? I have a pi running for my actual hub right now, but I imagine it’s easiest to develop on a separate machine, possibly with docker, and then only push your add-on to the pi once it’s working?

If you’re comfortable with Docker, then yes, that’s probably easier than working on your active Pi gateway.

What I would do is this:

  • Run our Docker image, sharing in a directory for the user profile.
  • Do your development directly in that shared directory, under addons/<your-addon-id>.
  • Restart Docker container (or just the add-on, through the Settings UI) to test your changes.

If you have a .git directory within your add-on directory, the gateway will bypass any checksum verification and such. The easiest thing is probably to clone an existing add-on and start changing things as required.