I enclosed my atrium with a skylight. Outside the doors to the atrium, the room did not have ventilation. I've added a roof vent cap leading to a register/ vent in the room. As it can get dusty, I wanted to be able to close the vent. A simple mechanical system is not convenient, also due to the height where the vent is installed. Flair makes smart vents which are great in combination with HVAC system. In my case with a passive ventilation system, I just wanted to be able to control the on/ off the vent, maybe program it to open at predefined times to let some air in.
The Flair smart vent can be set in manual mode and controlled from their app. That's not convenient. Also, the integration with Alexa works as part of the HVAC smart solution, not for just opening/ closing the vent.
Fortunately, Flair offers APIs. Just drop them an email, instructions here:
https://support.flair.co/hc/en-us/articles/360000523252-Does-Flair-have-an-API
The team was responsive and soon I received my Oauth 2 credentials.
What I've created is:
1. An Alexa virtual switch that
2. Triggers an AWS Lambda function that calls the Flair APIs
3. I can either use Alexa voice prompt ("Alexa, vent on")
4. Or a cheap Amazon Basics smart switch that's used just as trigger for the Lambda function.
In the first place you need to install the Flair vent and the Flair Puck that enables the control and integration. In order to control the smart vent through APIs you need to set it in manual mode in the Flair app, otherwise you get an unstable behavior.
Amazon has published a good tutorial and step-by-step example to create a virtual switch. Follow carefully the steps from this tutorial:
https://developer.amazon.com/en-US/docs/alexa/smarthome/smart-home-skill-tutorial.html
Make sure you use N. Virginia as region (or Ireland)- the Alexa home skill does not work elsewhere.
I've used the sample Python code provided by Amazon with the following modifications (you can find the whole code in the code section). Few explanations:
You can change lines 68 and 69 to a friendly name. This is the name that will be visible in Alexa.
Line 73 is where the custom function calling Flair APIs is called. If the virtual switch is off, the vent is closing, if on opening.
The actual function is starting at line 112. You need to replace the values for "client_id" and "client_secret" with your values as provided by Flair team (see beginning of the instructions how to reach out to the Flair team).
In line 129 you need to replace your_vent_ID with the actual ID of the vent you want to control. Unfortunately, the vent ID is not visible in the Flair app (only a name that you assigned); the ID looks something like
13c44351-5883-5cbe-52cf-da0c1a1505f7
and you need to retrieve that through APIs. I used Postman. You need to create a GET request
However, that one requires configuring the Oauth 2.0
When you go to the Auth tab, select Oauth 2.0 and configure new token as follows
Configure New TokenToken Name: test
Grant type: Client Credentials
Access Token URL: https://api.flair.co/oauth2/token
Client ID: your client ID obtained through Flair
Client Secret: your client secret obtained through Flair
Scope: vents.view
Client Authentication: Send client credentials in body
Once done press the Get New Access Token. If successful, you should call the GET REST API
https://api.flair.co/api/vents
and in the response copy the vent ID that you want to control and modify accordingly the Lambda code.
Once you go through all the steps in the tutorial and activate your custom skill that you created, a device called "Vent" (or the name you chose in line 68) should appear in your devices list for Alexa. Test it out by calling "Alexa, vent on" or "Alexa, vent off". There might be a delay of up to a minute before the vent actually opens/ closes, have some patience.
Last step, optional but adds convenience, is to use an Amazon Basics Smart Switch to control the vent. At the time of this writing the switch costs just $18 but adds lot of convenience. You would need to have an empty receptacle (or add one) with 120V power to installed the switch. Once installed (you need to just connect the line and neutral, leave load hanging) and add that switch to your devices in Alexa, create routines that control the Vent virtual device (switch on, sets Vent on, and likewise switch off, Vent off).
Comments