fixed autodetect search from openweather and removed conrad from code temprary

This commit is contained in:
Simon Stürz 2014-04-14 01:21:27 +02:00
parent 6c3596a3f4
commit 477749fe7d
5 changed files with 36 additions and 29 deletions

View File

@ -3,7 +3,7 @@ SUBDIRS += elro \
intertechno \ intertechno \
# meisteranker \ # meisteranker \
wifidetector \ wifidetector \
conrad \ # conrad \
mock \ mock \
# weatherground \ # weatherground \
openweathermap \ openweathermap \

View File

@ -180,6 +180,17 @@ QList<DeviceClass> DevicePluginOpenweathermap::supportedDevices() const
locationParam.insert("name", "location"); locationParam.insert("name", "location");
locationParam.insert("type", "string"); locationParam.insert("type", "string");
params.append(locationParam); params.append(locationParam);
QVariantMap countryParam;
countryParam.insert("name", "country");
countryParam.insert("type", "string");
params.append(countryParam);
QVariantMap idParam;
idParam.insert("name", "id");
idParam.insert("type", "string");
params.append(idParam);
deviceClassOpenweathermap.setParams(params); deviceClassOpenweathermap.setParams(params);
// Actions // Actions
@ -294,7 +305,7 @@ DeviceManager::DeviceError DevicePluginOpenweathermap::discoverDevices(const Dev
{ {
qDebug() << "should discover divces for" << deviceClassId << params; qDebug() << "should discover divces for" << deviceClassId << params;
if(params.value("location").toString() == ""){ if(params.value("location").toString() == ""){
m_openweaher->update(); m_openweaher->searchAutodetect();
return DeviceManager::DeviceErrorNoError; return DeviceManager::DeviceErrorNoError;
} }
m_openweaher->search(params.value("location").toString()); m_openweaher->search(params.value("location").toString());
@ -318,6 +329,7 @@ PluginId DevicePluginOpenweathermap::pluginId() const
void DevicePluginOpenweathermap::guhTimer() void DevicePluginOpenweathermap::guhTimer()
{ {
m_openweaher->update();
} }
void DevicePluginOpenweathermap::searchResultsReady(const QList<QVariantMap> &cityList) void DevicePluginOpenweathermap::searchResultsReady(const QList<QVariantMap> &cityList)

View File

@ -66,16 +66,7 @@ void OpenWeatherMap::processLocationResponse(QByteArray data)
QVariantMap dataMap = jsonDoc.toVariant().toMap(); QVariantMap dataMap = jsonDoc.toVariant().toMap();
if(dataMap.contains("city")){ if(dataMap.contains("city")){
QString cityName = dataMap.value("city").toString(); search(dataMap.value("city").toString());
// skip search for cityID...
if(m_cityName != cityName){
m_cityName = cityName;
updateSearchData();
return;
}else{
updateWeatherData();
return;
}
} }
} }
@ -237,25 +228,25 @@ void OpenWeatherMap::processWeatherResponse(QByteArray data)
// emit // emit
} }
} }
// qDebug() << "#########################################################"; qDebug() << "#########################################################";
// qDebug() << m_cityName << m_cityId; qDebug() << m_cityName << m_cityId;
// qDebug() << "#########################################################"; qDebug() << "#########################################################";
// qDebug() << "temp" << m_temperatur; qDebug() << "temp" << m_temperatur;
// qDebug() << "temp min" << m_temperaturMin; qDebug() << "temp min" << m_temperaturMin;
// qDebug() << "temp max" << m_temperaturMax; qDebug() << "temp max" << m_temperaturMax;
// qDebug() << "cloudiness" << m_cloudiness; qDebug() << "cloudiness" << m_cloudiness;
// qDebug() << "humidity" << m_humidity; qDebug() << "humidity" << m_humidity;
// qDebug() << "pressure" << m_pressure; qDebug() << "pressure" << m_pressure;
// qDebug() << "wind dir" << m_windDirection; qDebug() << "wind dir" << m_windDirection;
// qDebug() << "wind speed" << m_windSpeed; qDebug() << "wind speed" << m_windSpeed;
// qDebug() << "sunrise" << QDateTime::fromTime_t(m_sunrise); qDebug() << "sunrise" << QDateTime::fromTime_t(m_sunrise);
// qDebug() << "sunset" << QDateTime::fromTime_t(m_sunset); qDebug() << "sunset" << QDateTime::fromTime_t(m_sunset);
// qDebug() << "last update" << QDateTime::fromTime_t(m_lastUpdate); qDebug() << "last update" << QDateTime::fromTime_t(m_lastUpdate);
} }
void OpenWeatherMap::update() void OpenWeatherMap::update()
{ {
updateLocationData(); updateWeatherData();
} }
void OpenWeatherMap::searchAutodetect() void OpenWeatherMap::searchAutodetect()
@ -280,24 +271,28 @@ void OpenWeatherMap::replyFinished(QNetworkReply *reply)
if(reply == m_locationReply && status == 200){ if(reply == m_locationReply && status == 200){
data = reply->readAll(); data = reply->readAll();
processLocationResponse(data); processLocationResponse(data);
m_locationReply->deleteLater();
return; return;
} }
if(reply == m_searchReply && status == 200){ if(reply == m_searchReply && status == 200){
data = reply->readAll(); data = reply->readAll();
processSearchResponse(data); processSearchResponse(data);
m_searchReply->deleteLater();
return; return;
} }
if(reply == m_searchLocationReply && status == 200){ if(reply == m_searchLocationReply && status == 200){
data = reply->readAll(); data = reply->readAll();
processSearchLocationResponse(data); processSearchLocationResponse(data);
m_searchLocationReply->deleteLater();
return; return;
} }
if(reply == m_weatherReply && status == 200){ if(reply == m_weatherReply && status == 200){
data = reply->readAll(); data = reply->readAll();
processWeatherResponse(data); processWeatherResponse(data);
m_weatherReply->deleteLater();
return; return;
} }
} }

