please install the webthings gateway from here: https://github.com/WebThingsIO/gateway
inspired by https://github.com/tim-hellhake/azure-iot-bridge
the code is heavilly commented please check out the source code /src/
- Go to https://portal.azure.com/#create/hub
- Search for IoT Hub
- Click on Create
- Create your hub
- Wait for the deployment to be finished
- Under Deployment detail: click on our hub resource
- Go to Shared access policies
- Click on the iothubowner
- Copy the Connection string — primary key
- Add the connection string from step 9 to the config
- Go to http://[your-gateway]/oauth/authorize?response_type=code&client_id=local-token&scope=/things:readwrite
- Create a token
- Add the token to the config
- clone it
$ git clone https://github.com/JaycHub/fot-azureiothub.git
- go inside of fot-azureiothub folder
$ cd fot-azureiothub
- run
$ npm install
- package.sh is the script that will compile and create a runtime package that will be used by Webthings gateway, it will also copy it directly to .webthing/addons forlder for faster testing assuming you are developing the addon on the same machine that is running the Webthings gateway.
- so give the package.sh permission to execute :
$ chmod +x package.sh
- give permission to gather-licenses.js that will auto gather and compile all licenses from the node_module package into your LICENSE file:
chmod +x gather-licenses.js
- next run:
$ npm run build
- Open the addon page of the webthings gateway to configure the addon by copying teh authorization token from step 12 to the config page of the addon.
- everytime you change the source code of teh addon run the build command in step 6 .
- Enjoy!
- auto delete the device from Azure IoT hub when it is removed from the gateway's things list
- add option to create a digital twin
- Update the code to typescript