Philips Hue – The Actuator

Introduction –
These smart bulbs are Wi-Fi enabled color changing LED lamps and white bulbs. It uses the Zigbee protocol to communicate and can also be controlled via the Philips Hue app (available in Android Play Store and Apple App Store) over Wi-Fi via a Hue bridge. This smart bridge connects to the LED bulb and then the 600 lumens LED connects to the Hue app on the phone. Through the app, you can not just turn on and off the light when you leave home, but you can customize the color of the light. One of the advantages of the smart bulbs is that they fit into the existing bulb.

We make use of Philips Hue in this project as an ‚Actuator‘. In order to establish a communication between  Microsoft  Azure and Philips Hue, we have made use of the ‚Function Apps‘ featured in Azure.

Steps – 

1. Hue Setup –

As well known, Philips Hue can be used through its Philips Hue app (for Android) or through Apple Store. For our project, we have made several API calls. The same can be understood from the documentations in the official pages:

https://www.developers.meethue.com/documentation/getting-started

The procedure for using the API is slightly convoluted on the auth-part. Furthermore, apart from the Clip Debugger tool mentioned, these API calls also work from other tools like Postman.

2. Azure Setup – 

In order to connect Azure and Philips Hue, we will do a queue-triggered function that will in turn do an HTTP-based call to the Hue Bridge.

For this, we first create an Azure Storage Queue: In Microsoft Azure, create a storage account and add a new queue under Queue Service. Queues were used as we did not need to send / receive large amounts of messages in order to test our connection. So, it’s straightforward to get through the Azure portal.

queue

3. Function Setup –

The next step is to create a function app in Microsoft Azure. For this, adopt the following steps –

i. Click on ‚Create a new resource‘.

ii. On the search box, type function app. Then click Create.

iii. Fill in the app name. In order to link the app to your resource group, click on ‚Use existing‘ under Resource Group field and choose the required Resource group. Then click Create.

iv. Once the function app is created, navigate to the function app. In order to create a queue triggered function, the following official documentation may be referred –

https://docs.microsoft.com/en-us/azure/azure-functions/functions-create-storage-queue-triggered-function

v. The following is the sample code snippet –

Function app_queue trigger

vi. In order to test the function, add few messages to the queue and run the function. The logs have been read from the queue.

Conclusion – 

In a nutshell, through Microsoft Azure, we create a function app created in the Azure portal in order to control the lights.

We saw that Philips Hue Lights could also be accessed from the Internet (either through API or through codes written in Microsoft Azure) instead of Android apps alone. 

Schreibe einen Kommentar