fixed uuid bug
parent
ebd094c57b
commit
66bce1b1ab
|
|
@ -1,13 +1,29 @@
|
|||
|
||||
# Air Quality Index
|
||||
|
||||
This plug-in gets the air quality information from http://aqicn.org.
|
||||
Through your IP address the next nearby sensor station will be discovered.
|
||||
|
||||
This plug-in gets air quality information from http://aqicn.org.
|
||||
Through the WAN IP address the next nearby sensor station will be discovered.
|
||||
The geo location can also be set manually.
|
||||
|
||||
## Supported Things
|
||||
|
||||
If you encounter that a value stays to zero, it means the sensor station
|
||||
* Air Quality Index
|
||||
* Location discovery
|
||||
* Manually location set
|
||||
* Air Quality
|
||||
* Cautionary statement
|
||||
* PM2.5 pollution level
|
||||
* PM10 pollution lebel
|
||||
* Ozone level
|
||||
* Nitrogen dioxide level
|
||||
* Carbon monoxide level
|
||||
* Sulfur dioxide level
|
||||
* Temperature
|
||||
* Humidity
|
||||
* Pressure
|
||||
* Wind speed
|
||||
|
||||
NOTE: If you encounter that a value stays to zero, it means the sensor station
|
||||
doesn't support that value.
|
||||
|
||||
Besides the air pollution level the plug-in also states a cautionary statement.
|
||||
|
|
@ -16,6 +32,10 @@ inform you what precautions should be taken.
|
|||
|
||||
## Requirments
|
||||
|
||||
* Valid "Air Quality Index" API Key
|
||||
* The package "nymea-plugin-airqualityindex" must be installed
|
||||
* Intenet connection
|
||||
|
||||
## More
|
||||
|
||||
More about the different Air Quality Levels: https://www.airnow.gov/index.cfm?action=aqibasics.aqi
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ QUuid AirQualityIndex::searchByName(const QString &name)
|
|||
if (m_apiKey.isEmpty())
|
||||
qCWarning(dcAirQualityIndex()) << "API key is not set";
|
||||
|
||||
QUuid requestId;
|
||||
QUuid requestId = QUuid::createUuid();;
|
||||
QUrl url;
|
||||
url.setUrl(m_baseUrl);
|
||||
url.setPath("/search/");
|
||||
|
|
@ -118,7 +118,7 @@ QUuid AirQualityIndex::getDataByIp()
|
|||
if (m_apiKey.isEmpty())
|
||||
qCWarning(dcAirQualityIndex()) << "API key is not set";
|
||||
|
||||
QUuid requestId;
|
||||
QUuid requestId = QUuid::createUuid();;
|
||||
QUrl url;
|
||||
url.setUrl(m_baseUrl);
|
||||
url.setPath("/feed/here/");
|
||||
|
|
@ -153,7 +153,7 @@ QUuid AirQualityIndex::getDataByGeolocation(const QString &lat, const QString &l
|
|||
if (m_apiKey.isEmpty())
|
||||
qCWarning(dcAirQualityIndex()) << "API key is not set";
|
||||
|
||||
QUuid requestId;
|
||||
QUuid requestId = QUuid::createUuid();
|
||||
QUrl url;
|
||||
url.setUrl(m_baseUrl);
|
||||
url.setPath("/feed/geo:"+lat+";"+lng+"/");
|
||||
|
|
|
|||
|
|
@ -78,8 +78,10 @@ void IntegrationPluginAqi::discoverThings(ThingDiscoveryInfo *info)
|
|||
connect(m_aqiConnection, &AirQualityIndex::stationsReceived, this, &IntegrationPluginAqi::onAirQualityStationsReceived);
|
||||
|
||||
connect(info, &ThingDiscoveryInfo::aborted, [this] {
|
||||
if (myThings().filterByThingClassId(airQualityIndexThingClassId).isEmpty()) {
|
||||
m_aqiConnection->deleteLater();
|
||||
m_aqiConnection = nullptr;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
qCDebug(dcAirQualityIndex()) << "AQI connection alread created";
|
||||
|
|
@ -107,8 +109,10 @@ void IntegrationPluginAqi::setupThing(ThingSetupInfo *info)
|
|||
|
||||
connect(info, &ThingSetupInfo::aborted, [requestId, this] {
|
||||
m_asyncSetups.remove(requestId);
|
||||
//m_aqiConnection->deleteLater();
|
||||
//m_aqiConnection = nullptr;
|
||||
if (myThings().filterByThingClassId(airQualityIndexThingClassId).isEmpty()) {
|
||||
m_aqiConnection->deleteLater();
|
||||
m_aqiConnection = nullptr;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
info->finish(Thing::ThingErrorNoError);
|
||||
|
|
@ -120,6 +124,7 @@ void IntegrationPluginAqi::setupThing(ThingSetupInfo *info)
|
|||
}
|
||||
|
||||
|
||||
|
||||
void IntegrationPluginAqi::postSetupThing(Thing *thing)
|
||||
{
|
||||
if (thing->thingClassId() == airQualityIndexThingClassId) {
|
||||
|
|
@ -162,7 +167,7 @@ void IntegrationPluginAqi::thingRemoved(Thing *thing)
|
|||
void IntegrationPluginAqi::onAirQualityDataReceived(QUuid requestId, AirQualityIndex::AirQualityData data)
|
||||
{
|
||||
if (m_asyncSetups.contains(requestId)) {
|
||||
ThingSetupInfo *info = m_asyncSetups.value(requestId);
|
||||
ThingSetupInfo *info = m_asyncSetups.take(requestId);
|
||||
return info->finish(Thing::ThingErrorNoError);
|
||||
}
|
||||
|
||||
|
|
@ -171,7 +176,6 @@ void IntegrationPluginAqi::onAirQualityDataReceived(QUuid requestId, AirQualityI
|
|||
if (!thing)
|
||||
return;
|
||||
|
||||
//thing->setStateValue(airQualityIndexStationNameStateTypeId, data);
|
||||
thing->setStateValue(airQualityIndexConnectedStateTypeId, true);
|
||||
thing->setStateValue(airQualityIndexCoStateTypeId, data.co);
|
||||
thing->setStateValue(airQualityIndexHumidityStateTypeId, data.humidity);
|
||||
|
|
@ -221,11 +225,14 @@ void IntegrationPluginAqi::onAirQualityStationsReceived(QUuid requestId, QList<A
|
|||
info->finish(Thing::ThingErrorNoError);
|
||||
}
|
||||
|
||||
|
||||
if (m_asyncRequests.contains(requestId)) {
|
||||
Thing * thing = myThings().findById(m_asyncRequests.take(requestId));
|
||||
if (!thing)
|
||||
return;
|
||||
thing->setStateValue(airQualityIndexConnectedStateTypeId, true);
|
||||
if (stations.length() != 0) {
|
||||
thing->setStateValue(airQualityIndexStationNameStateTypeId, stations.first().name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue