Looking for a SmartThings developer for Awair integration

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

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?

Yes.

But “simple” is, indeed, relative.

2 Likes

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.

2 Likes

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.

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.

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…

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

Anyone who’s interested should fill out this form: Awair API Request

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

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"
    }

}
1 Like

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.

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

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

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

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.

Now that this has been out for a while, anyone had anymore luck with ST integration?

Woukd love to have a CO2/air quality monitor that works in ST (and can eventually post to actiontiles).

Awair Has an IFTTT channel which can Be used to trigger smartthings events based on threshold levels such as “VOC above,” “Dust below,” etc.

But you can’t get the individual values to display. So it’s good for turning other devices on and off like a humidifier or an air purifier. But not great for action tiles informational display.

Sorry to bring up an old thread, but just recently stumbled upon this request. Since the last message, we have released Developer APIs in Beta (https://developer.getawair.com)

If you work for awair, I’m going to suggest you guys implement the smartthings developer program and get something officially released.

2 Likes

Yes, absolutely, that would be the smart thing to do, and we are working on that. In the meantime for people who stumbled across this thread (and for tinkerers), I wanted to give some options.

1 Like

I recently tried this device handler for Awair and it works great with my 2nd gen Awair. Is uses the developer API access: