Browse Source

Merge branch 'development03' of https://github.com/lumapu/ahoy into development03

pull/811/head
Markus Krause 2 years ago
parent
commit
5018009f4a
  1. 6
      src/CHANGES.md
  2. 2
      src/defines.h
  3. 2
      src/hm/hmInverter.h
  4. 4
      src/hm/hmPayload.h
  5. 26
      src/publisher/pubMqtt.h

6
src/CHANGES.md

@ -2,6 +2,12 @@
(starting from release version `0.5.66`) (starting from release version `0.5.66`)
## 0.5.108
* merge: PR SPI pins configureable (ESP32) #807, #806
* merge: PR MI serial outputs #809
* fix: no MQTT `total` sensor for autodiscover if only one inverter was found #805
* fix: MQTT `total` renamed to `device_name` + `_TOTOL` for better visibility #805
## 0.5.107 ## 0.5.107
* fix: show save message * fix: show save message
* fix: removed serial newline for `enqueueCmd` * fix: removed serial newline for `enqueueCmd`

2
src/defines.h

@ -13,7 +13,7 @@
//------------------------------------- //-------------------------------------
#define VERSION_MAJOR 0 #define VERSION_MAJOR 0
#define VERSION_MINOR 5 #define VERSION_MINOR 5
#define VERSION_PATCH 107 #define VERSION_PATCH 108
//------------------------------------- //-------------------------------------
typedef struct { typedef struct {

2
src/hm/hmInverter.h

@ -304,7 +304,7 @@ class Inverter {
if (getPosByChFld(0, FLD_ACT_ACTIVE_PWR_LIMIT, rec) == pos){ if (getPosByChFld(0, FLD_ACT_ACTIVE_PWR_LIMIT, rec) == pos){
actPowerLimit = rec->record[pos]; actPowerLimit = rec->record[pos];
DPRINT(DBG_DEBUG, F("Inverter actual power limit: ")); DPRINT(DBG_DEBUG, F("Inverter actual power limit: "));
DBGPRINTLN(String(actPowerLimit, 1)); DPRINTLN(DBG_DEBUG, String(actPowerLimit, 1));
} }
} }
else if (rec->assign == AlarmDataAssignment) { else if (rec->assign == AlarmDataAssignment) {

4
src/hm/hmPayload.h

@ -168,7 +168,7 @@ class HmPayload {
DPRINTLN(DBG_DEBUG, F("fragment number zero received and ignored")); DPRINTLN(DBG_DEBUG, F("fragment number zero received and ignored"));
} else { } else {
DPRINT(DBG_DEBUG, F("PID: 0x")); DPRINT(DBG_DEBUG, F("PID: 0x"));
DBGHEXLN(*pid); DPRINTLN(DBG_DEBUG, String(*pid, HEX));
if ((*pid & 0x7F) < MAX_PAYLOAD_ENTRIES) { if ((*pid & 0x7F) < MAX_PAYLOAD_ENTRIES) {
memcpy(mPayload[iv->id].data[(*pid & 0x7F) - 1], &p->packet[10], p->len - 11); memcpy(mPayload[iv->id].data[(*pid & 0x7F) - 1], &p->packet[10], p->len - 11);
mPayload[iv->id].len[(*pid & 0x7F) - 1] = p->len - 11; mPayload[iv->id].len[(*pid & 0x7F) - 1] = p->len - 11;
@ -285,7 +285,7 @@ class HmPayload {
DPRINT(DBG_INFO, F("procPyld: txid: 0x")); DPRINT(DBG_INFO, F("procPyld: txid: 0x"));
DBGHEXLN(mPayload[iv->id].txId); DBGHEXLN(mPayload[iv->id].txId);
DPRINT(DBG_DEBUG, F("procPyld: max: ")); DPRINT(DBG_DEBUG, F("procPyld: max: "));
DBGPRINTLN(String(mPayload[iv->id].maxPackId)); DPRINTLN(DBG_DEBUG, String(mPayload[iv->id].maxPackId));
record_t<> *rec = iv->getRecordStruct(mPayload[iv->id].txCmd); // choose the parser record_t<> *rec = iv->getRecordStruct(mPayload[iv->id].txCmd); // choose the parser
mPayload[iv->id].complete = true; mPayload[iv->id].complete = true;

26
src/publisher/pubMqtt.h

@ -38,6 +38,7 @@ typedef struct {
bool running; bool running;
uint8_t lastIvId; uint8_t lastIvId;
uint8_t sub; uint8_t sub;
uint8_t foundIvCnt;
} discovery_t; } discovery_t;
template<class HMSYSTEM> template<class HMSYSTEM>
@ -224,6 +225,7 @@ class PubMqtt {
mDiscovery.running = true; mDiscovery.running = true;
mDiscovery.lastIvId = 0; mDiscovery.lastIvId = 0;
mDiscovery.sub = 0; mDiscovery.sub = 0;
mDiscovery.foundIvCnt = 0;
} }
void setPowerLimitAck(Inverter<> *iv) { void setPowerLimitAck(Inverter<> *iv) {
@ -350,14 +352,16 @@ class PubMqtt {
uint8_t fldTotal[4] = {FLD_PAC, FLD_YT, FLD_YD, FLD_PDC}; uint8_t fldTotal[4] = {FLD_PAC, FLD_YT, FLD_YD, FLD_PDC};
const char* unitTotal[4] = {"W", "kWh", "Wh", "W"}; const char* unitTotal[4] = {"W", "kWh", "Wh", "W"};
String node_mac = WiFi.macAddress().substring(12,14)+ WiFi.macAddress().substring(15,17); String node_id = String(mDevName) + "_TOTAL";
String node_id = "AHOY_DTU_" + node_mac;
bool total = (mDiscovery.lastIvId == MAX_NUM_INVERTERS); bool total = (mDiscovery.lastIvId == MAX_NUM_INVERTERS);
Inverter<> *iv = mSys->getInverterByPos(mDiscovery.lastIvId); Inverter<> *iv = mSys->getInverterByPos(mDiscovery.lastIvId);
record_t<> *rec; record_t<> *rec;
if (NULL != iv) if (NULL != iv) {
rec = iv->getRecordStruct(RealTimeRunData_Debug); rec = iv->getRecordStruct(RealTimeRunData_Debug);
if(0 == mDiscovery.sub)
mDiscovery.foundIvCnt++;
}
if ((NULL != iv) || total) { if ((NULL != iv) || total) {
if (!total) { if (!total) {
@ -420,18 +424,26 @@ class PubMqtt {
if(++mDiscovery.sub == ((!total) ? (rec->length) : 4)) { if(++mDiscovery.sub == ((!total) ? (rec->length) : 4)) {
mDiscovery.sub = 0; mDiscovery.sub = 0;
if(++mDiscovery.lastIvId == (MAX_NUM_INVERTERS + 1)) checkDiscoveryEnd();
mDiscovery.running = false;
} }
} else { } else {
mDiscovery.sub = 0; mDiscovery.sub = 0;
if(++mDiscovery.lastIvId == (MAX_NUM_INVERTERS + 1)) checkDiscoveryEnd();
mDiscovery.running = false;
} }
yield(); yield();
} }
void checkDiscoveryEnd(void) {
if(++mDiscovery.lastIvId == MAX_NUM_INVERTERS) {
// check if only one inverter was found, then don't create 'total' sensor
DPRINTLN(DBG_INFO, "found: " + String(mDiscovery.foundIvCnt));
if(mDiscovery.foundIvCnt == 1)
mDiscovery.running = false;
} else if(mDiscovery.lastIvId == (MAX_NUM_INVERTERS + 1))
mDiscovery.running = false;
}
const char *getFieldDeviceClass(uint8_t fieldId) { const char *getFieldDeviceClass(uint8_t fieldId) {
uint8_t pos = 0; uint8_t pos = 0;
for (; pos < DEVICE_CLS_ASSIGN_LIST_LEN; pos++) { for (; pos < DEVICE_CLS_ASSIGN_LIST_LEN; pos++) {

Loading…
Cancel
Save