Skip to content

Commit

Permalink
Merge pull request #296 from MichaelDvP/v3.4
Browse files Browse the repository at this point in the history
fix #294
  • Loading branch information
proddy authored Jan 15, 2022
2 parents c2b63c3 + f599f3e commit 6e457c2
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
18 changes: 13 additions & 5 deletions src/emsdevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ static const __FlashStringHelper * const DeviceValueTAG_s[] PROGMEM = {
F_(tag_hc2), // "hc2"
F_(tag_hc3), // "hc3"
F_(tag_hc4), // "hc4"
F_(tag_hc5), // "hc5"
F_(tag_hc6), // "hc6"
F_(tag_hc7), // "hc7"
F_(tag_hc8), // "hc8"
F_(tag_wwc1), // "wwc1"
F_(tag_wwc2), // "Wwc2"
F_(tag_wwc3), // "wwc3"
Expand Down Expand Up @@ -78,6 +82,10 @@ static const __FlashStringHelper * const DeviceValueTAG_mqtt[] PROGMEM = {
F_(tag_hc2), // "hc2"
F_(tag_hc3), // "hc3"
F_(tag_hc4), // "hc4"
F_(tag_hc5), // "hc5"
F_(tag_hc6), // "hc6"
F_(tag_hc7), // "hc7"
F_(tag_hc8), // "hc8"
F_(tag_wwc1), // "wwc1"
F_(tag_wwc2), // "Wwc2"
F_(tag_wwc3), // "wwc3"
Expand Down Expand Up @@ -540,7 +548,7 @@ void EMSdevice::register_device_value(uint8_t tag,

uint8_t flags = CommandFlag::ADMIN_ONLY; // executing commands require admin privileges

if (tag >= DeviceValueTAG::TAG_HC1 && tag <= DeviceValueTAG::TAG_HC4) {
if (tag >= DeviceValueTAG::TAG_HC1 && tag <= DeviceValueTAG::TAG_HC8) {
flags |= CommandFlag::MQTT_SUB_FLAG_HC;
} else if (tag >= DeviceValueTAG::TAG_WWC1 && tag <= DeviceValueTAG::TAG_WWC4) {
flags |= CommandFlag::MQTT_SUB_FLAG_WWC;
Expand Down Expand Up @@ -582,7 +590,7 @@ void EMSdevice::publish_value(void * value_p) {
for (auto & dv : devicevalues_) {
if (dv.value_p == value_p) {
char topic[Mqtt::MQTT_TOPIC_MAX_SIZE];
if ((dv.tag >= DeviceValueTAG::TAG_HC1 && dv.tag <= DeviceValueTAG::TAG_HC4)
if ((dv.tag >= DeviceValueTAG::TAG_HC1 && dv.tag <= DeviceValueTAG::TAG_HC8)
|| (dv.tag >= DeviceValueTAG::TAG_WWC1 && dv.tag <= DeviceValueTAG::TAG_WWC4)) {
snprintf(topic,
sizeof(topic),
Expand Down Expand Up @@ -897,10 +905,10 @@ bool EMSdevice::get_value_info(JsonObject & output, const char * cmd, const int8
int8_t tag = id;

// check if we have hc or wwc
if (id >= 1 && id <= 4) {
if (id >= 1 && id <= 8) {
tag = DeviceValueTAG::TAG_HC1 + id - 1;
} else if (id >= 8 && id <= 11) {
tag = DeviceValueTAG::TAG_WWC1 + id - 8;
} else if (id >= 9 && id <= 12) {
tag = DeviceValueTAG::TAG_WWC1 + id - 9;
} else if (id != -1) {
return false; // error
}
Expand Down
4 changes: 4 additions & 0 deletions src/emsdevicevalue.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ class DeviceValue {
TAG_HC2,
TAG_HC3,
TAG_HC4,
TAG_HC5,
TAG_HC6,
TAG_HC7,
TAG_HC8,
TAG_WWC1,
TAG_WWC2,
TAG_WWC3,
Expand Down
6 changes: 3 additions & 3 deletions src/emsesp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ void EMSESP::publish_device_values(uint8_t device_type) {
Mqtt::publish(Mqtt::tag_to_topic(device_type, DeviceValueTAG::TAG_NONE), json);
}
doc.clear();

// thermostat only have hc1-4
for (uint8_t hc_tag = DeviceValueTAG::TAG_HC1; hc_tag <= DeviceValueTAG::TAG_HC4; hc_tag++) {
if (emsdevice->generate_values(json, hc_tag, false, EMSdevice::OUTPUT_TARGET::MQTT)) { // not nested
Mqtt::publish(Mqtt::tag_to_topic(device_type, hc_tag), json);
Expand Down Expand Up @@ -1183,9 +1183,9 @@ bool EMSESP::command_commands(uint8_t device_type, JsonObject & output, const in
bool EMSESP::command_info(uint8_t device_type, JsonObject & output, const int8_t id, const uint8_t output_target) {
bool has_value = false;
uint8_t tag;
if (id >= 1 && id <= 4) {
if (id >= 1 && id <= 8) {
tag = DeviceValueTAG::TAG_HC1 + id - 1;
} else if (id >= 9 && id <= 10) {
} else if (id >= 9 && id <= 12) {
tag = DeviceValueTAG::TAG_WWC1 + id - 9;
} else if (id == -1 || id == 0) {
tag = DeviceValueTAG::TAG_NONE;
Expand Down
4 changes: 4 additions & 0 deletions src/locale_EN.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,10 @@ MAKE_PSTR(tag_hc1, "hc1")
MAKE_PSTR(tag_hc2, "hc2")
MAKE_PSTR(tag_hc3, "hc3")
MAKE_PSTR(tag_hc4, "hc4")
MAKE_PSTR(tag_hc5, "hc5")
MAKE_PSTR(tag_hc6, "hc6")
MAKE_PSTR(tag_hc7, "hc7")
MAKE_PSTR(tag_hc8, "hc8")
MAKE_PSTR(tag_wwc1, "wwc1")
MAKE_PSTR(tag_wwc2, "wwc2")
MAKE_PSTR(tag_wwc3, "wwc3")
Expand Down

0 comments on commit 6e457c2

Please sign in to comment.