Log interesting go-eCharger states and fix execute action and discovry
This commit is contained in:
parent
1a09836dd7
commit
24a7ce13be
@ -59,9 +59,14 @@ void IntegrationPluginGoECharger::discoverThings(ThingDiscoveryInfo *info)
|
|||||||
foreach (const NetworkDevice &networkDevice, discoveryReply->networkDevices()) {
|
foreach (const NetworkDevice &networkDevice, discoveryReply->networkDevices()) {
|
||||||
|
|
||||||
qCDebug(dcGoECharger()) << "Found" << networkDevice;
|
qCDebug(dcGoECharger()) << "Found" << networkDevice;
|
||||||
|
// Filter by hostname
|
||||||
if (!networkDevice.hostName().toLower().contains("go-echarger"))
|
if (!networkDevice.hostName().toLower().contains("go-echarger"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
// We need also the mac address
|
||||||
|
if (!networkDevice.macAddress().isEmpty())
|
||||||
|
continue;
|
||||||
|
|
||||||
QString title;
|
QString title;
|
||||||
if (networkDevice.hostName().isEmpty()) {
|
if (networkDevice.hostName().isEmpty()) {
|
||||||
title = networkDevice.address().toString();
|
title = networkDevice.address().toString();
|
||||||
@ -152,7 +157,8 @@ void IntegrationPluginGoECharger::executeAction(ThingActionInfo *info)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (thing->stateValue(goeHomeConnectedStateTypeId).toBool()) {
|
if (!thing->stateValue(goeHomeConnectedStateTypeId).toBool()) {
|
||||||
|
qCWarning(dcGoECharger()) << thing << "failed to execute action. The device seems not to be connected.";
|
||||||
info->finish(Thing::ThingErrorHardwareNotAvailable);
|
info->finish(Thing::ThingErrorHardwareNotAvailable);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -246,6 +252,8 @@ void IntegrationPluginGoECharger::onPublishReceived(MqttChannel *channel, const
|
|||||||
QString serialNumber = thing->stateValue(goeHomeSerialNumberStateTypeId).toString();
|
QString serialNumber = thing->stateValue(goeHomeSerialNumberStateTypeId).toString();
|
||||||
if (topic == QString("go-eCharger/%1/status").arg(serialNumber)) {
|
if (topic == QString("go-eCharger/%1/status").arg(serialNumber)) {
|
||||||
update(thing, jsonDoc.toVariant().toMap());
|
update(thing, jsonDoc.toVariant().toMap());
|
||||||
|
} else {
|
||||||
|
qCDebug(dcGoECharger()) << "Unhandled topic publish received:" << topic << qUtf8Printable(jsonDoc.toJson(QJsonDocument::Compact));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -338,8 +346,8 @@ void IntegrationPluginGoECharger::sendActionRequest(Thing *thing, ThingActionInf
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
qCDebug(dcGoECharger()) << "Action response" << jsonDoc.toJson(QJsonDocument::Compact);
|
|
||||||
info->finish(Thing::ThingErrorNoError);
|
info->finish(Thing::ThingErrorNoError);
|
||||||
|
update(thing, jsonDoc.toVariant().toMap());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -349,9 +357,10 @@ void IntegrationPluginGoECharger::setupMqttChannel(ThingSetupInfo *info, const Q
|
|||||||
QString serialNumber = statusMap.value("sse").toString();
|
QString serialNumber = statusMap.value("sse").toString();
|
||||||
QString clientId = QString("go-eCharger:%1:%2").arg(serialNumber).arg(statusMap.value("rbc").toInt());
|
QString clientId = QString("go-eCharger:%1:%2").arg(serialNumber).arg(statusMap.value("rbc").toInt());
|
||||||
QString statusTopic = QString("go-eCharger/%1/status").arg(serialNumber);
|
QString statusTopic = QString("go-eCharger/%1/status").arg(serialNumber);
|
||||||
qCDebug(dcGoECharger()) << "Setting up mqtt channel for" << thing << address.toString() << statusTopic;
|
QString commandTopic = QString("go-eCharger/%1/cmd/req").arg(serialNumber);
|
||||||
|
qCDebug(dcGoECharger()) << "Setting up mqtt channel for" << thing << address.toString() << statusTopic << commandTopic;
|
||||||
|
|
||||||
MqttChannel *channel = hardwareManager()->mqttProvider()->createChannel(clientId, address, {statusTopic});
|
MqttChannel *channel = hardwareManager()->mqttProvider()->createChannel(clientId, address, {statusTopic, commandTopic});
|
||||||
if (!channel) {
|
if (!channel) {
|
||||||
qCWarning(dcGoECharger()) << "Failed to create MQTT channel for" << thing;
|
qCWarning(dcGoECharger()) << "Failed to create MQTT channel for" << thing;
|
||||||
info->finish(Thing::ThingErrorHardwareFailure, QT_TR_NOOP("Error creating MQTT channel. Please check MQTT server settings."));
|
info->finish(Thing::ThingErrorHardwareFailure, QT_TR_NOOP("Error creating MQTT channel. Please check MQTT server settings."));
|
||||||
|
|||||||
@ -50,7 +50,8 @@
|
|||||||
"Waiting for vehicle",
|
"Waiting for vehicle",
|
||||||
"Charging finished and vehicle still connected"
|
"Charging finished and vehicle still connected"
|
||||||
],
|
],
|
||||||
"defaultValue": "Ready but no vehicle connected"
|
"defaultValue": "Ready but no vehicle connected",
|
||||||
|
"suggestLogging": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "d80e1ed8-c3ae-4b68-bf86-21b4d7b2b201",
|
"id": "d80e1ed8-c3ae-4b68-bf86-21b4d7b2b201",
|
||||||
@ -63,7 +64,8 @@
|
|||||||
"RFID",
|
"RFID",
|
||||||
"Automatic"
|
"Automatic"
|
||||||
],
|
],
|
||||||
"defaultValue": "Open"
|
"defaultValue": "Open",
|
||||||
|
"suggestLogging": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "8a7ab9f1-0143-494c-98ee-69f94125fe42",
|
"id": "8a7ab9f1-0143-494c-98ee-69f94125fe42",
|
||||||
@ -96,7 +98,8 @@
|
|||||||
"displayNameEvent": "Cloud enabled changed",
|
"displayNameEvent": "Cloud enabled changed",
|
||||||
"type": "bool",
|
"type": "bool",
|
||||||
"defaultValue": true,
|
"defaultValue": true,
|
||||||
"writable": true
|
"writable": true,
|
||||||
|
"suggestLogging": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "08b107bc-1284-455d-9e5a-6a1c3adc389f",
|
"id": "08b107bc-1284-455d-9e5a-6a1c3adc389f",
|
||||||
@ -104,7 +107,8 @@
|
|||||||
"displayName": "Update available",
|
"displayName": "Update available",
|
||||||
"displayNameEvent": "Update available changed",
|
"displayNameEvent": "Update available changed",
|
||||||
"type": "bool",
|
"type": "bool",
|
||||||
"defaultValue": false
|
"defaultValue": false,
|
||||||
|
"suggestLogging": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "d557e59e-ca22-4aff-bf80-dfee44db0f69",
|
"id": "d557e59e-ca22-4aff-bf80-dfee44db0f69",
|
||||||
@ -112,7 +116,8 @@
|
|||||||
"displayName": "Adapter connected",
|
"displayName": "Adapter connected",
|
||||||
"displayNameEvent": "Adapter connected changed",
|
"displayNameEvent": "Adapter connected changed",
|
||||||
"type": "bool",
|
"type": "bool",
|
||||||
"defaultValue": false
|
"defaultValue": false,
|
||||||
|
"suggestLogging": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "d8f5abb6-5db3-4040-8829-553b1d881ce4",
|
"id": "d8f5abb6-5db3-4040-8829-553b1d881ce4",
|
||||||
@ -130,7 +135,8 @@
|
|||||||
"displayNameEvent": "Charge energy changed",
|
"displayNameEvent": "Charge energy changed",
|
||||||
"type": "double",
|
"type": "double",
|
||||||
"unit": "KiloWattHour",
|
"unit": "KiloWattHour",
|
||||||
"defaultValue": 0.0
|
"defaultValue": 0.0,
|
||||||
|
"suggestLogging": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "b06479d5-7a38-4fbd-867e-e55bdb54651b",
|
"id": "b06479d5-7a38-4fbd-867e-e55bdb54651b",
|
||||||
@ -161,7 +167,8 @@
|
|||||||
"displayNameEvent": "Temperature 1 changed",
|
"displayNameEvent": "Temperature 1 changed",
|
||||||
"type": "double",
|
"type": "double",
|
||||||
"unit": "DegreeCelsius",
|
"unit": "DegreeCelsius",
|
||||||
"defaultValue": 0.0
|
"defaultValue": 0.0,
|
||||||
|
"suggestLogging": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "558e273a-4028-495a-902a-e4e932a0ae24",
|
"id": "558e273a-4028-495a-902a-e4e932a0ae24",
|
||||||
@ -170,7 +177,8 @@
|
|||||||
"displayNameEvent": "Temperature 2 changed",
|
"displayNameEvent": "Temperature 2 changed",
|
||||||
"type": "double",
|
"type": "double",
|
||||||
"unit": "DegreeCelsius",
|
"unit": "DegreeCelsius",
|
||||||
"defaultValue": 0.0
|
"defaultValue": 0.0,
|
||||||
|
"suggestLogging": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "dbf8a5dc-b8f5-437a-ac0c-c4cf8a09aacb",
|
"id": "dbf8a5dc-b8f5-437a-ac0c-c4cf8a09aacb",
|
||||||
@ -179,7 +187,8 @@
|
|||||||
"displayNameEvent": "Temperature 3 changed",
|
"displayNameEvent": "Temperature 3 changed",
|
||||||
"type": "double",
|
"type": "double",
|
||||||
"unit": "DegreeCelsius",
|
"unit": "DegreeCelsius",
|
||||||
"defaultValue": 0.0
|
"defaultValue": 0.0,
|
||||||
|
"suggestLogging": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "1953e29f-fe28-4016-9b05-f4baf4c311ff",
|
"id": "1953e29f-fe28-4016-9b05-f4baf4c311ff",
|
||||||
@ -188,7 +197,8 @@
|
|||||||
"displayNameEvent": "Temperature 4 changed",
|
"displayNameEvent": "Temperature 4 changed",
|
||||||
"type": "double",
|
"type": "double",
|
||||||
"unit": "DegreeCelsius",
|
"unit": "DegreeCelsius",
|
||||||
"defaultValue": 0.0
|
"defaultValue": 0.0,
|
||||||
|
"suggestLogging": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "5d18b48d-b886-409e-ab2e-336d9c94a55c",
|
"id": "5d18b48d-b886-409e-ab2e-336d9c94a55c",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user