Virtual AQI Device

Hello! I am new to creating Hubitat drivers, but not new to coding. I wanted to create a driver that would pull openweathermap AQI data via the API and present it in the current states. I read some other similar drivers to try and get started, but I'm having trouble getting it to show any data.

Could anyone provide some pointers to where I am going wrong? I'm trying to attach my code to this post.

Okay I think I got it working, may as well post it for others. I was just doing some dumb stuff.

/*
	OpenWeatherMap-Air Quality
*/
static String version()	{  return '0.0.1'  }
import groovy.transform.Field


metadata {
    definition (name: "OpenWeatherMap-Air Quality", namespace: "bryan", author: "bryan") {
	capability "AirQuality"
    command 'pollData'
	} 
    preferences {
        input 'apiKey', 'text', required: true, title: 'Type OpenWeatherMap.org API Key Here', defaultValue: null
        input name: "logEnable", type: "bool", title: "Enable debug logging", defaultValue: true
        input name: "txtEnable", type: "bool", title: "Enable descriptionText logging", defaultValue: true
    }
}

void pollAQI() {
	if( apiKey == null ) {
		return
	}
	Map ParamsAQI
	ParamsAQI = [ 
        uri: 'https://api.openweathermap.org/data/2.5/air_pollution?lat=' + (String)location.latitude + '&lon=' + (String)location.longitude + '&appid=' + (String)apiKey, 
        timeout: 20 ]
    if (logEnable) log.debug "ParamsAQI:${ParamsAQI}"
	asynchttpGet('pollAQIHandler', ParamsAQI)
}

void pollAQIHandler(resp, data) {
	if(resp.getStatus() == 200 || resp.getStatus() == 207) {
		Map aqi = parseJson(resp.data)
		if(aqi.toString()==sNULL) {
			pauseExecution(1000)
			pollAQI()
			return
		}
		def name = 'airQualityIndex'
		def value = aqi.list[0].main.aqi
		def descriptionText = "${device.displayName} ${name} is ${value}"
		if (txtEnable) log.info "${descriptionText}"
		sendEvent(name: name,value: value,descriptionText: descriptionText,unit: unit)
	}
}

void refresh() {
}

void installed() {
    schedule("0 0 0/1 1/1 * ? * ", pollAQI)
}

void uninstalled() {
    unschedule()
}

void pollData() {
	pollAQI()
}

Download the Hubitat app