From 6dba095c261e41e8958bb26456d806f567758222 Mon Sep 17 00:00:00 2001 From: IgorYbema Date: Thu, 16 Jan 2025 14:19:28 +0100 Subject: [PATCH] optdata GUI fix and import rules fix --- HeishaMon/decode.cpp | 4 ++-- HeishaMon/src/rules/rules.cpp | 6 +++--- HeishaMon/webfunctions.cpp | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/HeishaMon/decode.cpp b/HeishaMon/decode.cpp index 11d8c56c..56384638 100644 --- a/HeishaMon/decode.cpp +++ b/HeishaMon/decode.cpp @@ -412,9 +412,9 @@ void decode_optional_heatpump_data(char* data, char* actOptData, PubSubClient & int maxvalue = atoi(opttopicDescription[Topic_Number][0]); String dataValue = getOptDataValue(actOptData, Topic_Number); if (maxvalue == 0) { //this takes the special case where the description is a real value description instead of a mode, so get description index 1 - sprintf_P(log_msg, PSTR("{\"data\": {\"heishavalues\": {\"topic\": \"OPTTOP%u\", \"value\": %s, \"description\": \"%s\"}}}"), Topic_Number, dataValue.c_str(),opttopicDescription[Topic_Number][1]); + sprintf_P(log_msg, PSTR("{\"data\": {\"heishavalues\": {\"topic\": \"OPT%u\", \"value\": %s, \"description\": \"%s\"}}}"), Topic_Number, dataValue.c_str(),opttopicDescription[Topic_Number][1]); } else { - sprintf_P(log_msg, PSTR("{\"data\": {\"heishavalues\": {\"topic\": \"OPTTOP%u\", \"value\": %s, \"description\": \"%s\"}}}"), Topic_Number, dataValue.c_str(),opttopicDescription[Topic_Number][dataValue.toInt() + 1]); + sprintf_P(log_msg, PSTR("{\"data\": {\"heishavalues\": {\"topic\": \"OPT%u\", \"value\": %s, \"description\": \"%s\"}}}"), Topic_Number, dataValue.c_str(),opttopicDescription[Topic_Number][dataValue.toInt() + 1]); } rules_event_cb(_F("@"), optTopics[Topic_Number]); } diff --git a/HeishaMon/src/rules/rules.cpp b/HeishaMon/src/rules/rules.cpp index 57a990a1..245eac83 100644 --- a/HeishaMon/src/rules/rules.cpp +++ b/HeishaMon/src/rules/rules.cpp @@ -296,7 +296,7 @@ static int8_t lexer_parse_number(char *text, uint16_t len, uint16_t *pos) { * The dot cannot be the first character * and we cannot have more than 1 dot */ - while(*pos <= len && + while(*pos < len && ( isdigit(current) || (i == 0 && current == '-') || @@ -320,7 +320,7 @@ static int8_t lexer_parse_number(char *text, uint16_t len, uint16_t *pos) { static uint16_t lexer_parse_string(char *text, uint16_t len, uint16_t *pos) { char current = getval(text[*pos]); - while(*pos <= len && + while(*pos < len && (current != ' ' && current != ',' && current != ';' && @@ -363,7 +363,7 @@ static int8_t lexer_parse_quoted_string(char *text, uint16_t len, uint16_t *pos) static int8_t lexer_parse_skip_characters(char *text, uint16_t len, uint16_t *pos) { char current = getval(text[*pos]); - while(*pos <= len && + while(*pos < len && (current == ' ' || current == '\n' || current == '\t' || diff --git a/HeishaMon/webfunctions.cpp b/HeishaMon/webfunctions.cpp index 318c55b4..917d4451 100644 --- a/HeishaMon/webfunctions.cpp +++ b/HeishaMon/webfunctions.cpp @@ -1253,7 +1253,7 @@ int handleJsonOutput(struct webserver_t *client, char* actData, char* actDataExt webserver_send_content_P(client, PSTR("\",\"Description\":\""), 17); int maxvalue = atoi(opttopicDescription[topic][0]); - int value = actOptData[0] == '\0' ? 0 : getOptDataValue(actDataExtra, topic).toInt(); + int value = actOptData[0] == '\0' ? 0 : getOptDataValue(actOptData, topic).toInt(); if (maxvalue == 0) { //this takes the special case where the description is a real value description instead of a mode, so value should take first index (= 0 + 1) value = 0; }