fronius: devices to things
parent
b1f5c89944
commit
2e38fae9a7
|
|
@ -56,7 +56,7 @@ QUrl FroniusInverter::updateUrl()
|
|||
requestUrl.setHost(hostAddress());
|
||||
requestUrl.setPath(baseUrl() + "GetInverterRealtimeData.cgi");
|
||||
query.addQueryItem("Scope", "Device");
|
||||
query.addQueryItem("DeviceId", thingId().toString());
|
||||
query.addQueryItem("DeviceId", thingId());
|
||||
query.addQueryItem("DataCollection", "CommonInverterData");
|
||||
requestUrl.setQuery(query);
|
||||
|
||||
|
|
|
|||
|
|
@ -56,8 +56,8 @@ QUrl FroniusMeter::updateUrl()
|
|||
QUrlQuery query;
|
||||
requestUrl.setHost(hostAddress());
|
||||
requestUrl.setPath(baseUrl() + "GetMeterRealtimeData.cgi");
|
||||
query.addQueryItem("Scope", "Thing");
|
||||
query.addQueryItem("ThingId", thingId().toString());
|
||||
query.addQueryItem("Scope", "Device");
|
||||
query.addQueryItem("DeviceId", thingId());
|
||||
requestUrl.setQuery(query);
|
||||
return requestUrl;
|
||||
}
|
||||
|
|
@ -93,10 +93,8 @@ void FroniusMeter::updateThingInfo(const QByteArray &data)
|
|||
pluginThing()->setStateValue(meterTotalEnergyConsumedStateTypeId, dataMap.value("EnergyReal_WAC_Sum_Consumed").toInt()/1000);
|
||||
}
|
||||
|
||||
|
||||
//update successful
|
||||
pluginThing()->setStateValue(meterConnectedStateTypeId,true);
|
||||
|
||||
}
|
||||
|
||||
QUrl FroniusMeter::activityUrl()
|
||||
|
|
|
|||
|
|
@ -65,8 +65,8 @@ QUrl FroniusStorage::updateUrl()
|
|||
QUrlQuery query;
|
||||
requestUrl.setHost(hostAddress());
|
||||
requestUrl.setPath(baseUrl() + "GetStorageRealtimeData.cgi");
|
||||
query.addQueryItem("Scope", "Thing");
|
||||
query.addQueryItem("ThingId", thingId().toString());
|
||||
query.addQueryItem("Scope", "Device");
|
||||
query.addQueryItem("DeviceId", thingId());
|
||||
requestUrl.setQuery(query);
|
||||
|
||||
return requestUrl;
|
||||
|
|
|
|||
|
|
@ -36,12 +36,12 @@ void FroniusThing::setName(const QString &name)
|
|||
m_name = name;
|
||||
}
|
||||
|
||||
ThingId FroniusThing::hostId() const
|
||||
QString FroniusThing::hostId() const
|
||||
{
|
||||
return m_hostId;
|
||||
}
|
||||
|
||||
void FroniusThing::setHostId(const ThingId &hostId)
|
||||
void FroniusThing::setHostId(const QString &hostId)
|
||||
{
|
||||
m_hostId = hostId;
|
||||
}
|
||||
|
|
@ -76,12 +76,12 @@ void FroniusThing::setUniqueId(const QString &uniqueId)
|
|||
m_uniqueId = uniqueId;
|
||||
}
|
||||
|
||||
ThingId FroniusThing::thingId() const
|
||||
QString FroniusThing::thingId() const
|
||||
{
|
||||
return m_thingId;
|
||||
}
|
||||
|
||||
void FroniusThing::setThingId(const ThingId &thingId)
|
||||
void FroniusThing::setThingId(const QString &thingId)
|
||||
{
|
||||
m_thingId = thingId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,8 +48,8 @@ public:
|
|||
QString name() const;
|
||||
void setName(const QString &name);
|
||||
|
||||
ThingId hostId() const;
|
||||
void setHostId(const ThingId &hostId);
|
||||
QString hostId() const;
|
||||
void setHostId(const QString &hostId);
|
||||
|
||||
QString hostAddress() const;
|
||||
void setHostAddress(const QString &hostAddress);
|
||||
|
|
@ -60,8 +60,8 @@ public:
|
|||
QString uniqueId() const;
|
||||
void setUniqueId(const QString &uniqueId);
|
||||
|
||||
ThingId thingId() const;
|
||||
void setThingId(const ThingId &thingId);
|
||||
QString thingId() const;
|
||||
void setThingId(const QString &thingId);
|
||||
|
||||
Thing* pluginThing() const;
|
||||
|
||||
|
|
@ -70,12 +70,13 @@ private:
|
|||
Thing* m_thing;
|
||||
|
||||
QString m_name;
|
||||
ThingId m_hostId;
|
||||
QString m_hostId;
|
||||
QString m_hostAddress;
|
||||
QString m_apiVersion;
|
||||
QString m_baseUrl;
|
||||
QString m_uniqueId;
|
||||
ThingId m_thingId;
|
||||
QString m_thingId;
|
||||
|
||||
};
|
||||
|
||||
#endif // FRONIUSTHING_H
|
||||
|
|
|
|||
|
|
@ -100,15 +100,15 @@ void IntegrationPluginFronius::setupThing(ThingSetupInfo *info)
|
|||
} else if (thing->thingClassId() == inverterThingClassId) {
|
||||
|
||||
FroniusInverter *newInverter = new FroniusInverter(thing,this);
|
||||
newInverter->setThingId(thing->paramValue(inverterThingIdParamTypeId));
|
||||
newInverter->setThingId(thing->paramValue(inverterThingIdParamTypeId).toString());
|
||||
newInverter->setName(thing->paramValue(inverterThingNameParamTypeId).toString());
|
||||
newInverter->setBaseUrl(thing->paramValue(inverterThingBaseParamTypeId).toString());
|
||||
newInverter->setHostId(thing->paramValue(inverterThingHostIdParamTypeId));
|
||||
newInverter->setHostId(thing->paramValue(inverterThingHostIdParamTypeId).toString());
|
||||
newInverter->setHostAddress(thing->paramValue(inverterThingHostParamTypeId).toString());
|
||||
|
||||
m_froniusInverters.insert(newInverter,thing);
|
||||
|
||||
thing->setParentId(newInverter->hostId());
|
||||
thing->setParentId(ThingId(newInverter->hostId()));
|
||||
thing->setName(newInverter->name());
|
||||
|
||||
// get inverter unique ID
|
||||
|
|
@ -161,7 +161,7 @@ void IntegrationPluginFronius::setupThing(ThingSetupInfo *info)
|
|||
|
||||
m_froniusStorages.insert(newStorage,thing);
|
||||
|
||||
thing->setParentId(newStorage->hostId());
|
||||
thing->setParentId(ThingId(newStorage->hostId()));
|
||||
thing->setName(newStorage->name());
|
||||
|
||||
// Get storage manufacturer and maximum capacity
|
||||
|
|
@ -213,7 +213,7 @@ void IntegrationPluginFronius::setupThing(ThingSetupInfo *info)
|
|||
|
||||
m_froniusMeters.insert(newMeter,thing);
|
||||
|
||||
thing->setParentId(newMeter->hostId());
|
||||
thing->setParentId(ThingId(newMeter->hostId()));
|
||||
thing->setName(newMeter->name());
|
||||
|
||||
info->finish(Thing::ThingErrorNoError);
|
||||
|
|
@ -318,13 +318,11 @@ void IntegrationPluginFronius::executeAction(ThingActionInfo *info)
|
|||
Thing *thing = info->thing();
|
||||
qCDebug(dcFronius()) << "Execute action" << thing->name() << action.actionTypeId().toString();
|
||||
|
||||
if (thing->thingClassId() == inverterThingClassId ||
|
||||
thing->thingClassId() == dataloggerThingClassId ||
|
||||
thing->thingClassId() == storageThingClassId) {
|
||||
if (thing->thingClassId() == dataloggerThingClassId) {
|
||||
|
||||
if (action.actionTypeId() == dataloggerSearchThingsActionTypeId) {
|
||||
if (action.actionTypeId() == dataloggerSearchDevicesActionTypeId) {
|
||||
searchNewThings(m_froniusLoggers.key(thing));
|
||||
info->finish(ThingManager::ThingErrorNoError);
|
||||
info->finish(Thing::ThingErrorNoError);
|
||||
} else {
|
||||
Q_ASSERT_X(false, "executeAction", QString("Unhandled action: %1").arg(action.actionTypeId().toString()).toUtf8());
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue