Developing an Add-on for the Project Issues Gateway

The Project Things Gateway exists as a platform to create all of your IoT devices together within unified umbrella, using a standardized HTTP-based API. Currently, the platform only offers support for a limited number of gadgets, and we need your help growing our reach! It is fairly simple to add support for new devices, and we’ll walk you through how to achieve this. The best part: you can use whatever programming vocabulary you’ d like!

High-Level Concepts

Addition

An Add-on is a number of code that the Gateway runs to get a new features, usually a new adapter. This is loosely modeled after the accessory system in Opera where each add-on adds to the efficiency of your Gateway in new plus exciting ways.

Adapter

An Adapter is an item that manages communication with a gadget or set of devices. This could be really granular, such as one adapter item communicating with one GPIO pin, or even it could be much more broad, such as a single adapter communicating with any number of devices more than WiFi. You decide!

Gadget

A Device is just that will, a hardware device, such as an intelligent plug, light bulb, or temperature messf├╝hler.

Property

A Property is an individual property of the device, such as its on/off condition, its energy usage, or the color.

Supported Dialects

Add-ons have been composed in Node. js, Python, plus Rust so far, and official JavaScript and Python bindings are available at the gateway platform. If you want to skip forward, you can check out the list of examples now. However , you are free to create an add-on in whatever vocabulary you choose, provided the following:

  • Your add-on is correctly packaged .
  • Your own add-on package bundles all needed dependencies that do not already can be found on the gateway platform.
  • If your package contains any put together binaries, they must be compiled for your armv6l architecture. All Raspberry Professional indemnity families are compatible with this particular architecture. The easiest way to do this would be to create your package on a Raspberry Pi 1/2/Zero.

Implementation: The particular Nitty Gritty

Evaluate Your own Target Device

Initial, you need to think about the device(s) you’ lso are trying to target.

  • Will your add-on be conntacting one or many devices?
  • How will the add-on communicate with the particular device(s)? Is a separate hardware kopierschutzstecker required?
    • For example , the particular Zigbee and Z-Wave adapters need a separate USB dongle to get in touch with devices.
  • What properties do these devices have got?
  • Is there an existing Factor type that you can advertise?
  • Are there existing libraries you can use approach your device?
    • You’ d be surprised by the number of NPM modules, Python modules, C/C++ libraries, etc . exist for conntacting IoT devices.

The key here is to get a strong understanding of the devices you’ re trying to support.

Start from an Example

The simplest way to start development is to start with among the existing addons (listed further down). You can download, copy and insert, or git clone one of them directly into:

  /home/pi/mozilla-iot/gateway/build/addons/ 
 

Alternatively, you can do your own development on a different machine. Just be sure you test on the Raspberry Professional indemnity.

After doing so, you need to edit the package deal. json file because appropriate. In particular, the name field must match the name of the directory you just produced.

Next, begin to modify the code. The key parts of the particular add-on lifecycle are device development and property updates. Device development typically happens as part of a breakthrough process, whether that’ s via SSDP , probing serial gadgets, or something else. After discovering gadgets, you need to build up their property lists, plus make sure you handle property changes (that could be through events you get, or perhaps you may have to poll your devices). Additionally you need to handle property updates through the user.

Restart the particular gateway process to test your modifications:

 $ sudo systemctl restart mozilla-iot-gateway. service 
 

Test your add-on completely. You can enable it through the Settings-> Add-ons menu in the UI.

Get Your Add-on Published!

Run . /package. you will need or whatever else you need to do to package up your add-on. Web host the package somewhere, i. electronic. on Github as a release. After that, submit a pull request or even issues to the addon-list repository.

Notes

  • Your add-on will run in the separate process and communicate with the particular gateway process via nanomsg IPC. That should hopefully be irrelevant for you.
  • If your add-on procedure dies, it will automatically be restarted.

Examples

The Project Things group has built several add-ons that can act as a good starting point and reference.

Node. js:

Python:

Rust:

References

Extra documentation, API references, etc ., are available here:

Find an insect in some of our software? Let us know! We’ d love to have issues, or even better yet, pull requests, filed towards the appropriate Github repo.

Degree 24 Computer Wizard on a mission to keep the Internet of Things free of charge and open.

More articles simply by James Hobin…

Michael is a software engineer with Mozilla working on Project Things.

A lot more articles by Michael Stegeman…

If you liked Developing an Add-on for the Project Issues Gateway by James Hobin Then you'll love Web Design Agency Miami

Add a Comment

Your email address will not be published. Required fields are marked *

Shares