added coin market cap

This commit is contained in:
nymea 2019-05-14 19:04:11 +02:00 committed by Michael Zanetti
parent 182c2a0004
commit 3e2954694a

View File

@ -31,7 +31,7 @@ DevicePluginCoinMarketCap::DevicePluginCoinMarketCap()
DeviceManager::DeviceSetupStatus DevicePluginCoinMarketCap::setupDevice(Device *device) DeviceManager::DeviceSetupStatus DevicePluginCoinMarketCap::setupDevice(Device *device)
{ {
if(!m_pluginTimer) { if(!m_pluginTimer) {
m_pluginTimer = hardwareManager()->pluginTimerManager()->registerTimer(60); m_pluginTimer = hardwareManager()->pluginTimerManager()->registerTimer(10);
connect(m_pluginTimer, &PluginTimer::timeout, this, &DevicePluginCoinMarketCap::onPluginTimer); connect(m_pluginTimer, &PluginTimer::timeout, this, &DevicePluginCoinMarketCap::onPluginTimer);
} }
@ -82,12 +82,12 @@ void DevicePluginCoinMarketCap::onPriceCallFinished()
qCWarning(dcCoinMarketCap()) << "Request error:" << status << reply->errorString(); qCWarning(dcCoinMarketCap()) << "Request error:" << status << reply->errorString();
device->setStateValue(currentPricesConnectedStateTypeId, false); device->setStateValue(currentPricesConnectedStateTypeId, false);
} }
reply->deleteLater();
// check JSON file // check JSON file
QJsonParseError error; QJsonParseError error;
QJsonDocument jsonResponse = QJsonDocument::fromJson(reply->readAll(), &error); QJsonDocument jsonResponse = QJsonDocument::fromJson(reply->readAll(), &error);
qDebug(dcCoinMarketCap()) << jsonResponse; reply->deleteLater();
if (error.error != QJsonParseError::NoError) { if (error.error != QJsonParseError::NoError) {
qCWarning(dcCoinMarketCap()) << "Update reply JSON error:" << error.errorString(); qCWarning(dcCoinMarketCap()) << "Update reply JSON error:" << error.errorString();
reply->deleteLater(); reply->deleteLater();