From e84bf9a1811f8151a7dd0d0a809d546bde7c839b Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Sat, 4 May 2024 12:41:04 +0200 Subject: [PATCH 1/4] add rego3000 holiday, dev9, update pkg --- CHANGELOG_LATEST.md | 1 + interface/package.json | 4 ++-- interface/yarn.lock | 22 ++++++++++---------- src/devices/thermostat.cpp | 42 ++++++++++++++++++++++++++++++++------ src/devices/thermostat.h | 3 ++- src/version.h | 2 +- 6 files changed, 53 insertions(+), 21 deletions(-) diff --git a/CHANGELOG_LATEST.md b/CHANGELOG_LATEST.md index 3e03cf0e0..61728483e 100644 --- a/CHANGELOG_LATEST.md +++ b/CHANGELOG_LATEST.md @@ -17,6 +17,7 @@ - heatpump entities `fan` and `shutdown` [#1690](https://github.com/emsesp/EMS-ESP32/discussions/1690) - mqtt HA-mode 3 for v3.6 compatible HA entities, set on update v3.6->v3.7 - HP input states [#1723](https://github.com/emsesp/EMS-ESP32/discussions/1723) +- holiday settings for rego 3000 [#1735](https://github.com/emsesp/EMS-ESP32/issues/1735) ## Fixed diff --git a/interface/package.json b/interface/package.json index 2d83f3420..9ff23469e 100644 --- a/interface/package.json +++ b/interface/package.json @@ -50,12 +50,12 @@ "typescript": "^5.4.5" }, "devDependencies": { - "@eslint/js": "^9.1.1", + "@eslint/js": "^9.2.0", "@preact/compat": "^17.1.2", "@preact/preset-vite": "^2.8.2", "@trivago/prettier-plugin-sort-imports": "^4.3.0", "concurrently": "^8.2.2", - "eslint": "^9.1.1", + "eslint": "^9.2.0", "eslint-config-prettier": "^9.1.0", "preact": "^10.21.0", "prettier": "^3.2.5", diff --git a/interface/yarn.lock b/interface/yarn.lock index 407dcaf0b..0303cd652 100644 --- a/interface/yarn.lock +++ b/interface/yarn.lock @@ -705,10 +705,10 @@ __metadata: languageName: node linkType: hard -"@eslint/js@npm:9.1.1, @eslint/js@npm:^9.1.1": - version: 9.1.1 - resolution: "@eslint/js@npm:9.1.1" - checksum: 10c0/b25d11736b91d8df44dd217e88adb1f43d2bd5911ef4f4033e51faffe370f28d329731ffbf841d0b8303c8eedb60bda8c3a9efe803bb3b3737a06bb22c09ad0c +"@eslint/js@npm:9.2.0, @eslint/js@npm:^9.2.0": + version: 9.2.0 + resolution: "@eslint/js@npm:9.2.0" + checksum: 10c0/89632466d329d9dd68c6ec24290e407f0950ca8c4b7f3750b82457daa7f6233799ccbc956cd84231f9544efbefddd69833ee82658883ca673cfca9e4b8e0713a languageName: node linkType: hard @@ -1707,7 +1707,7 @@ __metadata: "@alova/scene-react": "npm:^1.5.0" "@emotion/react": "npm:^11.11.4" "@emotion/styled": "npm:^11.11.5" - "@eslint/js": "npm:^9.1.1" + "@eslint/js": "npm:^9.2.0" "@mui/icons-material": "npm:^5.15.16" "@mui/material": "npm:^5.15.16" "@preact/compat": "npm:^17.1.2" @@ -1722,7 +1722,7 @@ __metadata: alova: "npm:^2.20.3" async-validator: "npm:^4.2.5" concurrently: "npm:^8.2.2" - eslint: "npm:^9.1.1" + eslint: "npm:^9.2.0" eslint-config-prettier: "npm:^9.1.0" history: "npm:^5.3.0" jwt-decode: "npm:^4.0.0" @@ -3209,14 +3209,14 @@ __metadata: languageName: node linkType: hard -"eslint@npm:^9.1.1": - version: 9.1.1 - resolution: "eslint@npm:9.1.1" +"eslint@npm:^9.2.0": + version: 9.2.0 + resolution: "eslint@npm:9.2.0" dependencies: "@eslint-community/eslint-utils": "npm:^4.2.0" "@eslint-community/regexpp": "npm:^4.6.1" "@eslint/eslintrc": "npm:^3.0.2" - "@eslint/js": "npm:9.1.1" + "@eslint/js": "npm:9.2.0" "@humanwhocodes/config-array": "npm:^0.13.0" "@humanwhocodes/module-importer": "npm:^1.0.1" "@humanwhocodes/retry": "npm:^0.2.3" @@ -3249,7 +3249,7 @@ __metadata: text-table: "npm:^0.2.0" bin: eslint: bin/eslint.js - checksum: 10c0/0173fbc561d2272802315726283f63df0cf7197949ca1f80afd8ef92e95867677d54601ff6cad5467c44745160ba0f9cef7ac1154ccbd097d0269a4c6eb21041 + checksum: 10c0/eab3265100a359a486e40e1d9d4d3ecff936d2f4d952f4ab107d404e0684fffbe186ecd0fb41791af5bcb13570a27032ddf9a2e628927ed33473f64255b0037b languageName: node linkType: hard diff --git a/src/devices/thermostat.cpp b/src/devices/thermostat.cpp index 61177d3fe..befac9bd5 100644 --- a/src/devices/thermostat.cpp +++ b/src/devices/thermostat.cpp @@ -174,6 +174,7 @@ Thermostat::Thermostat(uint8_t device_type, uint8_t device_id, uint8_t product_i register_telegram_type(0x240, "RC300Settings", true, MAKE_PF_CB(process_RC300Settings)); register_telegram_type(0xBB, "HybridSettings", true, MAKE_PF_CB(process_HybridSettings)); register_telegram_type(0x23E, "PVSettings", true, MAKE_PF_CB(process_PVSettings)); + register_telegram_type(0x269, "RC300Holiday1", true, MAKE_PF_CB(process_RC300Holiday)); // JUNKERS/HT3 } else if (model == EMSdevice::EMS_DEVICE_FLAG_JUNKERS) { @@ -1289,6 +1290,25 @@ void Thermostat::process_RC300Floordry(std::shared_ptr telegram) has_update(telegram, floordrytemp_, 1); } +// 0x269 - 0x26D RC300 EMS+ holidaymodes 1 to 5 +// special case R3000 only date in 0x269 +void Thermostat::process_RC300Holiday(std::shared_ptr telegram) { + if (telegram->offset || telegram->message_length < 6) { + return; + } + char data[sizeof(vacation[0]) + 4]; + snprintf(data, + sizeof(data), + "%02d.%02d.%04d-%02d.%02d.%04d", + telegram->message_data[2], + telegram->message_data[1], + telegram->message_data[0] + 2000, + telegram->message_data[5], + telegram->message_data[4], + telegram->message_data[3] + 2000); + has_update(vacation[0], data, sizeof(vacation[0])); +} + // 0x291 ff. HP mode // thermostat(0x10) -W-> Me(0x0B), HPMode(0x0291), data: 01 00 00 03 FF 00 void Thermostat::process_HPMode(std::shared_ptr telegram) { @@ -2433,14 +2453,9 @@ bool Thermostat::set_holiday(const char * value, const int8_t id, const bool vac data[4] = (value[14] - '0') * 10 + (value[15] - '0'); data[5] = (value[18] - '0') * 100 + (value[19] - '0') * 10 + (value[20] - '0'); - if (data[0] > 31 || data[1] > 12 || data[3] > 31 || data[4] > 12) { + if (!data[0] || data[0] > 31 || !data[1] || data[1] > 12 || !data[3] || data[3] > 31 || !data[4] || data[4] > 12) { return false; } - if (model() == EMSdevice::EMS_DEVICE_FLAG_RC30) { - write_command(0xA9 + hc->hc(), 1, data, 6, 0x9A + hc->hc()); - return true; - } - if (!vacation || value[10] == '+') { // + for compatibility if (hc) { write_command(timer_typeids[hc->hc()], 93, data, 6, timer_typeids[hc->hc()]); @@ -2462,6 +2477,7 @@ bool Thermostat::set_holiday(const char * value, const int8_t id, const bool vac } // set vacations as string dd.mm.yyyy-dd.mm.yyyy +// RC30 and rego 3000 bool Thermostat::set_RC30Vacation(const char * value, const int8_t id) { if (strlen(value) != 21) { return false; @@ -2478,6 +2494,11 @@ bool Thermostat::set_RC30Vacation(const char * value, const int8_t id) { if (!data[0] || data[0] > 31 || !data[1] || data[1] > 12 || !data[3] || data[3] > 31 || !data[4] || data[4] > 12) { return false; } + if (model() == EMSdevice::EMS_DEVICE_FLAG_R3000) { + write_command(0x269, 0, data, 6, 0x269); + return true; + } + // RC30 write_command(0xA9, 1 + 7 * (id - 1), data, 6, 0x9A); return true; } @@ -3908,6 +3929,15 @@ void Thermostat::register_device_values() { DeviceValueUOM::DEGREES, MAKE_CF_CB(set_minexttemp)); register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, &ibaDamping_, DeviceValueType::BOOL, FL_(damping), DeviceValueUOM::NONE, MAKE_CF_CB(set_damping)); + if (model() == EMSdevice::EMS_DEVICE_FLAG_R3000) { + register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, + &vacation[0], + DeviceValueType::STRING, + FL_(tpl_holidays), + FL_(holiday), + DeviceValueUOM::NONE, + MAKE_CF_CB(set_RC30Vacation)); + } register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, &hybridStrategy_, DeviceValueType::ENUM, diff --git a/src/devices/thermostat.h b/src/devices/thermostat.h index 56ce51cde..757d59a3b 100644 --- a/src/devices/thermostat.h +++ b/src/devices/thermostat.h @@ -271,7 +271,7 @@ class Thermostat : public EMSdevice { uint8_t humidity_; uint8_t battery_; - char vacation[8][22]; // RC30 only, only one hc + char vacation[8][22]; // RC30, R3000 only, only one hc // HybridHP uint8_t hybridStrategy_; // co2 = 1, cost = 2, temperature = 3, mix = 4 @@ -431,6 +431,7 @@ class Thermostat : public EMSdevice { void process_RC300OutdoorTemp(std::shared_ptr telegram); void process_RC300Settings(std::shared_ptr telegram); void process_RC300Floordry(std::shared_ptr telegram); + void process_RC300Holiday(std::shared_ptr telegram); void process_RC300Curve(std::shared_ptr telegram); void process_JunkersMonitor(std::shared_ptr telegram); void process_JunkersSet(std::shared_ptr telegram); diff --git a/src/version.h b/src/version.h index ad1f990b9..25521abd3 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1 @@ -#define EMSESP_APP_VERSION "3.7.0-dev.8" +#define EMSESP_APP_VERSION "3.7.0-dev.9" From 9a2d635c62407b4caf2018f74effceded870de92 Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Sat, 4 May 2024 13:32:04 +0200 Subject: [PATCH 2/4] fix date format --- src/devices/thermostat.cpp | 27 +++++++++++++++++++++++++-- src/devices/thermostat.h | 1 + 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/devices/thermostat.cpp b/src/devices/thermostat.cpp index befac9bd5..46613654b 100644 --- a/src/devices/thermostat.cpp +++ b/src/devices/thermostat.cpp @@ -2503,6 +2503,29 @@ bool Thermostat::set_RC30Vacation(const char * value, const int8_t id) { return true; } +// set R3000 holiday as string dd.mm.yyyy-dd.mm.yyyy +// RC30 and rego 3000 +bool Thermostat::set_R3000Holiday(const char * value, const int8_t id) { + if (strlen(value) != 21) { + return false; + } + + uint8_t data[6]; + data[2] = (value[0] - '0') * 10 + (value[1] - '0'); + data[1] = (value[3] - '0') * 10 + (value[4] - '0'); + data[0] = (value[7] - '0') * 100 + (value[8] - '0') * 10 + (value[9] - '0'); + data[5] = (value[11] - '0') * 10 + (value[12] - '0'); + data[4] = (value[14] - '0') * 10 + (value[15] - '0'); + data[3] = (value[18] - '0') * 100 + (value[19] - '0') * 10 + (value[20] - '0'); + + if (!data[2] || data[2] > 31 || !data[1] || data[1] > 12 || !data[5] || data[5] > 31 || !data[4] || data[4] > 12) { + return false; + } + write_command(0x269, 0, data, 6, 0x269); + return true; +} + + // set pause in hours bool Thermostat::set_pause(const char * value, const int8_t id) { auto hc = heating_circuit(id); @@ -3934,9 +3957,9 @@ void Thermostat::register_device_values() { &vacation[0], DeviceValueType::STRING, FL_(tpl_holidays), - FL_(holiday), + FL_(vacations), DeviceValueUOM::NONE, - MAKE_CF_CB(set_RC30Vacation)); + MAKE_CF_CB(set_R3000Holiday)); } register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, &hybridStrategy_, diff --git a/src/devices/thermostat.h b/src/devices/thermostat.h index 757d59a3b..74e5cba14 100644 --- a/src/devices/thermostat.h +++ b/src/devices/thermostat.h @@ -580,6 +580,7 @@ class Thermostat : public EMSdevice { bool set_wwDailyHeating(const char * value, const int8_t id); bool set_wwDailyHeatTime(const char * value, const int8_t id); bool set_wwwhenmodeoff(const char * value, const int8_t id); + bool set_R3000Holiday(const char * value, const int8_t id); inline bool set_wwVacation(const char * value, const int8_t id) { return set_holiday(value, DeviceValueTAG::TAG_DHW1, true); } From 2bd14e5648b69897ed164fcdf9add135624960a3 Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Sat, 4 May 2024 19:39:24 +0200 Subject: [PATCH 3/4] v3.7.0-dev.10 --- src/version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/version.h b/src/version.h index 25521abd3..6f78f3e82 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1 @@ -#define EMSESP_APP_VERSION "3.7.0-dev.9" +#define EMSESP_APP_VERSION "3.7.0-dev.10" From f44bd81fd90b83075c25c38635432fbc33cbfca6 Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Sun, 5 May 2024 09:15:54 +0200 Subject: [PATCH 4/4] fix command with command as value, #1740 --- src/command.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/command.cpp b/src/command.cpp index a03818fec..50b81e9b9 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -173,10 +173,9 @@ uint8_t Command::process(const char * path, const bool is_admin, const JsonObjec if (!output.containsKey("api_data")) { return CommandRet::INVALID; } - String dat = output["api_data"]; + String dat = output["api_data"].as(); output.clear(); - input["data"] = dat.c_str(); - data = input["data"]; + return Command::call(device_type, command_p, dat.c_str(), is_admin, id_n, output); } } }