Add energy counter for meter and use display name instead of name for meter

master
Simon Stürz 2022-08-18 09:47:06 +02:00
parent 4a1fe66041
commit 88657c791c
1 changed files with 4 additions and 3 deletions

View File

@ -236,7 +236,7 @@ void IntegrationPluginKostal::postSetupThing(Thing *thing)
qCDebug(dcKostal()) << "There is a meter connected but not set up yet. Creating a meter...";
// No meter thing created for this inverter, lets create one with the inverter as parent
ThingClass meterThingClass = thingClass(kostalMeterThingClassId);
ThingDescriptor descriptor(kostalMeterThingClassId, meterThingClass.name(), QString(), thing->id());
ThingDescriptor descriptor(kostalMeterThingClassId, meterThingClass.displayName(), QString(), thing->id());
// No params required, all we need is the connection
emit autoThingsAppeared(ThingDescriptors() << descriptor);
} else {
@ -428,8 +428,6 @@ void IntegrationPluginKostal::setupKostalConnection(ThingSetupInfo *info)
if (meterThings.count() == 1) {
Thing *meterThing = meterThings.first();
// TODO: set total energy consumed/produced
// Power
meterThing->setStateValue(kostalMeterCurrentPhaseAStateTypeId, kostalConnection->powerMeterCurrentPhase1());
meterThing->setStateValue(kostalMeterCurrentPhaseBStateTypeId, kostalConnection->powerMeterCurrentPhase2());
@ -447,6 +445,9 @@ void IntegrationPluginKostal::setupKostalConnection(ThingSetupInfo *info)
meterThing->setStateValue(kostalMeterFrequencyStateTypeId, kostalConnection->gridFrequencyPowerMeter());
// TODO: Not sure where to get the exported energy
meterThing->setStateValue(kostalMeterTotalEnergyConsumedStateTypeId, kostalConnection->totalHomeConsumptionFromGrid() / 1000.0); // kWh
// Set the power as last value
meterThing->setStateValue(kostalMeterCurrentPowerStateTypeId, kostalConnection->powerMeterTotalActivePower());
}