process power factor

This commit is contained in:
loosrob 2022-02-12 11:35:42 +01:00 committed by GitHub
parent 8ce779b258
commit 33a1934ef3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1146,6 +1146,7 @@ void IntegrationPluginShelly::onPublishReceived(MqttChannel *channel, const QStr
QVariant value = payload; QVariant value = payload;
QHash<QString, StateTypeId> stateTypeIdMap; QHash<QString, StateTypeId> stateTypeIdMap;
stateTypeIdMap["power"] = shellyEmChannelCurrentPowerStateTypeId; stateTypeIdMap["power"] = shellyEmChannelCurrentPowerStateTypeId;
stateTypeIdMap["pf"] = shellyEmChannelPowerFactorPhaseAStateTypeId;
stateTypeIdMap["reactive_power"] = shellyEmChannelReactivePowerPhaseAStateTypeId; stateTypeIdMap["reactive_power"] = shellyEmChannelReactivePowerPhaseAStateTypeId;
stateTypeIdMap["voltage"] = shellyEmChannelVoltagePhaseAStateTypeId; stateTypeIdMap["voltage"] = shellyEmChannelVoltagePhaseAStateTypeId;
stateTypeIdMap["total"] = shellyEmChannelTotalEnergyConsumedStateTypeId; stateTypeIdMap["total"] = shellyEmChannelTotalEnergyConsumedStateTypeId;
@ -1182,14 +1183,14 @@ void IntegrationPluginShelly::onPublishReceived(MqttChannel *channel, const QStr
} else { } else {
child->setStateValue(shellyEmChannelCurrentPhaseAStateTypeId, 0); child->setStateValue(shellyEmChannelCurrentPhaseAStateTypeId, 0);
} }
double reactivePower = child->stateValue(shellyEmChannelReactivePowerPhaseAStateTypeId).toDouble(); /*double reactivePower = child->stateValue(shellyEmChannelReactivePowerPhaseAStateTypeId).toDouble();
double root = qSqrt(power*power + reactivePower*reactivePower); double root = qSqrt(power*power + reactivePower*reactivePower);
if (qFuzzyCompare(root, 0) == false) { if (qFuzzyCompare(root, 0) == false) {
double calcPf = power/root; double calcPf = power/root;
child->setStateValue(shellyEmChannelPowerFactorPhaseAStateTypeId, calcPf); child->setStateValue(shellyEmChannelPowerFactorPhaseAStateTypeId, calcPf);
} else { } else {
child->setStateValue(shellyEmChannelPowerFactorPhaseAStateTypeId, 0); child->setStateValue(shellyEmChannelPowerFactorPhaseAStateTypeId, 0);
} }*/
} }
} }