Skip to content

Commit c4b0a19

Browse files
committed
v3.35
1 parent 14d183d commit c4b0a19

File tree

6 files changed

+321
-335
lines changed

6 files changed

+321
-335
lines changed

NEWTAGS.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,6 @@ ADD_NEW_TOPIC=TAG_SGR_HW_PROVIDER:TAG_SGR_INDEX:_:1:0:sg_ready/3/provider/index
184184
ADD_NEW_TOPIC=TAG_SGR_HW_PROVIDER:TAG_SGR_NAME:_:1:0:sg_ready/3/provider/name
185185
ADD_NEW_TOPIC=TAG_SGR_HW_PROVIDER:TAG_SGR_INDEX:_:1:0:sg_ready/4/provider/index
186186
ADD_NEW_TOPIC=TAG_SGR_HW_PROVIDER:TAG_SGR_NAME:_:1:0:sg_ready/4/provider/name
187-
ADD_NEW_REQUEST=0:TAG_SGR_REQ_READY_TO_USE-0
188-
ADD_NEW_TOPIC=0:TAG_SGR_READY_TO_USE:W:1:0:sg_ready/ready_to_use
189187
ADD_NEW_REQUEST=0:TAG_SGR_REQ_COOLDOWN_END-0
190188
ADD_NEW_TOPIC=0:TAG_SGR_COOLDOWN_END:_:1:0:sg_ready/cooldown_end
191189
ADD_NEW_REQUEST=0:TAG_SGR_REQ_USED_POWER-0

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ or to show the help page
160160
If everything works properly, you will see something like this:
161161

