Looking for a SmartThings developer for Awair integration


(Paul Beckett) #1

Hi All

In terms of air monitoring devices… Awair (www.getawair.com) seems to be the most comprehensive of the bunch! It offers Temp, Humidity, CO2, VOCs/Chemicals and Dust!

If only that information was in SmartThings to trigger events such as turn on fan, or send notification, or send alert (maybe via Hue Lighting)?!?!?!

Would anyone be interested in building a simple SmartThings Awair? Here is the API information:

API information for Awair

I’m hoping the API is suitable for a SmartThings integration without a bridge.

Effectively, all that would be required is the 5 values be displayed for each device.


#2

Hopefully you’ll get some developer responses.

Meanwhile, you can get indirect integration through the free IFTTT service. You just use the Awair as the “if” and smartthings as the “that”

If you have IFTTT turn on a virtual switch and then you have that virtual switch coming on run a routine or start a Webcore piston you should be able to do pretty much everything you described in your first post. There might be some slight additional lag going through IFTTT, but that’s not usually an issue with the type of use cases you mentioned.

So I’m not sure if that helps any, but it might be worth considering. :sunglasses:

If you’ve never used virtual switches before, it’s the same method we use so that we can have Amazon echo do things other than just turn on a single device, so the following thread explains that process:


(Paul Beckett) #3

Thanks! I’ve moved away from IFTTT as the lag is sometimes quite long… I was experiencing “if THIS then THAT… but after 28 mins of THIS happening” :-/ I’m down to a couple of IFTTT actions so I do still use it, but I certainty wouldn’t invest in any more (new) devices (such as Awair) for my SmartThings Smart Home unless they integrate directly.


#4

Understood. Hopefully one of the code gurus will find this an interesting project. :sunglasses:


(Allan) #5

General question in case someone much more knowledgeable then me sees this. For a one-off device can you create a DTH and hard code the access token and device ID into it and then create a new device based on your DTH and have it pull data and work or do you need the SmartApp side to actually make the HTTP request and handle the data?

I.e. can you get super simple (relatively) and just add a runevery15min to a device, poll the data, and update some tiles and make a integration like this work?


(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy) #6

Yes.

But “simple” is, indeed, relative.


(Allan) #7

So if you can do it all within a DTH it is, relatively, simple. To me a individual device hard coded with what I need is simple compared to a SmartApp + device combo with preferences and all that jazz. Based on the weather underground HTTP request example and the API linked above I would think a decent SmartApp/DTH person could whip out a “simple” DTH for this device in a hour.

I kinda wanna try just for the hell of it since I’ve never done a HTTP request in SmartThings yet but I don’t have the device. @beckettpauln - If you are willing to PM me the access token and device ID of your unit I’ll give it a shot. Its not going to be fancy and you’ll have to manually install it (no SmartApp) but I think I can make it work.


(Sergii) #8

AWAIR API is in beta mode and is only available for a handful of pre-selected users. If somebody can help me to get access token for my device I can do the development.


(Allan) #9

FYI - I thought it was kinda neat so I already built the framework if you want a copy. I PM’d the @op for a access token and got no response.


(Benh57) #10

I’m new to ST, am a software engineer and also have an Awair. I’ll see if I can get a token out of them…


(Benh57) #11

Update: They refused to provide me a key, stating its not available to consumers yet.

Anyone who’s interested should fill out this form: http://goo.gl/Ff83kU

Awair Support (Awair)

Jan 2, 13:10 PST

Hi Ben,

The API we’ve built is apart of our enterprise package and isn’t available separately at this moment.

We are collecting a list of users who would be interested in an API for consumers. Please fill out this form if you’d like to be notified when it’s available.

I’m sorry I don’t have more information about when it will be available. Please feel free to share the ways you’d like to use an API if it were available–hearing directly from our customers is the best way to push this request along our product roadmap.

Depending on what you’re trying to accomplish, you might find some utility with our IFTTT integration. Let me know if there’s anything else I can do to help!

Thank you,
Michael


(Allan) #12

Out of simple curiosity of trying to use a http get in a device handler I made a shell program for this device. Since they arn’t giving out codes I can’t test it but if anyone else gets one they hopefully can use something in here. Figured I’d most it before deleting it out of my IDE:

/**
 *   AWAIR 
 *
 *  Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 *  in compliance with the License. You may obtain a copy of the License at:
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
 *  on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
 *  for the specific language governing permissions and limitations under the License.
 *
 *  Change History:
 *
 *    Date        Who            What
 *    ----        ---            ----
 *    2017-10-13  Allan (vseven) Initial creation
 * 
 */
