GenericCar: Add max charging current for generic car

This commit is contained in:
Simon Stürz 2025-12-22 10:54:23 +01:00
parent 265cfb5339
commit b8b81ac2bb
3 changed files with 28 additions and 23 deletions

View File

@ -25,25 +25,22 @@
#include "integrationplugingenericcar.h"
#include "plugininfo.h"
#include <QDebug>
#include <QtMath>
IntegrationPluginGenericCar::IntegrationPluginGenericCar()
{
}
IntegrationPluginGenericCar::IntegrationPluginGenericCar() {}
void IntegrationPluginGenericCar::setupThing(ThingSetupInfo *info)
{
Thing *thing = info->thing();
// Set the min charging current state if the settings value changed
connect(thing, &Thing::settingChanged, this, [thing](const ParamTypeId &paramTypeId, const QVariant &value){
connect(thing, &Thing::settingChanged, this, [thing](const ParamTypeId &paramTypeId, const QVariant &value) {
if (paramTypeId == carSettingsCapacityParamTypeId) {
thing->setStateValue(carCapacityStateTypeId, value);
} else if (paramTypeId == carSettingsMinChargingCurrentParamTypeId) {
qCDebug(dcGenericCar()) << "Car minimum charging current settings changed" << value.toUInt() << "A";
thing->setStateValue(carMinChargingCurrentStateTypeId, value);
} else if (paramTypeId == carSettingsMaxChargingCurrentParamTypeId) {
qCDebug(dcGenericCar()) << "Car maximum charging current settings changed" << value.toUInt() << "A";
thing->setStateValue(carMaxChargingCurrentStateTypeId, value);
} else if (paramTypeId == carSettingsPhaseCountParamTypeId) {
thing->setStateValue(carPhaseCountStateTypeId, value);
}

View File

@ -25,13 +25,11 @@
#ifndef INTEGRATIONPLUGINGENERICCAR_H
#define INTEGRATIONPLUGINGENERICCAR_H
#include "integrations/integrationplugin.h"
#include "plugintimer.h"
#include <integrations/integrationplugin.h>
#include "extern-plugininfo.h"
#include <QTimer>
class IntegrationPluginGenericCar: public IntegrationPlugin
class IntegrationPluginGenericCar : public IntegrationPlugin
{
Q_OBJECT
@ -42,11 +40,6 @@ public:
explicit IntegrationPluginGenericCar();
void setupThing(ThingSetupInfo *info) override;
void executeAction(ThingActionInfo *info) override;
private:
QHash<Thing *, int> m_pulsesPerTimeframe;
QHash<Thing *, QTimer *> m_smartMeterTimer;
};
#endif // INTEGRATIONPLUGINGENERICCAR_H

View File

@ -25,6 +25,16 @@
"maxValue": 16,
"defaultValue": 6
},
{
"id": "69ae5ffa-b31b-4295-a2a8-61bd7b2fc5da",
"name": "maxChargingCurrent",
"displayName": "Maximal charging current",
"type": "uint",
"unit": "Ampere",
"minValue": 16,
"maxValue": 80,
"defaultValue": 80
},
{
"id": "57f36386-dd71-4ab0-8d2f-8c74a391f90d",
"name": "capacity",
@ -60,7 +70,6 @@
"id": "363a2a39-61b6-4109-9cd9-aca7367d12c7",
"name": "capacity",
"displayName": "Capacity",
"displayNameEvent": "Capacity changed",
"type": "double",
"unit": "KiloWattHour",
"defaultValue": 50
@ -69,7 +78,6 @@
"id": "d33982d6-6467-4281-b448-68c1b1db088d",
"name": "batteryCritical",
"displayName": "Battery level critical",
"displayNameEvent": "Battery entered or left critical state",
"type": "bool",
"defaultValue": false
},
@ -77,7 +85,6 @@
"id": "3f1cca10-8988-4ec6-b937-0775653cde12",
"name": "batteryLevel",
"displayName": "Battery level",
"displayNameEvent": "Battery level changed",
"displayNameAction": "Set battery level",
"type": "int",
"unit": "Percentage",
@ -90,18 +97,26 @@
"id": "20faf2b8-2b40-4bee-b228-97dbaf0cdffc",
"name": "minChargingCurrent",
"displayName": "Minimum charging current",
"displayNameEvent": "Minimum charging current changed",
"type": "uint",
"unit": "Ampere",
"minValue": 6,
"maxValue": 16,
"defaultValue": 6
},
{
"id": "ad17e812-ba07-47a8-99a4-eefb8b54fc85",
"name": "maxChargingCurrent",
"displayName": "Maximum charging current",
"type": "uint",
"unit": "Ampere",
"minValue": 16,
"maxValue": 80,
"defaultValue": 80
},
{
"id": "c886c062-bf1a-46c5-8e54-aed804a22d57",
"name": "phaseCount",
"displayName": "Phase count",
"displayNameEvent": "Phase count changed",
"type": "uint",
"minValue": 1,
"maxValue": 3,