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