From 181b672c1a22c02765f92bb5830e300c73ea0854 Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Sun, 4 Jun 2023 15:32:43 +0200 Subject: [PATCH] add ventilation bypass --- interface/package.json | 2 +- interface/yarn.lock | 100 +++++++++++++-------------- lib/espMqttClient/src/MqttClient.cpp | 6 +- src/devices/ventilation.cpp | 18 ++++- src/devices/ventilation.h | 4 +- src/emsesp.cpp | 1 + 6 files changed, 76 insertions(+), 55 deletions(-) diff --git a/interface/package.json b/interface/package.json index 0898b2c16..067bb18f1 100644 --- a/interface/package.json +++ b/interface/package.json @@ -47,7 +47,7 @@ "devDependencies": { "@typescript-eslint/eslint-plugin": "^5.59.8", "@typescript-eslint/parser": "^5.59.8", - "@vitejs/plugin-react-swc": "^3.3.1", + "@vitejs/plugin-react-swc": "^3.3.2", "eslint": "^8.42.0", "eslint-config-airbnb": "^19.0.4", "eslint-config-airbnb-typescript": "^17.0.0", diff --git a/interface/yarn.lock b/interface/yarn.lock index 2ecb333b0..835d157aa 100644 --- a/interface/yarn.lock +++ b/interface/yarn.lock @@ -1101,90 +1101,90 @@ __metadata: languageName: node linkType: hard -"@swc/core-darwin-arm64@npm:1.3.56": - version: 1.3.56 - resolution: "@swc/core-darwin-arm64@npm:1.3.56" +"@swc/core-darwin-arm64@npm:1.3.62": + version: 1.3.62 + resolution: "@swc/core-darwin-arm64@npm:1.3.62" conditions: os=darwin & cpu=arm64 languageName: node linkType: hard -"@swc/core-darwin-x64@npm:1.3.56": - version: 1.3.56 - resolution: "@swc/core-darwin-x64@npm:1.3.56" +"@swc/core-darwin-x64@npm:1.3.62": + version: 1.3.62 + resolution: "@swc/core-darwin-x64@npm:1.3.62" conditions: os=darwin & cpu=x64 languageName: node linkType: hard -"@swc/core-linux-arm-gnueabihf@npm:1.3.56": - version: 1.3.56 - resolution: "@swc/core-linux-arm-gnueabihf@npm:1.3.56" +"@swc/core-linux-arm-gnueabihf@npm:1.3.62": + version: 1.3.62 + resolution: "@swc/core-linux-arm-gnueabihf@npm:1.3.62" conditions: os=linux & cpu=arm languageName: node linkType: hard -"@swc/core-linux-arm64-gnu@npm:1.3.56": - version: 1.3.56 - resolution: "@swc/core-linux-arm64-gnu@npm:1.3.56" +"@swc/core-linux-arm64-gnu@npm:1.3.62": + version: 1.3.62 + resolution: "@swc/core-linux-arm64-gnu@npm:1.3.62" conditions: os=linux & cpu=arm64 & libc=glibc languageName: node linkType: hard -"@swc/core-linux-arm64-musl@npm:1.3.56": - version: 1.3.56 - resolution: "@swc/core-linux-arm64-musl@npm:1.3.56" +"@swc/core-linux-arm64-musl@npm:1.3.62": + version: 1.3.62 + resolution: "@swc/core-linux-arm64-musl@npm:1.3.62" conditions: os=linux & cpu=arm64 & libc=musl languageName: node linkType: hard -"@swc/core-linux-x64-gnu@npm:1.3.56": - version: 1.3.56 - resolution: "@swc/core-linux-x64-gnu@npm:1.3.56" +"@swc/core-linux-x64-gnu@npm:1.3.62": + version: 1.3.62 + resolution: "@swc/core-linux-x64-gnu@npm:1.3.62" conditions: os=linux & cpu=x64 & libc=glibc languageName: node linkType: hard -"@swc/core-linux-x64-musl@npm:1.3.56": - version: 1.3.56 - resolution: "@swc/core-linux-x64-musl@npm:1.3.56" +"@swc/core-linux-x64-musl@npm:1.3.62": + version: 1.3.62 + resolution: "@swc/core-linux-x64-musl@npm:1.3.62" conditions: os=linux & cpu=x64 & libc=musl languageName: node linkType: hard -"@swc/core-win32-arm64-msvc@npm:1.3.56": - version: 1.3.56 - resolution: "@swc/core-win32-arm64-msvc@npm:1.3.56" +"@swc/core-win32-arm64-msvc@npm:1.3.62": + version: 1.3.62 + resolution: "@swc/core-win32-arm64-msvc@npm:1.3.62" conditions: os=win32 & cpu=arm64 languageName: node linkType: hard -"@swc/core-win32-ia32-msvc@npm:1.3.56": - version: 1.3.56 - resolution: "@swc/core-win32-ia32-msvc@npm:1.3.56" +"@swc/core-win32-ia32-msvc@npm:1.3.62": + version: 1.3.62 + resolution: "@swc/core-win32-ia32-msvc@npm:1.3.62" conditions: os=win32 & cpu=ia32 languageName: node linkType: hard -"@swc/core-win32-x64-msvc@npm:1.3.56": - version: 1.3.56 - resolution: "@swc/core-win32-x64-msvc@npm:1.3.56" +"@swc/core-win32-x64-msvc@npm:1.3.62": + version: 1.3.62 + resolution: "@swc/core-win32-x64-msvc@npm:1.3.62" conditions: os=win32 & cpu=x64 languageName: node linkType: hard -"@swc/core@npm:^1.3.56": - version: 1.3.56 - resolution: "@swc/core@npm:1.3.56" +"@swc/core@npm:^1.3.61": + version: 1.3.62 + resolution: "@swc/core@npm:1.3.62" dependencies: - "@swc/core-darwin-arm64": 1.3.56 - "@swc/core-darwin-x64": 1.3.56 - "@swc/core-linux-arm-gnueabihf": 1.3.56 - "@swc/core-linux-arm64-gnu": 1.3.56 - "@swc/core-linux-arm64-musl": 1.3.56 - "@swc/core-linux-x64-gnu": 1.3.56 - "@swc/core-linux-x64-musl": 1.3.56 - "@swc/core-win32-arm64-msvc": 1.3.56 - "@swc/core-win32-ia32-msvc": 1.3.56 - "@swc/core-win32-x64-msvc": 1.3.56 + "@swc/core-darwin-arm64": 1.3.62 + "@swc/core-darwin-x64": 1.3.62 + "@swc/core-linux-arm-gnueabihf": 1.3.62 + "@swc/core-linux-arm64-gnu": 1.3.62 + "@swc/core-linux-arm64-musl": 1.3.62 + "@swc/core-linux-x64-gnu": 1.3.62 + "@swc/core-linux-x64-musl": 1.3.62 + "@swc/core-win32-arm64-msvc": 1.3.62 + "@swc/core-win32-ia32-msvc": 1.3.62 + "@swc/core-win32-x64-msvc": 1.3.62 peerDependencies: "@swc/helpers": ^0.5.0 dependenciesMeta: @@ -1211,7 +1211,7 @@ __metadata: peerDependenciesMeta: "@swc/helpers": optional: true - checksum: c468e281f0249742bc0ba4b7cd4076cdbf87bfc82b8bd5ad1ca8940d36372ca22754df80ab54b22613121680718eab26b92c48c8c9f5f3abb24434f05e5e1ea0 + checksum: aaa0827960f656c762733836938d31b2d596495b8430eb6feb0d1f6b1416b3444e7b59c326ae37ee410d8d3d25fff20ac8ff0f66ebe8a87e7fae1ca651aff915 languageName: node linkType: hard @@ -1507,14 +1507,14 @@ __metadata: languageName: node linkType: hard -"@vitejs/plugin-react-swc@npm:^3.3.1": - version: 3.3.1 - resolution: "@vitejs/plugin-react-swc@npm:3.3.1" +"@vitejs/plugin-react-swc@npm:^3.3.2": + version: 3.3.2 + resolution: "@vitejs/plugin-react-swc@npm:3.3.2" dependencies: - "@swc/core": ^1.3.56 + "@swc/core": ^1.3.61 peerDependencies: vite: ^4 - checksum: 72ab0a72d41c949009a2f71836894fb0003939329a2d1bb59b1181b03d21fda5002ccd20b40b48ddc8f12511cc8717122141f49ac51e97263df3c3f3142ae937 + checksum: 8544023de3dc605d00f66db10de085b2a90887111657db87dd192e02ffc1e4a191b09d58180b4ba498858f01e8861d15e216d744e0f6dfad2550065999890fb2 languageName: node linkType: hard @@ -1534,7 +1534,7 @@ __metadata: "@types/react-router-dom": ^5.3.3 "@typescript-eslint/eslint-plugin": ^5.59.8 "@typescript-eslint/parser": ^5.59.8 - "@vitejs/plugin-react-swc": ^3.3.1 + "@vitejs/plugin-react-swc": ^3.3.2 async-validator: ^4.2.5 axios: ^1.4.0 eslint: ^8.42.0 diff --git a/lib/espMqttClient/src/MqttClient.cpp b/lib/espMqttClient/src/MqttClient.cpp index 314a3c385..c371c9f93 100644 --- a/lib/espMqttClient/src/MqttClient.cpp +++ b/lib/espMqttClient/src/MqttClient.cpp @@ -577,7 +577,7 @@ void MqttClient::_onPubrec() { while (it) { // PUBRECs come in the order PUBs are sent. So we only check the first PUB packet in outbox // if it doesn't match the ID, return - if ((it.get()->packet.packetType()) == PacketType.PUBLISH) { + if ((it.get()->packet.packetType()) == PacketType.PUBLISH || (it.get()->packet.packetType()) == PacketType.PUBREL) { if (it.get()->packet.packetId() == idToMatch) { if (!_addPacket(PacketType.PUBREL, idToMatch)) { emc_log_e("Could not create PUBREL packet"); @@ -707,7 +707,9 @@ uint16_t MqttClient::getQueue() const { espMqttClientInternals::Outbox::Iterator it = _outbox.front(); uint16_t count = 0; while (it) { - ++count; + if (it.get()->packet.packetType() == PacketType.PUBLISH) { + ++count; + } ++it; } EMC_SEMAPHORE_GIVE(); diff --git a/src/devices/ventilation.cpp b/src/devices/ventilation.cpp index 18d2d1579..f68059200 100644 --- a/src/devices/ventilation.cpp +++ b/src/devices/ventilation.cpp @@ -29,6 +29,7 @@ Ventilation::Ventilation(uint8_t device_type, uint8_t device_id, uint8_t product register_telegram_type(0x585, "Blowerspeed", false, MAKE_PF_CB(process_BlowerMessage)); register_telegram_type(0x583, "VentilationMonitor", false, MAKE_PF_CB(process_MonitorMessage)); register_telegram_type(0x5D9, "Airquality", false, MAKE_PF_CB(process_VOCMessage)); + register_telegram_type(0x587, "Bypass", false, MAKE_PF_CB(process_BypassMessage)); // register_telegram_type(0x5, "VentilationSet", true, MAKE_PF_CB(process_SetMessage)); register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, @@ -44,7 +45,8 @@ Ventilation::Ventilation(uint8_t device_type, uint8_t device_id, uint8_t product register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, &ventOutSpeed_, DeviceValueType::UINT, FL_(ventOutSpeed), DeviceValueUOM::PERCENT); register_device_value( DeviceValueTAG::TAG_DEVICE_DATA, &mode_, DeviceValueType::ENUM, FL_(enum_ventMode), FL_(ventInSpeed), DeviceValueUOM::NONE, MAKE_CF_CB(set_ventMode)); - register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, &voc_, DeviceValueType::USHORT, DeviceValueNumOp::DV_NUMOP_DIV10, FL_(airquality), DeviceValueUOM::NONE); + register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, &voc_, DeviceValueType::USHORT, FL_(airquality), DeviceValueUOM::NONE); + register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, &bypass_, DeviceValueType::BOOL, FL_(bypass), DeviceValueUOM::NONE, MAKE_CF_CB(set_bypass)); } // message @@ -81,6 +83,11 @@ void Ventilation::process_ModeMessage(std::shared_ptr telegram) has_enumupdate(telegram, mode_, 0, -1); } +// message 0x0587, data: 01 00 +void Ventilation::process_BypassMessage(std::shared_ptr telegram) { + has_update(telegram, bypass_, 1); +} + bool Ventilation::set_ventMode(const char * value, const int8_t id) { uint8_t v; if (!Helpers::value2enum(value, v, FL_(enum_ventMode))) { @@ -99,4 +106,13 @@ bool Ventilation::set_filter(const char * value, const int8_t id) { return true; } +bool Ventilation::set_bypass(const char * value, const int8_t id) { + bool b; + if (!Helpers::value2bool(value, b)) { + return false; + } + write_command(0x55C, 1, b ? 1 : 0, 0x587); + return true; +} + } // namespace emsesp diff --git a/src/devices/ventilation.h b/src/devices/ventilation.h index a48285374..88b24d7ff 100644 --- a/src/devices/ventilation.h +++ b/src/devices/ventilation.h @@ -34,7 +34,7 @@ class Ventilation : public EMSdevice { int16_t inEx_; int16_t outEx_; uint16_t voc_; - // uint8_t bypass_; + uint8_t bypass_; // uint16_t filterRemain_; uint8_t ventInSpeed_; uint8_t ventOutSpeed_; @@ -45,8 +45,10 @@ class Ventilation : public EMSdevice { void process_ModeMessage(std::shared_ptr telegram); // 0x56B void process_BlowerMessage(std::shared_ptr telegram); // 0x56B void process_VOCMessage(std::shared_ptr telegram); // 0x56B + void process_BypassMessage(std::shared_ptr telegram); // 0x56B bool set_ventMode(const char * value, const int8_t id); + bool set_bypass(const char * value, const int8_t id); bool set_filter(const char * value, const int8_t id); diff --git a/src/emsesp.cpp b/src/emsesp.cpp index 8d8436637..f9ec33684 100644 --- a/src/emsesp.cpp +++ b/src/emsesp.cpp @@ -597,6 +597,7 @@ void EMSESP::publish_other_values() { publish_device_values(EMSdevice::DeviceType::SWITCH); publish_device_values(EMSdevice::DeviceType::HEATPUMP); publish_device_values(EMSdevice::DeviceType::HEATSOURCE); + publish_device_values(EMSdevice::DeviceType::VENTILATION); // other devices without values yet // publish_device_values(EMSdevice::DeviceType::GATEWAY); // publish_device_values(EMSdevice::DeviceType::CONNECT);