Fix max settings if no cable connected and improve discovery result texts

This commit is contained in:
Simon Stürz 2021-12-03 12:50:48 +01:00
parent ee30d86f94
commit 7c4a21c006
2 changed files with 11 additions and 7 deletions

View File

@ -60,7 +60,7 @@ void IntegrationPluginGoECharger::discoverThings(ThingDiscoveryInfo *info)
qCDebug(dcGoECharger()) << "Checking discovered" << networkDeviceInfo; qCDebug(dcGoECharger()) << "Checking discovered" << networkDeviceInfo;
// Filter by hostname // Filter by hostname
if (!networkDeviceInfo.hostName().contains("go-eCharger")) if (!networkDeviceInfo.hostName().toLower().contains("go-echarger"))
continue; continue;
// We need also the mac address // We need also the mac address
@ -71,14 +71,14 @@ void IntegrationPluginGoECharger::discoverThings(ThingDiscoveryInfo *info)
if (networkDeviceInfo.hostName().isEmpty()) { if (networkDeviceInfo.hostName().isEmpty()) {
title = networkDeviceInfo.address().toString(); title = networkDeviceInfo.address().toString();
} else { } else {
title = "go-eCharger (" + networkDeviceInfo.address().toString() + ")"; title = "go-eCharger";
} }
QString description; QString description;
if (networkDeviceInfo.macAddressManufacturer().isEmpty()) { if (networkDeviceInfo.macAddressManufacturer().isEmpty()) {
description = networkDeviceInfo.macAddress(); description = networkDeviceInfo.address().toString();
} else { } else {
description = networkDeviceInfo.macAddress() + " (" + networkDeviceInfo.macAddressManufacturer() + ")"; description = networkDeviceInfo.address().toString() + " (" + networkDeviceInfo.macAddressManufacturer() + ")";
} }
ThingDescriptor descriptor(goeHomeThingClassId, title, description); ThingDescriptor descriptor(goeHomeThingClassId, title, description);
@ -368,7 +368,11 @@ void IntegrationPluginGoECharger::update(Thing *thing, const QVariantMap &status
thing->setStateValue(goeHomeCableType2AmpereStateTypeId, cableLimit); thing->setStateValue(goeHomeCableType2AmpereStateTypeId, cableLimit);
// Set the limit for the max charging amps // Set the limit for the max charging amps
thing->setStateMaxValue(goeHomeMaxChargingCurrentStateTypeId, qMin(amaLimit, cableLimit)); if (cableLimit != 0) {
thing->setStateMaxValue(goeHomeMaxChargingCurrentStateTypeId, qMin(amaLimit, cableLimit));
} else {
thing->setStateMaxValue(goeHomeMaxChargingCurrentStateTypeId, amaLimit);
}
// Parse nrg array // Parse nrg array
uint voltagePhaseA = 0; uint voltagePhaseB = 0; uint voltagePhaseC = 0; uint voltagePhaseA = 0; uint voltagePhaseB = 0; uint voltagePhaseC = 0;

View File

@ -122,8 +122,8 @@
"type": "uint", "type": "uint",
"unit": "Ampere", "unit": "Ampere",
"minValue": 6, "minValue": 6,
"maxValue": 20, "maxValue": 32,
"defaultValue": 0.00, "defaultValue": 0,
"writable": true "writable": true
}, },
{ {