mirror of
https://github.com/nymea/nymea-plugins.git
synced 2026-08-05 03:33:51 +02:00
Fix netatmo plugin timer interval and initialization
This commit is contained in:
parent
35f4ba6ce4
commit
ce06fed618
@ -60,8 +60,7 @@ DevicePluginNetatmo::~DevicePluginNetatmo()
|
|||||||
|
|
||||||
void DevicePluginNetatmo::init()
|
void DevicePluginNetatmo::init()
|
||||||
{
|
{
|
||||||
m_pluginTimer = hardwareManager()->pluginTimerManager()->registerTimer(30);
|
|
||||||
connect(m_pluginTimer, &PluginTimer::timeout, this, &DevicePluginNetatmo::onPluginTimer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceManager::DeviceSetupStatus DevicePluginNetatmo::setupDevice(Device *device)
|
DeviceManager::DeviceSetupStatus DevicePluginNetatmo::setupDevice(Device *device)
|
||||||
@ -69,6 +68,11 @@ DeviceManager::DeviceSetupStatus DevicePluginNetatmo::setupDevice(Device *device
|
|||||||
if (device->deviceClassId() == netatmoConnectionDeviceClassId) {
|
if (device->deviceClassId() == netatmoConnectionDeviceClassId) {
|
||||||
qCDebug(dcNetatmo) << "Setup netatmo connection" << device->name() << device->params();
|
qCDebug(dcNetatmo) << "Setup netatmo connection" << device->name() << device->params();
|
||||||
|
|
||||||
|
if (!m_pluginTimer) {
|
||||||
|
m_pluginTimer = hardwareManager()->pluginTimerManager()->registerTimer(300);
|
||||||
|
connect(m_pluginTimer, &PluginTimer::timeout, this, &DevicePluginNetatmo::onPluginTimer);
|
||||||
|
}
|
||||||
|
|
||||||
OAuth2 *authentication = new OAuth2("561c015d49c75f0d1cce6e13", "GuvKkdtu7JQlPD47qTTepRR9hQ0CUPAj4Tae3Ohcq", this);
|
OAuth2 *authentication = new OAuth2("561c015d49c75f0d1cce6e13", "GuvKkdtu7JQlPD47qTTepRR9hQ0CUPAj4Tae3Ohcq", this);
|
||||||
authentication->setUrl(QUrl("https://api.netatmo.net/oauth2/token"));
|
authentication->setUrl(QUrl("https://api.netatmo.net/oauth2/token"));
|
||||||
authentication->setUsername(device->paramValue(netatmoConnectionDeviceUsernameParamTypeId).toString());
|
authentication->setUsername(device->paramValue(netatmoConnectionDeviceUsernameParamTypeId).toString());
|
||||||
@ -113,6 +117,12 @@ void DevicePluginNetatmo::deviceRemoved(Device *device)
|
|||||||
OAuth2 * authentication = m_authentications.key(device);
|
OAuth2 * authentication = m_authentications.key(device);
|
||||||
m_authentications.remove(authentication);
|
m_authentications.remove(authentication);
|
||||||
authentication->deleteLater();
|
authentication->deleteLater();
|
||||||
|
|
||||||
|
if (m_pluginTimer) {
|
||||||
|
m_pluginTimer->deleteLater();
|
||||||
|
m_pluginTimer = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
} else if (device->deviceClassId() == indoorDeviceClassId) {
|
} else if (device->deviceClassId() == indoorDeviceClassId) {
|
||||||
NetatmoBaseStation *indoor = m_indoorDevices.key(device);
|
NetatmoBaseStation *indoor = m_indoorDevices.key(device);
|
||||||
m_indoorDevices.remove(indoor);
|
m_indoorDevices.remove(indoor);
|
||||||
|
|||||||
@ -50,7 +50,7 @@ public slots:
|
|||||||
DeviceManager::DeviceError executeAction(Device *device, const Action &action) override;
|
DeviceManager::DeviceError executeAction(Device *device, const Action &action) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PluginTimer *m_pluginTimer;
|
PluginTimer *m_pluginTimer = nullptr;
|
||||||
QList<Device *> m_asyncSetups;
|
QList<Device *> m_asyncSetups;
|
||||||
|
|
||||||
QHash<OAuth2 *, Device *> m_authentications;
|
QHash<OAuth2 *, Device *> m_authentications;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user