Browse Source

Merge pull request #4 from DanielR92/zero-export

smal fixes, remove comment what clear is
pull/1551/head
tictrick 10 months ago
committed by GitHub
parent
commit
b57a0807af
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 15
      src/plugins/zeroExport/powermeter.h
  2. 42
      src/plugins/zeroExport/zeroExport.h

15
src/plugins/zeroExport/powermeter.h

@ -391,6 +391,7 @@ class powermeter {
* @param group * @param group
* @returns true/false * @returns true/false
* @TODO: Username & Passwort wird mittels base64 verschlüsselt. Dies wird für die Authentizierung benötigt. Wichtig diese im WebUI unkenntlich zu machen und base64 im eeprom zu speichern, statt klartext. * @TODO: Username & Passwort wird mittels base64 verschlüsselt. Dies wird für die Authentizierung benötigt. Wichtig diese im WebUI unkenntlich zu machen und base64 im eeprom zu speichern, statt klartext.
* @TODO: Abfrage Interval einbauen. Info: Datei-Size kann auch mal 0-bytes sein!
*/ */
sml_states_t currentState; sml_states_t currentState;
@ -448,7 +449,7 @@ class powermeter {
http.begin(url); http.begin(url);
http.addHeader("Authorization", "Basic " + auth); http.addHeader("Authorization", "Basic " + auth);
if (http.GET() == HTTP_CODE_OK) { if (http.GET() == HTTP_CODE_OK && http.getSize() != 0) {
String myString = http.getString(); String myString = http.getString();
char floatBuffer[20]; char floatBuffer[20];
@ -474,9 +475,7 @@ class powermeter {
mCfg->groups[group].pmPowerL3 = _powerMeterTotal / 3; mCfg->groups[group].pmPowerL3 = _powerMeterTotal / 3;
} }
// TODO: Ein return an dieser Stelle verhindert das ordnungsgemäße http.end()
result = true; result = true;
// return true;
break; break;
case SML_LISTEND: case SML_LISTEND:
// check handlers on last received list // check handlers on last received list
@ -487,9 +486,19 @@ class powermeter {
} }
} }
break; break;
default:
logObj["SML_DEFAULT"] = String(smlCurrentState);
break;
} }
} }
} }
else
{
logObj["result"] = String(result);
logObj["http_size"] = String(http.getSize());
}
http.end(); http.end();
logObj["P"] = mCfg->groups[group].pmPower; logObj["P"] = mCfg->groups[group].pmPower;

42
src/plugins/zeroExport/zeroExport.h

@ -68,48 +68,50 @@ class ZeroExport {
continue; continue;
} }
bool flag = false;
switch (mCfg->groups[group].state) { switch (mCfg->groups[group].state) {
case zeroExportState::INIT: case zeroExportState::INIT:
if (groupInit(group)) sendLog(); flag = groupInit(group);
break; break;
case zeroExportState::WAIT: case zeroExportState::WAIT:
if (groupWait(group)) sendLog(); flag = groupWait(group);
break; break;
case zeroExportState::PUBLISH: case zeroExportState::PUBLISH:
if (groupPublish(group)) sendLog(); flag = groupPublish(group);
break; break;
case zeroExportState::WAITREFRESH: case zeroExportState::WAITREFRESH:
if (groupWaitRefresh(group)) sendLog(); flag = groupWaitRefresh(group);
break; break;
case zeroExportState::GETINVERTERACKS: case zeroExportState::GETINVERTERACKS:
if (groupGetInverterAcks(group)) sendLog(); flag = groupGetInverterAcks(group);
break; break;
case zeroExportState::GETINVERTERDATA: case zeroExportState::GETINVERTERDATA:
if (groupGetInverterData(group)) sendLog(); flag = groupGetInverterData(group);
break; break;
case zeroExportState::BATTERYPROTECTION: case zeroExportState::BATTERYPROTECTION:
if (groupBatteryprotection(group)) sendLog(); flag = groupBatteryprotection(group);
break; break;
case zeroExportState::GETPOWERMETER: case zeroExportState::GETPOWERMETER:
if (groupGetPowermeter(group)) sendLog(); flag = groupGetPowermeter(group);
break; break;
case zeroExportState::CONTROLLER: case zeroExportState::CONTROLLER:
if (groupController(group)) sendLog(); flag = groupController(group);
break; break;
case zeroExportState::PROGNOSE: case zeroExportState::PROGNOSE:
if (groupPrognose(group)) sendLog(); flag = groupPrognose(group);
break; break;
case zeroExportState::AUFTEILEN: case zeroExportState::AUFTEILEN:
if (groupAufteilen(group)) sendLog(); flag = groupAufteilen(group);
break; break;
case zeroExportState::SETLIMIT: case zeroExportState::SETLIMIT:
if (groupSetLimit(group)) sendLog(); flag = groupSetLimit(group);
break; break;
case zeroExportState::SETPOWER: case zeroExportState::SETPOWER:
if (groupSetPower(group)) sendLog(); flag = groupSetPower(group);
break; break;
case zeroExportState::SETREBOOT: case zeroExportState::SETREBOOT:
if (groupSetReboot(group)) sendLog(); flag = groupSetReboot(group);
break; break;
case zeroExportState::FINISH: case zeroExportState::FINISH:
case zeroExportState::ERROR: case zeroExportState::ERROR:
@ -121,6 +123,8 @@ class ZeroExport {
} }
break; break;
} }
if (flag) sendLog();
} }
} }
@ -292,13 +296,19 @@ class ZeroExport {
} }
/** onMqttMessage /** onMqttMessage
* * Subscribe section
*/ */
void onMqttMessage(JsonObject obj) { void onMqttMessage(JsonObject obj) {
if ((!mIsInitialized) || (!mCfg->enabled)) { if ((!mIsInitialized) || (!mCfg->enabled)) {
return; return;
} }
// MQTT":{"val":0,"path":"zero","cmd":"set","id":0}
if (strcmp(obj["cmd"], "set") != 0 && strcmp(obj["path"], "zero") != 0)
{
mCfg->enabled = (bool)obj["val"];
}
mLog["MQTT"] = obj; mLog["MQTT"] = obj;
sendLog(); sendLog();
} }
@ -460,7 +470,7 @@ class ZeroExport {
// mCfg->groups[group].publishPower = false; // mCfg->groups[group].publishPower = false;
obj["L1"] = mCfg->groups[group].pmPowerL1; obj["L1"] = mCfg->groups[group].pmPowerL1;
obj["L2"] = mCfg->groups[group].pmPowerL2; obj["L2"] = mCfg->groups[group].pmPowerL2;
obj["L2"] = mCfg->groups[group].pmPowerL3; obj["L3"] = mCfg->groups[group].pmPowerL3;
obj["Sum"] = mCfg->groups[group].pmPower; obj["Sum"] = mCfg->groups[group].pmPower;
mMqtt->publish("zero/state/powermeter/P", doc.as<std::string>().c_str(), false); mMqtt->publish("zero/state/powermeter/P", doc.as<std::string>().c_str(), false);
doc.clear(); doc.clear();

Loading…
Cancel
Save