Skip to content

Commit

Permalink
0.8.1030014
Browse files Browse the repository at this point in the history
  • Loading branch information
tictrick committed May 12, 2024
1 parent 243bc06 commit 7b9b2bd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//-------------------------------------
#define VERSION_MAJOR 0
#define VERSION_MINOR 8
#define VERSION_PATCH 1030013
#define VERSION_PATCH 1030014
//-------------------------------------
typedef struct {
uint8_t ch;
Expand Down
19 changes: 13 additions & 6 deletions src/plugins/zeroExport/powermeter.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,22 @@ class powermeter {
if (millis() - mPreviousTsp <= 1000) return; // skip when it is to fast
mPreviousTsp = millis();

if (mCfg->debug) DBGPRINTLN(F("pm Takt:"));

bool result = false;
float power = 0.0;

for (u_short group = 0; group < ZEROEXPORT_MAX_GROUPS; group++) {
if ((!mCfg->groups[group].enabled) || (mCfg->groups[group].sleep)) continue;

if ((millis() - mCfg->groups[group].pm_peviousTsp) <= ((uint16_t)mCfg->groups[group].pm_refresh * 1000)) continue;
if ((millis() - mCfg->groups[group].pm_peviousTsp) < ((uint16_t)mCfg->groups[group].pm_refresh * 1000)) continue;
mCfg->groups[group].pm_peviousTsp = millis();

if (mCfg->debug) DBGPRINTLN(F("pm Do:"));

result = false;
power = 0.0;

switch (mCfg->groups[group].pm_type) {
#if defined(ZEROEXPORT_POWERMETER_SHELLY)
case zeroExportPowermeterType_t::Shelly:
Expand Down Expand Up @@ -107,19 +114,19 @@ class powermeter {
bufferWrite(power, group);

// MQTT - Powermeter
if (mCfg->debug) {
// if (mCfg->debug) {
if (mMqtt->isConnected()) {
// P
mqttObj["Sum"] = ah::round1(power);
// mqttObj["Sum"] = ah::round1(power);
// mqttObj["L1"] = ah::round1(power.P1);
// mqttObj["L2"] = ah::round1(power.P2);
// mqttObj["L3"] = ah::round1(power.P3);
mMqtt->publish(String("zero/state/groups/" + String(group) + "/powermeter/P").c_str(), mqttDoc.as<std::string>().c_str(), false);
mqttDoc.clear();
mMqtt->publish(String("zero/state/groups/" + String(group) + "/powermeter/P").c_str(), String(ah::round1(power)).c_str(), false);
// mqttDoc.clear();

// W (TODO)
}
}
// }
}
}
}
Expand Down

0 comments on commit 7b9b2bd

Please sign in to comment.