From 33a1934ef3808bf9831cba7d0a313151eed0bcfc Mon Sep 17 00:00:00 2001 From: loosrob <79396812+loosrob@users.noreply.github.com> Date: Sat, 12 Feb 2022 11:35:42 +0100 Subject: [PATCH] process power factor --- shelly/integrationpluginshelly.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/shelly/integrationpluginshelly.cpp b/shelly/integrationpluginshelly.cpp index b010da51..8a91fe14 100644 --- a/shelly/integrationpluginshelly.cpp +++ b/shelly/integrationpluginshelly.cpp @@ -1146,6 +1146,7 @@ void IntegrationPluginShelly::onPublishReceived(MqttChannel *channel, const QStr QVariant value = payload; QHash stateTypeIdMap; stateTypeIdMap["power"] = shellyEmChannelCurrentPowerStateTypeId; + stateTypeIdMap["pf"] = shellyEmChannelPowerFactorPhaseAStateTypeId; stateTypeIdMap["reactive_power"] = shellyEmChannelReactivePowerPhaseAStateTypeId; stateTypeIdMap["voltage"] = shellyEmChannelVoltagePhaseAStateTypeId; stateTypeIdMap["total"] = shellyEmChannelTotalEnergyConsumedStateTypeId; @@ -1182,14 +1183,14 @@ void IntegrationPluginShelly::onPublishReceived(MqttChannel *channel, const QStr } else { child->setStateValue(shellyEmChannelCurrentPhaseAStateTypeId, 0); } - double reactivePower = child->stateValue(shellyEmChannelReactivePowerPhaseAStateTypeId).toDouble(); + /*double reactivePower = child->stateValue(shellyEmChannelReactivePowerPhaseAStateTypeId).toDouble(); double root = qSqrt(power*power + reactivePower*reactivePower); if (qFuzzyCompare(root, 0) == false) { double calcPf = power/root; child->setStateValue(shellyEmChannelPowerFactorPhaseAStateTypeId, calcPf); } else { child->setStateValue(shellyEmChannelPowerFactorPhaseAStateTypeId, 0); - } + }*/ } }