switch netatmo plugin to use new parenting mechanism
parent
540acbf2b1
commit
46f5b514fb
|
|
@ -86,9 +86,8 @@ DeviceManager::DeviceSetupStatus DevicePluginNetatmo::setupDevice(Device *device
|
|||
qCDebug(dcNetatmo) << "Setup netatmo indoor base station" << device->params();
|
||||
NetatmoBaseStation *indoor = new NetatmoBaseStation(device->paramValue(indoorNameParamTypeId).toString(),
|
||||
device->paramValue(indoorMacParamTypeId).toString(),
|
||||
device->paramValue(indoorConnectionParamTypeId).toString(), this);
|
||||
this);
|
||||
|
||||
device->setParentId(DeviceId(indoor->connectionId()));
|
||||
m_indoorDevices.insert(indoor, device);
|
||||
connect(indoor, SIGNAL(statesChanged()), this, SLOT(onIndoorStatesChanged()));
|
||||
|
||||
|
|
@ -97,10 +96,9 @@ DeviceManager::DeviceSetupStatus DevicePluginNetatmo::setupDevice(Device *device
|
|||
qCDebug(dcNetatmo) << "Setup netatmo outdoor module" << device->params();
|
||||
NetatmoOutdoorModule *outdoor = new NetatmoOutdoorModule(device->paramValue(outdoorNameParamTypeId).toString(),
|
||||
device->paramValue(outdoorMacParamTypeId).toString(),
|
||||
device->paramValue(outdoorConnectionParamTypeId).toString(),
|
||||
device->paramValue(outdoorBaseStationParamTypeId).toString(),this);
|
||||
device->paramValue(outdoorBaseStationParamTypeId).toString(),
|
||||
this);
|
||||
|
||||
device->setParentId(DeviceId(outdoor->connectionId()));
|
||||
m_outdoorDevices.insert(outdoor, device);
|
||||
connect(outdoor, SIGNAL(statesChanged()), this, SLOT(onOutdoorStatesChanged()));
|
||||
|
||||
|
|
@ -163,11 +161,10 @@ void DevicePluginNetatmo::processRefreshData(const QVariantMap &data, const QStr
|
|||
Device *indoorDevice = findIndoorDevice(deviceMap.value("_id").toString());
|
||||
// check if we have to create the device (auto)
|
||||
if (!indoorDevice) {
|
||||
DeviceDescriptor descriptor(indoorDeviceClassId, "Indoor Station", deviceMap.value("station_name").toString());
|
||||
DeviceDescriptor descriptor(indoorDeviceClassId, "Indoor Station", deviceMap.value("station_name").toString(), connectionId);
|
||||
ParamList params;
|
||||
params.append(Param(indoorNameParamTypeId, deviceMap.value("station_name").toString()));
|
||||
params.append(Param(indoorMacParamTypeId, deviceMap.value("_id").toString()));
|
||||
params.append(Param(indoorConnectionParamTypeId, connectionId));
|
||||
descriptor.setParams(params);
|
||||
emit autoDevicesAppeared(indoorDeviceClassId, QList<DeviceDescriptor>() << descriptor);
|
||||
} else {
|
||||
|
|
@ -190,11 +187,10 @@ void DevicePluginNetatmo::processRefreshData(const QVariantMap &data, const QStr
|
|||
Device *outdoorDevice = findOutdoorDevice(moduleMap.value("_id").toString());
|
||||
// check if we have to create the device (auto)
|
||||
if (!outdoorDevice) {
|
||||
DeviceDescriptor descriptor(outdoorDeviceClassId, "Outdoor Module", moduleMap.value("module_name").toString());
|
||||
DeviceDescriptor descriptor(outdoorDeviceClassId, "Outdoor Module", moduleMap.value("module_name").toString(), connectionId);
|
||||
ParamList params;
|
||||
params.append(Param(outdoorNameParamTypeId, moduleMap.value("module_name").toString()));
|
||||
params.append(Param(outdoorMacParamTypeId, moduleMap.value("_id").toString()));
|
||||
params.append(Param(outdoorConnectionParamTypeId, connectionId));
|
||||
params.append(Param(outdoorBaseStationParamTypeId, moduleMap.value("main_device").toString()));
|
||||
descriptor.setParams(params);
|
||||
emit autoDevicesAppeared(outdoorDeviceClassId, QList<DeviceDescriptor>() << descriptor);
|
||||
|
|
|
|||
|
|
@ -75,14 +75,6 @@
|
|||
"type": "QString",
|
||||
"inputType": "TextLine",
|
||||
"readOnly": true
|
||||
},
|
||||
{
|
||||
"id": "c15e5dea-10f2-4c96-afab-649872f43d5c",
|
||||
"name": "connection",
|
||||
"displayName": "connection",
|
||||
"type": "QString",
|
||||
"inputType": "TextLine",
|
||||
"readOnly": true
|
||||
}
|
||||
],
|
||||
"stateTypes": [
|
||||
|
|
@ -206,14 +198,6 @@
|
|||
"inputType": "TextLine",
|
||||
"readOnly": true
|
||||
},
|
||||
{
|
||||
"id": "c15e5dea-10f2-4c96-afab-649872f43d5c",
|
||||
"name": "connection",
|
||||
"displayName": "connection",
|
||||
"type": "QString",
|
||||
"inputType": "TextLine",
|
||||
"readOnly": true
|
||||
},
|
||||
{
|
||||
"id": "d7a0ec46-760c-4fdc-9753-fe10c86fe1b9",
|
||||
"name": "baseStation",
|
||||
|
|
|
|||
|
|
@ -24,11 +24,10 @@
|
|||
|
||||
#include <QVariantMap>
|
||||
|
||||
NetatmoBaseStation::NetatmoBaseStation(const QString &name, const QString &macAddress, const QString &connectionId, QObject *parent) :
|
||||
NetatmoBaseStation::NetatmoBaseStation(const QString &name, const QString &macAddress, QObject *parent) :
|
||||
QObject(parent),
|
||||
m_name(name),
|
||||
m_macAddress(macAddress),
|
||||
m_connectionId(connectionId)
|
||||
m_macAddress(macAddress)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -42,11 +41,6 @@ QString NetatmoBaseStation::macAddress() const
|
|||
return m_macAddress;
|
||||
}
|
||||
|
||||
QString NetatmoBaseStation::connectionId() const
|
||||
{
|
||||
return m_connectionId;
|
||||
}
|
||||
|
||||
int NetatmoBaseStation::lastUpdate() const
|
||||
{
|
||||
return m_lastUpdate;
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ class NetatmoBaseStation : public QObject
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit NetatmoBaseStation(const QString &name, const QString &macAddress, const QString &connectionId, QObject *parent = 0);
|
||||
explicit NetatmoBaseStation(const QString &name, const QString &macAddress, QObject *parent = 0);
|
||||
|
||||
// Params
|
||||
QString name() const;
|
||||
|
|
@ -54,7 +54,6 @@ private:
|
|||
// Params
|
||||
QString m_name;
|
||||
QString m_macAddress;
|
||||
QString m_connectionId;
|
||||
|
||||
// States
|
||||
int m_lastUpdate;
|
||||
|
|
|
|||
|
|
@ -24,11 +24,10 @@
|
|||
|
||||
#include <QVariantMap>
|
||||
|
||||
NetatmoOutdoorModule::NetatmoOutdoorModule(const QString &name, const QString &macAddress, const QString &connectionId, const QString &baseStation, QObject *parent) :
|
||||
NetatmoOutdoorModule::NetatmoOutdoorModule(const QString &name, const QString &macAddress, const QString &baseStation, QObject *parent) :
|
||||
QObject(parent),
|
||||
m_name(name),
|
||||
m_macAddress(macAddress),
|
||||
m_connectionId(connectionId),
|
||||
m_baseStation(baseStation)
|
||||
{
|
||||
}
|
||||
|
|
@ -43,11 +42,6 @@ QString NetatmoOutdoorModule::macAddress() const
|
|||
return m_macAddress;
|
||||
}
|
||||
|
||||
QString NetatmoOutdoorModule::connectionId() const
|
||||
{
|
||||
return m_connectionId;
|
||||
}
|
||||
|
||||
QString NetatmoOutdoorModule::baseStation() const
|
||||
{
|
||||
return m_baseStation;
|
||||
|
|
|
|||
|
|
@ -29,12 +29,11 @@ class NetatmoOutdoorModule : public QObject
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit NetatmoOutdoorModule(const QString &name, const QString &macAddress, const QString &connectionId, const QString &baseStation, QObject *parent = 0);
|
||||
explicit NetatmoOutdoorModule(const QString &name, const QString &macAddress, const QString &baseStation, QObject *parent = 0);
|
||||
|
||||
// Params
|
||||
QString name() const;
|
||||
QString macAddress() const;
|
||||
QString connectionId() const;
|
||||
QString baseStation() const;
|
||||
|
||||
// States
|
||||
|
|
@ -52,7 +51,6 @@ private:
|
|||
// Params
|
||||
QString m_name;
|
||||
QString m_macAddress;
|
||||
QString m_connectionId;
|
||||
QString m_baseStation;
|
||||
|
||||
// States
|
||||
|
|
|
|||
Loading…
Reference in New Issue