fixed power calculation
This commit is contained in:
parent
5c5880ac62
commit
b9b6c19b15
@ -51,14 +51,14 @@ void IntegrationPluginGenericThings::setupThing(ThingSetupInfo *info)
|
|||||||
if (thing->thingClassId() == extendedSmartMeterConsumerThingClassId) {
|
if (thing->thingClassId() == extendedSmartMeterConsumerThingClassId) {
|
||||||
if (!m_smartMeterTimer) {
|
if (!m_smartMeterTimer) {
|
||||||
m_smartMeterTimer = hardwareManager()->pluginTimerManager()->registerTimer(10);
|
m_smartMeterTimer = hardwareManager()->pluginTimerManager()->registerTimer(10);
|
||||||
connect(m_smartMeterTimer, &PluginTimer::timeout, thing, [this, thing] {
|
|
||||||
|
|
||||||
int impulsePerKwh = thing->setting(extendedSmartMeterConsumerSettingsImpulsePerKwhParamTypeId).toInt();
|
|
||||||
double power = (m_pulsesPerTimeframe.value(thing)/impulsePerKwh)/(m_smartMeterTimer->interval()/3600.00); // Power = Energy/Time; Energy = Impulses/ImpPerkWh
|
|
||||||
thing->setStateValue(extendedSmartMeterConsumerCurrentPowerStateTypeId, power);
|
|
||||||
m_pulsesPerTimeframe.insert(thing, 0);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
connect(m_smartMeterTimer, &PluginTimer::timeout, thing, [this, thing] {
|
||||||
|
|
||||||
|
double impulsePerKwh = thing->setting(extendedSmartMeterConsumerSettingsImpulsePerKwhParamTypeId).toDouble();
|
||||||
|
double power = (m_pulsesPerTimeframe.value(thing)/impulsePerKwh)/(m_smartMeterTimer->interval()/3600.00); // Power = Energy/Time; Energy = Impulses/ImpPerkWh
|
||||||
|
thing->setStateValue(extendedSmartMeterConsumerCurrentPowerStateTypeId, power*1000);
|
||||||
|
m_pulsesPerTimeframe.insert(thing, 0);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
info->finish(Thing::ThingErrorNoError);
|
info->finish(Thing::ThingErrorNoError);
|
||||||
Thing *thing = info->thing();
|
Thing *thing = info->thing();
|
||||||
@ -491,6 +491,7 @@ void IntegrationPluginGenericThings::executeAction(ThingActionInfo *info)
|
|||||||
} else if (thing->thingClassId() == extendedSmartMeterConsumerThingClassId) {
|
} else if (thing->thingClassId() == extendedSmartMeterConsumerThingClassId) {
|
||||||
if (action.actionTypeId() == extendedSmartMeterConsumerS0InputActionTypeId) {
|
if (action.actionTypeId() == extendedSmartMeterConsumerS0InputActionTypeId) {
|
||||||
bool value = info->action().param(extendedSmartMeterConsumerS0InputActionS0InputParamTypeId).value().toBool();
|
bool value = info->action().param(extendedSmartMeterConsumerS0InputActionS0InputParamTypeId).value().toBool();
|
||||||
|
thing->setStateValue(extendedSmartMeterConsumerS0InputStateTypeId, value);
|
||||||
int impulsePerKwh = info->thing()->setting(extendedSmartMeterConsumerSettingsImpulsePerKwhParamTypeId).toInt();
|
int impulsePerKwh = info->thing()->setting(extendedSmartMeterConsumerSettingsImpulsePerKwhParamTypeId).toInt();
|
||||||
if (value) {
|
if (value) {
|
||||||
double currentEnergy = thing->stateValue(extendedSmartMeterConsumerTotalEnergyConsumedStateTypeId).toDouble();
|
double currentEnergy = thing->stateValue(extendedSmartMeterConsumerTotalEnergyConsumedStateTypeId).toDouble();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user