diff --git a/mypv/integrationpluginmypv.cpp b/mypv/integrationpluginmypv.cpp
index 65ffad5..84e9ba6 100644
--- a/mypv/integrationpluginmypv.cpp
+++ b/mypv/integrationpluginmypv.cpp
@@ -41,6 +41,7 @@ IntegrationPluginMyPv::IntegrationPluginMyPv()
void IntegrationPluginMyPv::discoverThings(ThingDiscoveryInfo *info)
{
+ if (info->thingClassId() == elwaThingClassId) {
QUdpSocket *searchSocket = new QUdpSocket(this);
// Note: This will fail, and it's not a problem, but it is required to force the socket to stick to IPv4...
@@ -56,7 +57,7 @@ void IntegrationPluginMyPv::discoverThings(ThingDiscoveryInfo *info)
qint64 len = searchSocket->writeDatagram(discoveryString, QHostAddress("255.255.255.255"), 16124);
if (len != discoveryString.length()) {
searchSocket->deleteLater();
- qCWarning(dcMypv()) << "Error sending discovery";
+ info->finish(Thing::ThingErrorHardwareNotAvailable , tr("Error starting device discovery"));
return;
}
@@ -87,33 +88,30 @@ void IntegrationPluginMyPv::discoverThings(ThingDiscoveryInfo *info)
continue;
}
- quint32 uiAddress = 0;
- for (int i=0; i<4; i++) {
- uiAddress |= data.at(7-i) << (i*8);
- }
- QHostAddress address(uiAddress);
+ ThingDescriptor thingDescriptors(info->thingClassId(), "AC ELWA-E", senderAddress.toString());
QByteArray serialNumber = data.mid(8, 16);
- bool existing = false;
foreach (Thing *existingThing, myThings()) {
- if (existingThing->thingClassId() == info->thingClassId() && existingThing->paramValue(elwaThingIpAddressParamTypeId).toString() == address.toString()) {
- existing = true;
+ if (serialNumber == existingThing->paramValue(elwaThingSerialNumberParamTypeId).toString()) {
+ qCDebug(dcMypv()) << "Rediscovered device " << existingThing->name();
+ thingDescriptors.setThingId(existingThing->id());
+ break;
}
}
- if (existing) {
- qCDebug(dcMypv()) << "Already have device" << senderAddress << "in configured devices. Skipping...";
- continue;
- }
- ThingDescriptor thingDescriptors(info->thingClassId(), "AC ELWA-E", address.toString());
+
ParamList params;
- params << Param(elwaThingIpAddressParamTypeId, address.toString());
+ params << Param(elwaThingIpAddressParamTypeId, senderAddress.toString());
params << Param(elwaThingSerialNumberParamTypeId, serialNumber);
thingDescriptors.setParams(params);
descriptorList << thingDescriptors;
}
info->addThingDescriptors(descriptorList);;
searchSocket->deleteLater();
+ info->finish(Thing::ThingErrorNoError);
});
+ } else {
+ Q_ASSERT_X(false, "discoverThings", QString("Unhandled thingClassId: %1").arg(info->thingClassId().toString()).toUtf8());
+ }
}
void IntegrationPluginMyPv::setupThing(ThingSetupInfo *info)
@@ -130,7 +128,7 @@ void IntegrationPluginMyPv::setupThing(ThingSetupInfo *info)
m_modbusTcpMasters.insert(thing, modbusTcpMaster);
} else {
- Q_ASSERT_X(false, "setupDevice", QString("Unhandled deviceClassId: %1").arg(thing->thingClassId().toString()).toUtf8());
+ Q_ASSERT_X(false, "setupThing", QString("Unhandled thingClassId: %1").arg(thing->thingClassId().toString()).toUtf8());
}
}
@@ -159,14 +157,23 @@ void IntegrationPluginMyPv::executeAction(ThingActionInfo *info)
ModbusTCPMaster *modbusTCPMaster = m_modbusTcpMasters.value(thing);
if (action.actionTypeId() == elwaHeatingPowerActionTypeId) {
int heatingPower = action.param(elwaHeatingPowerActionHeatingPowerParamTypeId).value().toInt();
-
QUuid requestId = modbusTCPMaster->writeHoldingRegister(0xff, ElwaModbusRegisters::Power, heatingPower);
- m_asyncActions.insert(requestId, info);
+ if (requestId.isNull()) {
+ info->finish(Thing::ThingErrorHardwareNotAvailable);
+ } else {
+ m_asyncActions.insert(requestId, info);
+ connect(info, &ThingActionInfo::aborted, this, [this, requestId] {m_asyncActions.remove(requestId);});
+ }
} else if (action.actionTypeId() == elwaPowerActionTypeId) {
bool power = action.param(elwaHeatingPowerActionHeatingPowerParamTypeId).value().toBool();
if(power) {
QUuid requestId = modbusTCPMaster->writeHoldingRegister(0xff, ElwaModbusRegisters::ManuelStart, 1);
- m_asyncActions.insert(requestId, info);
+ if (requestId.isNull()) {
+ info->finish(Thing::ThingErrorHardwareNotAvailable);
+ } else {
+ m_asyncActions.insert(requestId, info);
+ connect(info, &ThingActionInfo::aborted, this, [this, requestId] {m_asyncActions.remove(requestId);});
+ }
}
} else {
Q_ASSERT_X(false, "executeAction", QString("Unhandled actionTypeId: %1").arg(action.actionTypeId().toString()).toUtf8());
diff --git a/mypv/translations/73c7efcc-80d5-4166-ad97-2cbbeb129d91-de.ts b/mypv/translations/73c7efcc-80d5-4166-ad97-2cbbeb129d91-de.ts
new file mode 100644
index 0000000..47d5076
--- /dev/null
+++ b/mypv/translations/73c7efcc-80d5-4166-ad97-2cbbeb129d91-de.ts
@@ -0,0 +1,153 @@
+
+
+
+
+ IntegrationPluginMyPv
+
+
+ Error starting device discovery
+ Fehler beim starten der Gerätesuche
+
+
+
+ Mypv
+
+
+ AC Elwa E
+ The name of the ThingClass ({19ac4c7c-9c0a-4998-a8f0-c77d940cbb08})
+ AC Elwa E
+
+
+
+ Change power
+ The name of the ActionType ({e6b0260b-f255-4f17-8ac1-bc87a950f449}) of ThingClass elwa
+ Ändere Eingeschalten
+
+
+
+ Change power consumption
+ The name of the ActionType ({2eb3c40c-1b43-4b64-82e2-6558f0b8817e}) of ThingClass elwa
+ Ändere Leistungsverbrauch
+
+
+
+
+ Connected
+ The name of the ParamType (ThingClass: elwa, EventType: connected, ID: {a5afaad5-78bf-4cac-b98d-7eae31aac518})
+----------
+The name of the StateType ({a5afaad5-78bf-4cac-b98d-7eae31aac518}) of ThingClass elwa
+ Verbunden
+
+
+
+ Connected changed
+ The name of the EventType ({a5afaad5-78bf-4cac-b98d-7eae31aac518}) of ThingClass elwa
+ Verbunden geändert
+
+
+
+ IP address
+ The name of the ParamType (ThingClass: elwa, Type: thing, ID: {ae66596f-f6c7-4d9c-9eee-b9190616a9e1})
+ IP-Adresse
+
+
+
+ Mypv
+ The name of the plugin Mypv ({73c7efcc-80d5-4166-ad97-2cbbeb129d91})
+ my-PV
+
+
+
+
+
+ Power
+ The name of the ParamType (ThingClass: elwa, ActionType: power, ID: {e6b0260b-f255-4f17-8ac1-bc87a950f449})
+----------
+The name of the ParamType (ThingClass: elwa, EventType: power, ID: {e6b0260b-f255-4f17-8ac1-bc87a950f449})
+----------
+The name of the StateType ({e6b0260b-f255-4f17-8ac1-bc87a950f449}) of ThingClass elwa
+ Eingeschalten
+
+
+
+ Power changed
+ The name of the EventType ({e6b0260b-f255-4f17-8ac1-bc87a950f449}) of ThingClass elwa
+ Leistung geändert
+
+
+
+
+
+ Power consumption
+ The name of the ParamType (ThingClass: elwa, ActionType: heatingPower, ID: {2eb3c40c-1b43-4b64-82e2-6558f0b8817e})
+----------
+The name of the ParamType (ThingClass: elwa, EventType: heatingPower, ID: {2eb3c40c-1b43-4b64-82e2-6558f0b8817e})
+----------
+The name of the StateType ({2eb3c40c-1b43-4b64-82e2-6558f0b8817e}) of ThingClass elwa
+ Leistung
+
+
+
+ Power consumption changed
+ The name of the EventType ({2eb3c40c-1b43-4b64-82e2-6558f0b8817e}) of ThingClass elwa
+ Leistung geändert
+
+
+
+ Serial number
+ The name of the ParamType (ThingClass: elwa, Type: thing, ID: {b31a263a-2fdc-4a88-88ec-9e182025da8f})
+ Seriennummer
+
+
+
+
+ Status
+ The name of the ParamType (ThingClass: elwa, EventType: status, ID: {d0a7065e-7773-47d7-b474-ce8d21d55aa7})
+----------
+The name of the StateType ({d0a7065e-7773-47d7-b474-ce8d21d55aa7}) of ThingClass elwa
+ Status
+
+
+
+ Status changed
+ The name of the EventType ({d0a7065e-7773-47d7-b474-ce8d21d55aa7}) of ThingClass elwa
+ Status geändert
+
+
+
+
+ Target water temperature
+ The name of the ParamType (ThingClass: elwa, EventType: targetWaterTemperature, ID: {2b089c93-6411-41f7-96aa-f78d5cf910cb})
+----------
+The name of the StateType ({2b089c93-6411-41f7-96aa-f78d5cf910cb}) of ThingClass elwa
+ Zielwassertemperatur
+
+
+
+ Target water temperature changed
+ The name of the EventType ({2b089c93-6411-41f7-96aa-f78d5cf910cb}) of ThingClass elwa
+ Zielwassertemperatur geändert
+
+
+
+
+ Water temperature
+ The name of the ParamType (ThingClass: elwa, EventType: temperature, ID: {60006f93-8852-433b-bbc0-f10cc3939eeb})
+----------
+The name of the StateType ({60006f93-8852-433b-bbc0-f10cc3939eeb}) of ThingClass elwa
+ Wassertemperatur
+
+
+
+ Water temperature changed
+ The name of the EventType ({60006f93-8852-433b-bbc0-f10cc3939eeb}) of ThingClass elwa
+ Wassertemperatur geändert
+
+
+
+ my-PV
+ The name of the vendor ({1f17597f-e0d0-459b-858d-ec9cbcd10b2c})
+ my-PV
+
+
+
diff --git a/mypv/translations/73c7efcc-80d5-4166-ad97-2cbbeb129d91-en_US.ts b/mypv/translations/73c7efcc-80d5-4166-ad97-2cbbeb129d91-en_US.ts
new file mode 100644
index 0000000..5c10149
--- /dev/null
+++ b/mypv/translations/73c7efcc-80d5-4166-ad97-2cbbeb129d91-en_US.ts
@@ -0,0 +1,153 @@
+
+
+
+
+ IntegrationPluginMyPv
+
+
+ Error starting device discovery
+
+
+
+
+ Mypv
+
+
+ AC Elwa E
+ The name of the ThingClass ({19ac4c7c-9c0a-4998-a8f0-c77d940cbb08})
+
+
+
+
+ Change power
+ The name of the ActionType ({e6b0260b-f255-4f17-8ac1-bc87a950f449}) of ThingClass elwa
+
+
+
+
+ Change power consumption
+ The name of the ActionType ({2eb3c40c-1b43-4b64-82e2-6558f0b8817e}) of ThingClass elwa
+
+
+
+
+
+ Connected
+ The name of the ParamType (ThingClass: elwa, EventType: connected, ID: {a5afaad5-78bf-4cac-b98d-7eae31aac518})
+----------
+The name of the StateType ({a5afaad5-78bf-4cac-b98d-7eae31aac518}) of ThingClass elwa
+
+
+
+
+ Connected changed
+ The name of the EventType ({a5afaad5-78bf-4cac-b98d-7eae31aac518}) of ThingClass elwa
+
+
+
+
+ IP address
+ The name of the ParamType (ThingClass: elwa, Type: thing, ID: {ae66596f-f6c7-4d9c-9eee-b9190616a9e1})
+
+
+
+
+ Mypv
+ The name of the plugin Mypv ({73c7efcc-80d5-4166-ad97-2cbbeb129d91})
+
+
+
+
+
+
+ Power
+ The name of the ParamType (ThingClass: elwa, ActionType: power, ID: {e6b0260b-f255-4f17-8ac1-bc87a950f449})
+----------
+The name of the ParamType (ThingClass: elwa, EventType: power, ID: {e6b0260b-f255-4f17-8ac1-bc87a950f449})
+----------
+The name of the StateType ({e6b0260b-f255-4f17-8ac1-bc87a950f449}) of ThingClass elwa
+
+
+
+
+ Power changed
+ The name of the EventType ({e6b0260b-f255-4f17-8ac1-bc87a950f449}) of ThingClass elwa
+
+
+
+
+
+
+ Power consumption
+ The name of the ParamType (ThingClass: elwa, ActionType: heatingPower, ID: {2eb3c40c-1b43-4b64-82e2-6558f0b8817e})
+----------
+The name of the ParamType (ThingClass: elwa, EventType: heatingPower, ID: {2eb3c40c-1b43-4b64-82e2-6558f0b8817e})
+----------
+The name of the StateType ({2eb3c40c-1b43-4b64-82e2-6558f0b8817e}) of ThingClass elwa
+
+
+
+
+ Power consumption changed
+ The name of the EventType ({2eb3c40c-1b43-4b64-82e2-6558f0b8817e}) of ThingClass elwa
+
+
+
+
+ Serial number
+ The name of the ParamType (ThingClass: elwa, Type: thing, ID: {b31a263a-2fdc-4a88-88ec-9e182025da8f})
+
+
+
+
+
+ Status
+ The name of the ParamType (ThingClass: elwa, EventType: status, ID: {d0a7065e-7773-47d7-b474-ce8d21d55aa7})
+----------
+The name of the StateType ({d0a7065e-7773-47d7-b474-ce8d21d55aa7}) of ThingClass elwa
+
+
+
+
+ Status changed
+ The name of the EventType ({d0a7065e-7773-47d7-b474-ce8d21d55aa7}) of ThingClass elwa
+
+
+
+
+
+ Target water temperature
+ The name of the ParamType (ThingClass: elwa, EventType: targetWaterTemperature, ID: {2b089c93-6411-41f7-96aa-f78d5cf910cb})
+----------
+The name of the StateType ({2b089c93-6411-41f7-96aa-f78d5cf910cb}) of ThingClass elwa
+
+
+
+
+ Target water temperature changed
+ The name of the EventType ({2b089c93-6411-41f7-96aa-f78d5cf910cb}) of ThingClass elwa
+
+
+
+
+
+ Water temperature
+ The name of the ParamType (ThingClass: elwa, EventType: temperature, ID: {60006f93-8852-433b-bbc0-f10cc3939eeb})
+----------
+The name of the StateType ({60006f93-8852-433b-bbc0-f10cc3939eeb}) of ThingClass elwa
+
+
+
+
+ Water temperature changed
+ The name of the EventType ({60006f93-8852-433b-bbc0-f10cc3939eeb}) of ThingClass elwa
+
+
+
+
+ my-PV
+ The name of the vendor ({1f17597f-e0d0-459b-858d-ec9cbcd10b2c})
+
+
+
+