From 34b0f436520d691e4accb42ee96082526ee93ab8 Mon Sep 17 00:00:00 2001 From: kr0ner Date: Wed, 4 Dec 2024 23:51:30 +0100 Subject: [PATCH] Add support for wpl13 --- esp32-poe-technik.yaml | 3 +- src/communication.h | 19 ++++-- src/property.h | 141 +++-------------------------------------- src/simple_variant.h | 1 + yaml/wpl13.yaml | 56 ++++++++++++++++ 5 files changed, 83 insertions(+), 137 deletions(-) create mode 100644 yaml/wpl13.yaml diff --git a/esp32-poe-technik.yaml b/esp32-poe-technik.yaml index 853a19f..e605472 100644 --- a/esp32-poe-technik.yaml +++ b/esp32-poe-technik.yaml @@ -97,9 +97,10 @@ packages: watermeter: !include OneESP32ToRuleThemAll/yaml/watermeter.yaml sensors: !include OneESP32ToRuleThemAll/yaml/sensors.yaml # thz404: !include OneESP32ToRuleThemAll/yaml/thz404.yaml - thz504: !include OneESP32ToRuleThemAll/yaml/thz504.yaml +# thz504: !include OneESP32ToRuleThemAll/yaml/thz504.yaml # thz55eco: !include OneESP32ToRuleThemAll/yaml/thz5_5_eco.yaml # ttf07: !include OneESP32ToRuleThemAll/yaml/ttf07.yaml + wpl13: !include OneESP32ToRuleThemAll/yaml/wpl13.yaml kondensatpumpe: !include OneESP32ToRuleThemAll/yaml/kondensatpumpe.yaml ######################################### diff --git a/src/communication.h b/src/communication.h index 64ee069..413161f 100644 --- a/src/communication.h +++ b/src/communication.h @@ -20,11 +20,11 @@ struct CanMember { std::uint16_t getResponseId() const { return getWriteId() | 0x200; } }; -static const CanMember ESPClient{0x6a2, "ESPClient"}; -static const CanMember Anfrage{0x6a1, "Anfrage"}; +static const CanMember ESPClient{0x680, "ESPClient"}; static const CanMember Kessel{0x180, "Kessel"}; -static const CanMember HK1{0x301, "HK1"}; -static const CanMember HK2{0x302, "HK2"}; +static const CanMember HK1{0x500, "HK1"}; +static const CanMember HK2{0x480, "HK2"}; +static const CanMember Anfrage{0x700, "Anfrage"}; using Request = std::pair; static std::queue request_queue; @@ -40,6 +40,14 @@ bool isRequest(const std::vector& msg) { return it != members.cend(); } +bool isResponse(const std::vector& msg) { + const auto id{msg[1U] | (msg[0U] << 8U)}; + const std::vector members = {ESPClient, Anfrage, Kessel, HK1, HK2}; + const auto it = std::find_if(members.cbegin(), members.cend(), + [id](const auto& member) { return member.getResponseId() == id; }); + return it != members.cend(); +} + /** * @brief Puts a request towards the \c member for the given \c property in the request queue. * This will effectively prevent that requests are all sent at the same time, which might @@ -80,7 +88,8 @@ std::pair processCanMessage(const std::vector #include #include +#include template struct is_string diff --git a/yaml/wpl13.yaml b/yaml/wpl13.yaml new file mode 100644 index 0000000..2868b6c --- /dev/null +++ b/yaml/wpl13.yaml @@ -0,0 +1,56 @@ +esphome: + includes: + - OneESP32ToRuleThemAll/src/callback_handler.h + - OneESP32ToRuleThemAll/src/communication.h + - OneESP32ToRuleThemAll/src/mapper.h + - OneESP32ToRuleThemAll/src/mapper.cpp + - OneESP32ToRuleThemAll/src/property.h + - OneESP32ToRuleThemAll/src/property.cpp + - OneESP32ToRuleThemAll/src/simple_variant.h + - OneESP32ToRuleThemAll/src/type.h + - OneESP32ToRuleThemAll/src/type.cpp + platformio_options: + build_flags: + - "-DWPL_13" + +######################################### +# # +# Intervals # +# # +######################################### +interval: + - interval: 250ms + then: + - lambda: |- + // Request sensor value one after another. + if(!request_queue.empty()) { + constexpr auto use_extended_id{false}; + const auto request_element = request_queue.front(); + request_queue.pop(); + //requestData(request_element.first, request_element.second); + } + +######################################### +# # +# CANbus configuration # +# # +######################################### +canbus: + - id: wp_can + can_id: 680 + use_extended_id: false + bit_rate: 20kbps + on_frame: + - can_id: 0 + can_id_mask: 0 + then: + - lambda: |- + ESP_LOGI("CAN", "message received with CAN-Id 0x%04x", can_id); + const auto property_value_pair = processCanMessage(x); + +packages: + AUSSENTEMP: !include { file: wp_temperature.yaml, vars: { property: "AUSSENTEMP" }} + RUECKLAUFISTTEMP: !include { file: wp_temperature.yaml, vars: { property: "RUECKLAUFISTTEMP" }} + TAUPUNKTTEMPERATUR: !include { file: wp_temperature.yaml, vars: { property: "TAUPUNKTTEMPERATUR", target: "HK1" }} + QUELLENDRUCK: !include { file: wp_generic.yaml, vars: { property: "QUELLENDRUCK" , unit: "bar" , icon: "mdi:water-pressure", accuracy_decimals: "1" }} +# add new sensors that you want to expose to HA here ... look at the parameters that you can pass to them ... maybe you need to override target with HK1, or HK2. Depends where the values are incoming \ No newline at end of file