Does Flair Work With SmartThings Hub?
Hello -
My five new Mitsubishi mini-splits have been installed and they are absolutely delightful. My Flair Pucks are on backorder, but once they get here I will be over the moon.
I'm considering getting the SmartThings Hub from Aeotec or the Hubitat. SmartThings was created by Samsung, and is often refered to as the Samsung SmartThings Hub. Hubitat looks to be a little more versatile than SmartThings.
Will Flair Pucks play nice with SmartThings and/or Hubitat? I don't see Flair on the lists on Aeotec or Hubitat's websites.
-
I guess it depends on what you are trying to do. I have the Samsung hub and I got the pucks and vents working using the Flair API. There were developers in the Smartthings forums wanting to charge for DHT support, so I wrote my own. So far I have implemented being able to open and close vents, set temperatures in the pucks, and set heat/cold mode. The assumption is that you got everything working via the Flair app before you try to control things via the Flair API and Smartthings.
You are welcome to try what I have. Obviously, the setup assumes that you are a little tech savvy, but it is not too bad. Send me a note if interested.
Regards,
Jose
-
Hi Jim,
Jose Paredes is correct. There's no current SmartThings integration with Flair and you can use our API. Also, you have to create a Flair account using the Flair app and add all your devices via the Setup process before you can control them with the API.
Out of curiosity, why not use the Flair app to do these things?
All the best,
Finn
-
Out of curiosity, why not use the Flair app to do these things?
I can't speak for Jim S, but for me it is because I have all my home automation controlled via the Smartthings app. Lights, thermostats, garage doors, fireplace, movement detectors, etc. It's useful to have it all in once place.
For example, I have a simple smartapp that detects if my thermostat has changed mode from cold to heat or vice versa and changes the flair mode accordingly. This can happen all the time at this time of year in Austin, TX (last night was 40 degrees and tomorrow will be close to 80 degrees).
Regards,
Jose
-
"why not use the Flair app to do these things?"
As Jose points out, it would be nice to have everything under one "roof" on my phone or tablet. It's also my understanding that with the SmartThings or Hubitat hubs (I'm leaning towards Hubitat) I can have some rudimentary IFTTT actions. I'm just starting on my home automation learning curve, but it seems that Zigbee and Z-Wave are the two protocols that are essentially the gold standard and I'm surprised Flair doesn't use those protocols.
Jose Paredes - I would be very interested in what you have, Thank You! But I don't have the Flair Pucks yet, I will set a reminder to ping you when I get them.
-
Jim S - I can't vouch for Hubitat, though. I've only written DHTs for SmartThings.
Regards,
Jose
-
Hi Brian Hilbern,
In Flair, you can temporarily unassign the Puck from that room and use the Smart Vent widget to manually close the Vent.
Later, you can reassign the Puck to that room to restart automating the Smart Vent operation.
All the best,
Finn
-
Hey Finn -
I appreciate the woirkarounds like you mentioned to BrianH above. But the unassigning then reassigning a puck seems to be extra steps that shouldn't be needed. Really, the more I read about the Zigbee and Z-Wave protocols, the sillier it seems that Flair doesn't support them. In the spring and fall shoulder seasons, there are always many weeks in a row where we use heat in the morning, then air conditioning in the afternoon. With the Mitsubishi mini-splits I can't turn on any afternoon air conditioning until I've turned off all the units that were being used for heating. I'm pretty sure with the Puck app I can open each unit, turn it off, then go back and turn on the A/C I want. But if Flair would subscribe to Zigbee/Z-Wave, I should be able to create a single action that will do all of that for me.
Disclaimer - I don't have my pucks yet and I don't have my Hubitat yet, so I might be speaking out my backside. If so, please be gentle while straightening me out :-)
-
Jim S My previous post to you got deleted, most likely because there was a link that could be interpreted as commercial.
A) Don't hold your breath about Flair going Zigbee or Z-Wave. Keen is Zigbee but I think they are on life support looking at their lack of every products. So that does not leave many options...
B) I'm using Hubitat to connect with the Flair API, using a paid plug-in. If you go to the Hubitat's forum you will find easily what Yves Racine has a solution. I've been using the Flair-Hubitat integration for maybe a full year and find it very reliable, although I'm a firm believer that Flair should come-up with a local gateway or any other local solution. The downside of the Flair-Hubitat integration is the polling time of (5) minutes. That being said you can also issue on demand "Refresh" command if you need the latest status before taking an action.
C) Have not tried the Smarthing but Hubitat is very stable. Rock solid.
Hope that helped.
-
Michel V For the Flair-Hubitat integration, since Hubitat does not require Internet (As I understand it), Does it use internet to control Flair vents, or can it control them locally?
-
Hi Jose,
I would be interested in your custom DTH for SmartThings if you could point me in the right direction.
Thanks,
AHB
-
Victor What Hubitat does is handle/communicate with Flair's web API. Therefore you are depending on internet being available AND Flair servers being up an running. So this is not a local solution.
Anthony Berkemeyer Unless you want to build your own from scratch, riding on Jose Paredes work, you can search for "Flair vent" on ST forum and discover Yves Racine's paid version DTH.
-
Hi Michel V
From what I saw on the ST form for Yves Racine's paid version of DTH, it requires the classic app which is no longer available. Unless I'm missing something.
-
Try to go to ecomatiqhomes dot com
-
Anthony Berkemeyer : I don't mind sharing my code for vents and pucks. The code is able to open/close vents, set temperature of pucks and set mode (cool/heat). I don't have fancy features like figuring out if the puck/vent are offline, for example. For the code to work you must have at least one puck installed in your system and and access to the API. You don't have to know how to use the API, but you do need personal API access (ID and Secret) to use the code I wrote. Figuring out which puck/vent ID goes with which DHT instance is a little more involved. In order to not make this post to complicated, let me know if you get as far as getting API access and I will take you through the process.
-
With the news in the last few days that the SmartThings Groovy infrastructure is being shutdown at end of September, now what?
This means that all WebCore, Groovy Smartapps, Groovy Device Handlers, etc... are just going to stop working. This includes Yves Racine's Flair drivers (these are the paid ones).
And to answer Finn's question: I have automated my home with SmartThings. Utilizing WebCore and Yves' code, I write a multi-stage system to resolve a hot area problem in a long room with only a mini split. The code automatically adjusts, temperature, fan speed and Vertical Swing, as well as a ceiling fan. That programmability is essential and why I purchased a Flair puck.
-
Chip:
I was able to create an edge driver and got everything working like it did before. Unfortunately, the edge drivers do not allow you to use the API directly. You must set up what I call an API proxy server. I already had a server working in my NAS so it was easy enough to create a new one. It's a little technical, but if you are interested in what I did, send me a note and I can share more.
Regards,
Jose
-
Jose Paredes I'd also like to learn more about your solution. I have very specific functions I need from an integration with Flair... temperature, fan speed and Vertical Swing. Please let us know more about your solution.
-
Chip:
I have never actually set up a server using a raspberry pi, but my understanding is that it is pretty straight forward. I wrote all the necessary server commands in php, so you will have to have php also working with the curl and openssl extensions enabled. My Synology NAS has php 7.0 installed.
I am not sure about everything you are asking...yet. I do not have any fans or splits connected to my pucks, so I can't comment on how to implement fan speed. I don't even know what a "Vertical Swing" is. But, if it can be accessed via the API then I think we have a good chance of getting it to work with Smartthings.
I should say a few things about my setup:
- There is a learning curve for the Samsung and Flair API prerequisite setup. It's not "too bad" if you are tech savvy or an amateur coder, but it might be daunting if you have never coded anything. If you have been programming all your life, it should be pretty straight forward. It does not help that the Samsung documentation is not awesome. I will try to keep the steps as clear as I can make them.
- I don't integrate any smart thermostat with Flair. My Nest is integrated with Smartthings.
- edge drivers makes web interactions (like API calls) somewhat unsecure (annoyingly so, actually). You cannot make https (secure) calls, at least not reliably as of the time I wrote my driver. You can make http (unsecure) calls, but only to the same local network as the edge driver. Thus the need for a proxy to access the flair API. Since you can only make local http calls, I suppose this makes edge "somewhat secure". That's why I say it's "somewhat unsecure". If edge would at least allow local https maybe it would be a little less unsecure, for example. Anyhow...
- I hard code the local proxy address in the edge driver, and api client id and api secret in the poxy server. This was on purpose. I did not want to allow for settings in the Smartthings app to allow for changing server or other security info since that would not be under my control. I suppose we could make this more generic, but I don't love the idea. I like "one point of security"
- I only know how to do this for Smartthings. Even so, I don't consider myself an expert here. Just know enough to "be dangerous".
If you are still OK with the above then the next steps are :
- get a Flair API secret and client id here :
https://support.flair.co/hc/en-us/articles/360000523252-Does-Flair-have-an-API-
Essentially, you have to contact support to obtain API access. You don't have to worry about the python examples, but you are welcome to tinker with them. As I stated before, I implement everything in php. - create a PAT token for your Samsung account: https://account.smartthings.com/tokens . This will allow you to access the CLI. This may be optional, but when I first starting working with the CLI it was the only reliable method of access.
- download and install the CLI: https://github.com/SmartThingsCommunity/smartthings-cli/blob/main/packages/cli/README.md
- OPTIONAL: I'm pretty sure you don't have to sign up for developer access, but just in case: https://smartthings.developer.samsung.com/
In the spirit of keeping this post from being ginormous, if you got this far and still want to continue, post back. I suspect 1-3 will take a bit of time to get just right. After you get everything working above, I think the next steps are: 1) setting up the proxy servers, 2) creating the edge driver, 3) installing the driver in the ST hub, and finally 4) using the driver.
Regards,
Jose
-
Hi Jose
Sounds good. I'm ready to move forward. I'm good with your disclaimers and advice. I've completed 1,2,4, but not yet 3 as I'm not sure I'll need that (but will install CLI if needed). I'm comfortable with php and I'm versed in installing edge drivers (at least through the channels added to my hub then adding them), so I think I just need to get the php proxy running and driver. Thanks! Looking forward to next steps. -
You'll definitively need to do (3) - installing the CLI. You'll actually create and install your own drivers: one for pucks and one for vents. As I said, we could create a set of drivers that point to a generic API proxy server, but to be extra safe, everything is hardcoded in the drivers. That being said, there is nothing to say that we can't get the php code working and the circle back to creating and installing the driver.
Below is the php code for the proxy server. I have created 11 very short set of php files to control vents and pucks. A lot of them is cut and paste from one another, so it is not too hard to create. Again, this could have been done with one php code with parameters, but for the sake of debug and ease of change, I opted for small, targeted code. The php tries to be make a quick call to the API and return. The heavy lifting happens in the edge drivers. Unless you are debugging the php code, you never have to call the files directly from a browser window. They are meant to be used by the edge drivers.
1) flairToken.php
This will give you a token you can use to access the pucks and vents. It's probably the most important piece of code to make sure is working correctly. The rest of the code will use the token for operations, such as opening the vents, setting temperature at the pucks, checking temperature, setting mode (heat/cold), etc. Call it (for checking) like this:http://<your_api_proxy_addr>/flairToken.php
It should give you an answer similar to this:
{"access_token": "<RETURNED_TOKEN>", "expires_in": 3600, "token_type": "Bearer", "scope": "pucks.view pucks.edit structures.view structures.edit vents.view vents.edit"}
Code:
<?php
$apiEndpoint = "https://api.flair.co";
$scope = "scope=pucks.view+pucks.edit+structures.view+structures.edit+vents.view+vents.edit";
$clientId = "client_id=<YOUR_ID>";
$secret = "client_secret=<YOUR SECRET>";
$url = $apiEndpoint."/oauth/token?".$clientId."&".$secret."&".$scope."&grant_type=client_credentials";
$headers = "--header 'content-type: application/x-www-form-urlencoded' ";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
$rc = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
header("content-type: application/json");
echo $result;
?>PHP files 2-8 is below. I think their calls should be self explanatory. Every call requires a token (from above) and specific and ID or set of IDs to do their things (ventId for a vent, for example). I don't think it's an exhaustive list to do everything, but it has everything I was looking for. In particular, I don't have splits so maybe something is missing to enable that functionality.
2) flairVentStatus.php
<?php
$token = $_GET['token'];
$ventId = $_GET['ventId'];
$apiEndpoint = "https://api.flair.co";
$url = $apiEndpoint."/api/vents/".$ventId;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: Bearer $token") );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
header("content-type: application/json");
echo $result;
?>3) flairPuckStatus.php
<?php
$token = $_GET['token'];
$ventId = $_GET['puckId'];
$apiEndpoint = "https://api.flair.co";
$url = $apiEndpoint."/api/puck/".$puckId;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: Bearer $token") );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
header("content-type: application/json");
echo $result;
?>4) flairOpenVent.php
<?php
$token = $_GET['token'];
$ventId = $_GET['ventId'];
$state = $_GET['state'];
$apiEndpoint = "https://api.flair.co";
$url = $apiEndpoint."/api/vents/".$ventId;
$percentOpen = 0;
if($state == "open") {
$percentOpen = 100;
}
$data = '{"data": {"type": "vents", "attributes": { "percent-open": "'.$percentOpen.'" } } }';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PATCH');
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: Bearer $token", "Content-type: application/json") );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
header("content-type: application/json");
echo $result;
?>5) flairSetThermostatSetpoint.php
<?php
$token = $_GET['token'];
$roomId = $_GET['roomId'];
$setpoint = $_GET['setpoint'];
$apiEndpoint = "https://api.flair.co";
$url = $apiEndpoint."/api/rooms/".$roomId;
$data = '{"data": {"type": "rooms", "attributes": { "set-point-c": "'.$setpoint.'" } } }';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PATCH');
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: Bearer $token", "Content-type: application/json") );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
header("content-type: application/json");
echo $result;
?>6) flairSetThermostatMode.php
<?php
$token = $_GET['token'];
$structureId = $_GET['structureId'];
$mode = $_GET['mode'];
$apiEndpoint = "https://api.flair.co";
$url = $apiEndpoint."/api/structures/".$structureId;
$data = '{"data": {"type": "structures", "attributes": { "structure-heat-cool-mode": "'.$mode.'" } } }';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PATCH');
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: Bearer $token", "Content-type: application/json") );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
header("content-type: application/json");
echo $result;
?>7) flairThermostatSetpointStatus.php
<?php
$token = $_GET['token'];
$puckId = $_GET['puckId'];
$apiEndpoint = "https://api.flair.co";
$url = $apiEndpoint."/api/pucks/".$puckId."/room";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: Bearer $token") );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
header("content-type: application/json");
echo $result;
?>8) flairThermostatModeStatus.php
<?php
$token = $_GET['token'];
$puckId = $_GET['puckId'];
$apiEndpoint = "https://api.flair.co";
$url = $apiEndpoint."/api/pucks/".$puckId."/structure";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: Bearer $token") );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
header("content-type: application/json");
echo $result;
?>The following two php files are needed for installing the edge drivers. When the drivers "search" they will make a call to the server to decide if the devices (puck or vent) have been installed or not. The data is specific to your setup so you will have to change the id and names appropriately. In particular "id1", "id2", etc should be the id of the device found in your Flair setup (not just "id1", "id2", etc...). Unfortunately, you cannot get at the actual id from the Flair app.
PHP file 11 is a utility function I wrote to find device ids and names. The edge drivers will not call this file. You can use it to find the device ids in your Flair setup. I suppose you can get fancy here and read the info from a file or database, but since my setup was not too complicated, I just hardcoded what I had after I knew the device Ids.
9) flairFindVents.php
<?php
$data = '{
"0": {"id": "id1", "name": "Family Room Vent"},
"1": {"id": "id2", "name": "Bonus Room Vent"},
"2": {"id": "id3", "name": "Office Vent"},
"3": {"id": "id4", "name": "Mstr Bdrm Vent"}
}';
header("content-type: application/json");
echo $data;
?>10) flairFindPucks.php
<?php
$data = '{
"0": {"id": "id1", "name": "Family Room Puck"},
"1": {"id": "id2", "name": "Bonus Room Puck"},
"2": {"id": "id3", "name": "Office Puck"},
"3": {"id": "id4", "name": "Mstr Bdrm Puck"}
}';
header("content-type: application/json");
echo $data;
?>Finally, my utility function:
11) flairDevices.php
<?php
$token = $_GET['token'];
$verbose = $_GET['verbose'];
$apiEndpoint = "https://api.flair.co";
// vents
$vents=getData($apiEndpoint."/api/vents", $token);
$pucks=getData($apiEndpoint."/api/pucks", $token);
if($verbose != "true") {
// minimized data
$pucks = minimizeData($pucks);
$vents = minimizeData($vents);
}
$finalResult = "{\"vents\":".$vents.",\"pucks\":".$pucks."}";
header("content-type: application/json");
echo $finalResult;
/* FUNCTIONS */
function getData($url, $token) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: Bearer $token") );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
function minimizeData($jsonData) {
$decoded_json = json_decode($jsonData,true);
$retVal = "[ ";
foreach($decoded_json['data'] as $data) {
$retVal .= "{";
$retVal .= "\"id\":\"".$data['id']."\",";
$retVal .= "\"name\":\"".$data['attributes']['name']."\"";
$retVal .= "},";
}
$retVal = substr($retVal,0,-1); // ignore last comma
$retVal .= "]";
return $retVal;
}
?>Sorry about the big post! Let me know how it goes.
Regards,
Jose
-
OK. I assume you mean you got the server working. If you haven't already you could try close and open vents as a sort of quick check that you can access the API. Changing modes (heat, cool) and setpoint (temperature) is more involved because it requires knowing the room id and structure id, which is done in the driver code itself.
For the drivers, clone the following 2 repositories from github.
https://github.com/josep1972/FlairVent.git
and
https://github.com/josep1972/FlairPuck.git
Change the apiEnpoint variable in src/lifecycles.lua to point to your server address. This is where we could have made the apiEndpoint a generic parameter set by the user later, but I opted for hardcoding it.
Once you point to your server address you can now install the driver. I assume you got the CLI working. You should check by typing something like:
smartthings devices
which should return a list of all your devices in your setup. If you didn't get a good return code here, make sure you get that working before trying to install anything.
Here is the documentation on how to install drivers:
https://developer.smartthings.com/docs/devices/hub-connected/driver-components-and-structure
The section Install the Hello World Example Driver outlines the steps for installing the drivers of a "hello world" example. In our case you have to install 2 drivers: 1 for pucks and 1 for vents. Also, if it is not obvious, when you get to the section on creating a channel, you don't have to create a personal channel every time you install a driver.
If everything worked correctly, you should be able to "scan" and your devices should be "found".
Let me know how it goes. Good luck!
Regards,
Jose
-
Awesome, thanks Jose. Will install and test.. hopefully in the next few days.
Yeah I have the server and API working and tested open/closing, Grabbed all the IDs, etc.
For me, I don't need any extra code except for literally the vent open/close (actually modified to accept a percentage like 25 or 75).. since I run in manual mode. -
Yes sorry. I just made the repos public. Let me know if you get it.
As far as the percentages, I read a while ago that percentages don't actually work. I think you could have 0,50 and 100, but 50% would do something bad to the battery life of the vent so I just implemented close and open. That being said, maybe they fixed it? In any case, the driver does not implement percentages, only open and close. Of course, you are welcome to experiment with percentages too. That's the beauty of it: you can do whatever you want!
Regards,
Jose
Please sign in to leave a comment.
Comments
35 comments