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