Tutorial Intro
Calls to the Connect Mesh Web API need to be authenticated. In order to use it, you can either create a Token that is valid only for your account, or alternativly create a OAuth2 client that allows you to create applications and control your users networks on their behalf after they have linked their Connect Mesh Cloud account with your service.
Creating a mesh network and setup a gateway
Use the Häfele Connect Mesh App [Google Play/App Store] to setup a mesh network you want to control. If you want to try out the example application, also create a group which you want to use for demo purposes (make sure to include some multiwhite lights in order to see the color temperature changes). You will also have to create a Connect Mesh Cloud Account in order to setup your gateway. You can do this within the app or alternativly with your browser.
Creating a token
Visit the developer section in your Connect Mesh Cloud Account in order to create a Token.
- Click on
Create a new token
- Give your token some meaningful name in order for easy future identification.
- Additionally you have to set an expiration date. You can use the offset helper to set it to a specific time from now.
When you create the token, the token will be displayed only once. Make sure to save it somewhere for further usage otherwise you will have to create a new one.
Try it out
- Goto the API section
- Click the
Authorize
button on the right hand corner. - Paste the token you just created into the bearer token field and save.
- Select the
networks > /networks [Fetch all user networks]
endpoint. - Run the command in your browser by pressing the
Try it out
and then theExecute
button. - Copy the network id of a network you would like to control from the response.
- Select the
groups > /groups [Fetch all the user groups]
endpoint. - Paste the network id and execute the command to get a list of all groups inside this network.
- Copy the id of a group you would like to control.
- Select the
groups > /power [Toggle a group on/off]
endpoint. - As the request body enter request body
{
"power": "on",
"networkId": "<the-network-id-the-group-belongs-to>",
"groupId": "<the-group-id-you-want-to-toggle>",
"acknowledged": false
} - Hit
Execute
and watch your devices turn on 💡
Example applications
The Example applications can be used to see how the web api can be used to control a users lights.
- Human centric lighting: Control a mesh groups brightness & color temperature depending on the time of day.
You can explore the source code at github