metadata {
	definition (name: "AWAIR Sensor", namespace: "vseven", author: "Allan (vseven)") {
		capability "Temperature Measurement"
		capability "Sensor"
        capability "Relative Humidity Measurement"

		attribute "co2", "number"
		attribute "voc", "number"
		attribute "dust", "number"
		attribute "lastUpdated", "String"
	}

	simulator {

	}
        
	tiles(scale: 2) {
		multiAttributeTile(name: "temperature", type: "generic", width: 6, height: 4, canChangeIcon: true) {
			tileAttribute("device.temperature", key: "PRIMARY_CONTROL") {
				attributeState("temperature", label: '${currentValue}°', unit:"F", defaultState: true, 
						backgroundColors: [
                                // Celsius
                                [value: 0, color: "#153591"],
                                [value: 7, color: "#1e9cbb"],
                                [value: 15, color: "#90d2a7"],
                                [value: 23, color: "#44b621"],
                                [value: 28, color: "#f1d801"],
                                [value: 35, color: "#d04e00"],
                                [value: 37, color: "#bc2323"],
                                // Fahrenheit
                                [value: 32, color: "#153591"],
                                [value: 44, color: "#1e9cbb"],
                                [value: 59, color: "#90d2a7"],
                                [value: 74, color: "#44b621"],
                                [value: 84, color: "#f1d801"],
                                [value: 95, color: "#d04e00"],
                                [value: 96, color: "#bc2323"]
						])
			}

			tileAttribute("device.humidity", key: "SECONDARY_CONTROL") {
				attributeState "humidity", label:'${currentValue}%', icon:"st.Weather.weather12"
            }
        }
		valueTile("co2", "device.co2",  width: 2, height: 2,decoration: "flat") {
			state "default", label:'${currentValue} co2 ppm'
		}
		valueTile("voc", "device.voc",  width: 2, height: 2,decoration: "flat") {
			state "default", label:'${currentValue}% voc ppm'
		}
		valueTile("dust", "device.dust",  width: 2, height: 2,decoration: "flat") {
			state "default", label:'${currentValue}% dust ppm'
		}
 		valueTile("lastUpdated", "device.lastUpdated", inactiveLabel: false, decoration: "flat", width: 6, height: 2) {
    			state "default", label:'Last Updated ${currentValue}', backgroundColor:"#ffffff"
		}
        
        main(["temperature"])
		details(["temperature", "humidity", "co2", "voc", "dust" ,"lastUpdated"])
	}
}

def installed() {
	runEvery15Minutes(getData)
}

def uninstalled() {
	unschedule()
}

def getData() {
    log.debug("getData run")

    def params = [
        uri:  'https://beta-api.awair.is/v1/devices/1/events/15min-avg',
        headers: ['Authorization': 'Bearer {access_token}'],
        contentType: 'application/json'
    ]
    try {
        httpGet(params) {resp ->
            log.debug "resp data: ${resp.data}"  
            // Do stuff with the data
        	resp.headers.each {
				log.debug "${it.name} : ${it.value}"
        	}
            log.debug "temp: ${resp.data.sensor.temp}"
        }
        
        // Update lastUpdated date and time
        def nowDay = new Date().format("MMM dd", location.timeZone)
        def nowTime = new Date().format("h:mm a", location.timeZone)
        sendEvent(name: "lastUpdated", value: nowDay + " at " + nowTime, displayed: false)
    } catch (e) {
        log.error "error: $e"
    }

}

(Rockvole) #13

I wrote some python code which I use to take the Awair readings and plot them on my own dashboard. Right now you dont need an api key, you just use your Awair username and password to request data from Awair.

You can see all of my code here :

Incidentally, I found the foobot to be more developer friendly - it also seems to be better reviewed.


#14

They are now giving out API codes. If you request it, they will contact you back with a link to set it up. Takes about 48 hours.

https://developer.getawair.com/onboard/welcome


(Denis Grabocka) #15

It is a very nice device in my opinion i have the Awair Glow it connects to Google Assistant and Alexa with GA you can only control the integrated night light and outlet which i have connected to a humidifier which automatically turns on and off depending on the humidity levels of my room. it will be nice to integrate it with SmartThings and have all controls into one place also have it control other devices not hardware connected to Awair such as fans or fireplaces etc.
So plus one on the votes for integrating their api into ST
Denis


#16

I tried this with my access token, but couldn’t get it paired. Any ideas on what else would need to be updated?


(Allan) #17

Well the code I posted was during their beta and it looks like the API is now at https://afb-api.awair.is so that definitely needs to be changed. Also I didn’t do anything with the data other then print it to the debug log to see if it was valid. Figured once it was working it could be done “properly”.

See http://docs.afb.awair.is/ for more info.