162162
```
163-
rscp2mqtt [3.34]
163+
rscp2mqtt [3.35]
164164
E3DC system >192.168.178.111:5033< user: >your E3DC user<
165165
MQTT broker >localhost:1883< qos = >0< retain = >✗< tls >✗< client id >✗< prefix >e3dc<
166166
Requesting PVI ✓ | PM (0) | DCB ✓ (1 battery string) | Wallbox ✗ | Interval 2 | Autorefresh ✓ | Raw data ✗ | Logging OFF

RELEASE.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
## Release Notes
22

3+
### Release v3.35 (14.03.2025)
4+
5+
Bug fixes:
6+
- Issue #102: Topic e3dc/ems/emergency_power_available is missing
7+
38
### Release v3.34 (01.03.2025)
49

510
Features:

RscpMqttMain.cpp

Lines changed: 18 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include <regex>
2323
#include <mutex>
2424

25-
#define RSCP2MQTT_VERSION "3.34"
25+
#define RSCP2MQTT_VERSION "3.35"
2626

2727
#define AES_KEY_SIZE 32
2828
#define AES_BLOCK_SIZE 32
@@ -354,7 +354,7 @@ void addTemplTopicsIdx(int index, char *seg, int start, int n, int inc, bool fin
354354
for (int c = start; c < n; c++) {
355355
for (std::vector<RSCP_MQTT::cache_t>::iterator it = RSCP_MQTT::RscpMqttCacheTempl.begin(); it != RSCP_MQTT::RscpMqttCacheTempl.end(); ++it) {
356356
if (it->index == index) {
357-
RSCP_MQTT::cache_t cache = { it->container, it->tag, index + c, "", "", it->format, "", it->divisor, it->bit_to_bool, it->history_log, it->changed, it->influx, it->forced };
357+
RSCP_MQTT::cache_t cache = { it->container, it->tag, index + c, "", "", it->format, "", it->divisor, it->bit_to_bool, it->history_log, it->handled, it->changed, it->influx, it->forced };
358358
if (n == 1) {
359359
snprintf(cache.topic, TOPIC_SIZE, it->topic, seg);
360360
} else if (seg == NULL) {
@@ -380,7 +380,7 @@ void addTemplTopics(uint32_t container, int index, char *seg, int start, int n,
380380
for (int c = start; c < n; c++) {
381381
for (std::vector<RSCP_MQTT::cache_t>::iterator it = RSCP_MQTT::RscpMqttCacheTempl.begin(); it != RSCP_MQTT::RscpMqttCacheTempl.end(); ++it) {
382382
if (it->container == container) {
383-
RSCP_MQTT::cache_t cache = { it->container, it->tag, c, "", "", it->format, "", it->divisor, it->bit_to_bool, it->history_log, it->changed, it->influx, it->forced };
383+
RSCP_MQTT::cache_t cache = { it->container, it->tag, c, "", "", it->format, "", it->divisor, it->bit_to_bool, it->history_log, it->handled, it->changed, it->influx, it->forced };
384384
if (it->index > 1) cache.index = it->index + c * 10;
385385
if ((seg == NULL) && (index == 0)) { // no args
386386
cache.index = it->index;
@@ -407,7 +407,7 @@ void addTemplTopics(uint32_t container, int index, char *seg, int start, int n,
407407
}
408408

409409
void addTopic(uint32_t container, uint32_t tag, char *topic, char *unit, int format, int divisor, int bit_to_bool, bool finalize) {
410-
RSCP_MQTT::cache_t cache = { container, tag, 0, "", "", format, "", divisor, bit_to_bool, false, false, false, false };
410+
RSCP_MQTT::cache_t cache = { container, tag, 0, "", "", format, "", divisor, bit_to_bool, false, false, false, false, false };
411411
strcpy(cache.topic, topic);
412412
strcpy(cache.unit, unit);
413413
RSCP_MQTT::RscpMqttCache.push_back(cache);
@@ -692,35 +692,6 @@ void logTopics(std::vector<RSCP_MQTT::cache_t> & v, char *file, bool check_paylo
692692
return;
693693
}
694694

695-
bool checkTopicOrder(std::vector<RSCP_MQTT::cache_t> & v) {
696-
uint32_t container = 0;
697-
uint32_t tag = 0;
698-
int index = 0;
699-
bool sorted = true;
700-
for (std::vector<RSCP_MQTT::cache_t>::iterator it = v.begin(); it != v.end(); ++it) {
701-
if ((it->container < container) && (it->tag < tag) && (it->index < index)) {
702-
sorted = false;
703-
break;
704-
}
705-
container = it->container;
706-
tag = it->tag;
707-
index = it->index;
708-
}
709-
return(sorted);
710-
}
711-
712-
bool checkTopicUniqueness(std::vector<RSCP_MQTT::cache_t> & v) {
713-
int j;
714-
for (std::vector<RSCP_MQTT::cache_t>::iterator i = v.begin(); i != v.end(); ++i) {
715-
j = 0;
716-
for (std::vector<RSCP_MQTT::cache_t>::iterator it = v.begin(); it != v.end(); ++it) {
717-
if ((i->container == it->container) && (i->tag == it->tag) && (i->index == it->index) && (i->bit_to_bool == it->bit_to_bool)) j++;
718-
}
719-
if (j > 1) return(false);
720-
}
721-
return(true);
722-
}
723-
724695
void logHealth(char *file) {
725696
logMessage(file, (char *)__FILE__, __LINE__, (char *)"[%s] PVI %s | PM %s | DCB %s (%d) | Wallbox %s | Autorefresh %s | Raw data %s | Interval %d\n", RSCP2MQTT, cfg.pvi_requests?"":"", cfg.pm_requests?"":"", cfg.dcb_requests?"":"", cfg.battery_strings, cfg.wallbox?"":"", cfg.auto_refresh?"":"", cfg.raw_mode?"":"", cfg.interval);
726697
for (uint8_t i = 0; i < cfg.pm_number; i++) {
@@ -733,8 +704,6 @@ void logHealth(char *file) {
733704
for (std::vector<RSCP_MQTT::additional_tags_t>::iterator it = RSCP_MQTT::AdditionalTags.begin(); it != RSCP_MQTT::AdditionalTags.end(); ++it) {
734705
logMessage(file, (char *)__FILE__, __LINE__, (char *)"Container >%s< Tag >%s< added (one shot: %s).\n", tagName(RSCP_TAGS::RscpTagsOverview, it->req_container), tagName(RSCP_TAGS::RscpTagsOverview, it->req_tag), it->one_shot?"true":"false");
735706
}
736-
logMessage(file, (char *)__FILE__, __LINE__, (char *)"Topics sorted >%s<\n", checkTopicOrder(RSCP_MQTT::RscpMqttCache)?"true":"false");
737-
logMessage(file, (char *)__FILE__, __LINE__, (char *)"Topics unique >%s<\n", checkTopicUniqueness(RSCP_MQTT::RscpMqttCache)?"true":"false");
738707
for (std::vector<RSCP_MQTT::not_supported_tags_t>::iterator it = RSCP_MQTT::NotSupportedTags.begin(); it != RSCP_MQTT::NotSupportedTags.end(); ++it) {
739708
logMessage(file, (char *)__FILE__, __LINE__, (char *)"Container >%s< Tag >%s< not supported.\n", tagName(RSCP_TAGS::RscpTagsOverview, it->container), tagName(RSCP_TAGS::RscpTagsOverview, it->tag));
740709
}
@@ -782,7 +751,7 @@ void logMessage(char *file, char *srcfile, int line, char *format, ...) {
782751
void copyCache(std::vector<RSCP_MQTT::cache_t> & to, std::vector<RSCP_MQTT::cache_t> & from, uint32_t container) {
783752
for (std::vector<RSCP_MQTT::cache_t>::iterator it = from.begin(); it != from.end(); ++it) {
784753
if (it->container == container) {
785-
RSCP_MQTT::cache_t cache = { it->container, it->tag, it->index, "", "", it->format, "", it->divisor, it->bit_to_bool, it->history_log, it->changed, it->influx, it->forced };
754+
RSCP_MQTT::cache_t cache = { it->container, it->tag, it->index, "", "", it->format, "", it->divisor, it->bit_to_bool, it->history_log, it->handled, it->changed, it->influx, it->forced };
786755
strcpy(cache.topic, it->topic);
787756
strcpy(cache.payload, it->payload);
788757
strcpy(cache.unit, it->unit);
@@ -1151,7 +1120,13 @@ int storeResponseValue(std::vector<RSCP_MQTT::cache_t> & c, RscpProtocol *protoc
11511120
static int battery_soc = -1;
11521121
int rc = -1;
11531122

1123+
// Issue #102
1124+
uint32_t old_container = 0;
1125+
uint32_t old_tag = 0;
1126+
int old_index = -1;
1127+
11541128
for (std::vector<RSCP_MQTT::cache_t>::iterator it = c.begin(); it != c.end(); ++it) {
1129+
if ((it->container > container) || ((old_container == it->container) && (old_tag == it->tag) && (old_index == it->index) && (it->bit_to_bool == 0))) break;
11551130
if ((!it->container || (it->container == container)) && (it->tag == response->tag) && (it->index == index) && !it->handled) {
11561131
switch (response->dataType) {
11571132
case RSCP::eTypeBool: {
@@ -1296,7 +1271,9 @@ int storeResponseValue(std::vector<RSCP_MQTT::cache_t> & c, RscpProtocol *protoc
12961271
else battery_soc = atoi(it->payload);
12971272
}
12981273
it->handled = true;
1299-
break;
1274+
old_container = it->container;
1275+
old_tag = it->tag;
1276+
old_index = it->index;
13001277
}
13011278
}
13021279
return(rc);
@@ -2365,7 +2342,6 @@ int handleResponseValue(RscpProtocol *protocol, SRscpValue *response) {
23652342
uint32_t uiErrorCode = protocol->getValueAsUInt32(&containerData[i]);
23662343
if (uiErrorCode == 6) {
23672344
pushNotSupportedTag(response->tag, containerData[i].tag);
2368-
logMessageByTag(response->tag, containerData[i].tag, uiErrorCode, __LINE__, (char *)"Not supported by the device: Container >%s< Tag >%s< received >%s< [%d]\n");
23692345
} else logMessageByTag(response->tag, containerData[i].tag, uiErrorCode, __LINE__, (char *)"Error: Container >%s< Tag >%s< received >%s< [%d]\n");
23702346
} else {
23712347
switch (containerData[i].tag) {
@@ -3117,6 +3093,8 @@ int main(int argc, char *argv[]) {
31173093
cfg.historyfile = strdup(value);
31183094
} else if (strcasecmp(key, "INTERVAL") == 0)
31193095
cfg.interval = atoi(value);
3096+
else if ((strcasecmp(key, "VERBOSE") == 0) && (strcasecmp(value, "true") == 0))
3097+
cfg.verbose = true;
31203098
else if ((strcasecmp(key, "PVI_REQUESTS") == 0) && (strcasecmp(value, "false") == 0))
31213099
cfg.pvi_requests = false;
31223100
else if (strcasecmp(key, "PVI_TRACKER") == 0)
@@ -3276,6 +3254,8 @@ int main(int argc, char *argv[]) {
32763254
if (env && (strcasecmp(env, "true") == 0)) cfg.raw_mode = true;
32773255
env = getenv("WALLBOX");
32783256
if (env && (strcasecmp(env, "true") == 0)) cfg.wallbox = true;
3257+
env = getenv("VERBOSE");
3258+
if (env && (strcasecmp(env, "true") == 0)) cfg.verbose = true;
32793259
env = getenv("PVI_TRACKER");
32803260
if (env) cfg.pvi_tracker = atoi(env);
32813261
env = getenv("BATTERY_STRINGS");

0 commit comments

Comments
 (0)