View File

@ -25,7 +25,7 @@ Q_IMPORT_PLUGIN(DevicePluginElro)
Q_IMPORT_PLUGIN(DevicePluginIntertechno) Q_IMPORT_PLUGIN(DevicePluginIntertechno)
//Q_IMPORT_PLUGIN(DevicePluginMeisterAnker) //Q_IMPORT_PLUGIN(DevicePluginMeisterAnker)
Q_IMPORT_PLUGIN(DevicePluginWifiDetector) Q_IMPORT_PLUGIN(DevicePluginWifiDetector)
Q_IMPORT_PLUGIN(DevicePluginConrad) //Q_IMPORT_PLUGIN(DevicePluginConrad)
Q_IMPORT_PLUGIN(DevicePluginMock) Q_IMPORT_PLUGIN(DevicePluginMock)
//Q_IMPORT_PLUGIN(DevicePluginWeatherground) //Q_IMPORT_PLUGIN(DevicePluginWeatherground)
Q_IMPORT_PLUGIN(DevicePluginOpenweathermap) Q_IMPORT_PLUGIN(DevicePluginOpenweathermap)

View File

@ -19,7 +19,7 @@ LIBS += -L../plugins/deviceplugins/elro/ -lguh_devicepluginelro
LIBS += -L../plugins/deviceplugins/intertechno/ -lguh_devicepluginintertechno LIBS += -L../plugins/deviceplugins/intertechno/ -lguh_devicepluginintertechno
#LIBS += -L../plugins/deviceplugins/meisteranker/ -lguh_devicepluginmeisteranker #LIBS += -L../plugins/deviceplugins/meisteranker/ -lguh_devicepluginmeisteranker
LIBS += -L../plugins/deviceplugins/wifidetector/ -lguh_devicepluginwifidetector LIBS += -L../plugins/deviceplugins/wifidetector/ -lguh_devicepluginwifidetector
LIBS += -L../plugins/deviceplugins/conrad -lguh_devicepluginconrad #LIBS += -L../plugins/deviceplugins/conrad -lguh_devicepluginconrad
LIBS += -L../plugins/deviceplugins/mock -lguh_devicepluginmock LIBS += -L../plugins/deviceplugins/mock -lguh_devicepluginmock
#LIBS += -L../plugins/deviceplugins/weatherground -lguh_devicepluginweatherground #LIBS += -L../plugins/deviceplugins/weatherground -lguh_devicepluginweatherground
LIBS += -L../plugins/deviceplugins/openweathermap -lguh_devicepluginopenweathermap LIBS += -L../plugins/deviceplugins/openweathermap -lguh_devicepluginopenweathermap