Skip to content

Commit

Permalink
support for kamstrup heat meters (#20057)
Browse files Browse the repository at this point in the history
  • Loading branch information
gemu2015 authored Nov 20, 2023
1 parent f4ad758 commit 7d30ab5
Showing 1 changed file with 49 additions and 4 deletions.
53 changes: 49 additions & 4 deletions tasmota/tasmota_xsns_sensor/xsns_53_sml.ino
Original file line number Diff line number Diff line change
Expand Up @@ -1458,6 +1458,7 @@ void sml_shift_in(uint32_t meters, uint32_t shard) {
uint32_t timediff = millis() - mp->lastms;
if (timediff > mp->tout_ms) {
mp->spos = 0;
SML_Decode(meters);
AddLog(LOG_LEVEL_DEBUG, PSTR("SML: sync"));
}
mp->lastms = millis();
Expand Down Expand Up @@ -1902,7 +1903,7 @@ void SML_Decode(uint8_t index) {
}
if (sml_globs.mp[mindex].type == 'o' || sml_globs.mp[mindex].type == 'c') {
if (*mp++ != *cp++) {
found=0;
found = 0;
}
} else {
if (sml_globs.mp[mindex].type == 's') {
Expand Down Expand Up @@ -1962,7 +1963,9 @@ void SML_Decode(uint8_t index) {
}
#endif
}
}
} else {
found = 0;
}
break;
}
uint8_t iob;
Expand Down Expand Up @@ -2335,8 +2338,27 @@ void SML_Decode(uint8_t index) {
goto getstr;
}
dval = CharToDouble((char*)lcp);
} else if (*mp == 's') {
mp++;
char delim = *mp;
mp++;
uint8_t toskip = strtol((char*)mp,(char**)&mp, 10);
mp++;
char *lcp = (char*)cp;
if (toskip) {
char *bp = (char*)cp;
for (uint32_t cnt = 0; cnt < toskip; cnt++) {
bp = strchr(bp, delim);
if (!bp) {
break;
}
bp++;
lcp = bp;
}
}
dval = CharToDouble((char*)lcp);
} else {
dval = CharToDouble((char*)cp);
dval = CharToDouble((char*)cp);
}
} else {
dval = sml_getvalue(cp, mindex);
Expand Down Expand Up @@ -2537,6 +2559,16 @@ void SML_Show(boolean json) {
} else {
mid = 0;
}
} else if (*cp == 's') {
// skip values
if (sml_globs.mp[mindex].type == 'o') {
cp += 2;
strtol((char*)cp,(char**)&cp, 10);
cp++;
goto tststr;
} else {
mid = 0;
}
} else if (*cp == 'b') {
// bit value
#ifdef SML_BIT_TEXT
Expand Down Expand Up @@ -3725,6 +3757,19 @@ uint32_t sml_getv(uint32_t sel) {
return sel;
}

uint32_t SML_Shift_Num(uint32_t meter, uint32_t shift) {
struct METER_DESC *mp = &sml_globs.mp[meter];
if (shift > mp->sbsiz) shift = mp->sbsiz;
for (uint16_t cnt = 0; cnt < shift; cnt++) {
for (uint16_t count = 0; count < mp->sbsiz - 1; count++) {
mp->sbuff[count] = mp->sbuff[count + 1];
SML_Decode(meter);
}
}
return shift;
}


double SML_GetVal(uint32_t index) {
if (sml_globs.ready == false) return 0;
if (index < 1 || index > sml_globs.maxvars) { index = 1;}
Expand Down Expand Up @@ -3984,7 +4029,7 @@ void SML_Check_Send(void) {
sml_globs.sml_100ms_cnt++;
char *cp;
for (uint32_t cnt = sml_globs.sml_desc_cnt; cnt < sml_globs.meters_used; cnt++) {
if (meter_desc[cnt].trxpin >= 0 && meter_desc[cnt].txmem) {
if (meter_desc[cnt].trxpin >= 0 && (meter_desc[cnt].txmem || meter_desc[cnt].script_str)) {
//AddLog(LOG_LEVEL_INFO, PSTR("100 ms>> %d - %s - %d"),sml_globs.sml_desc_cnt,meter_desc[cnt].txmem,meter_desc[cnt].tsecs);
if ((sml_globs.sml_100ms_cnt >= meter_desc[cnt].tsecs)) {
sml_globs.sml_100ms_cnt = 0;
Expand Down

0 comments on commit 7d30ab5

Please sign in to comment.