Skip to content

Commit

Permalink
Adds support for WPL13
Browse files Browse the repository at this point in the history
  • Loading branch information
kr0ner committed Dec 11, 2024
1 parent 9ce2763 commit 8c36ce2
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 7 deletions.
3 changes: 2 additions & 1 deletion esp32-poe-technik.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

#########################################
Expand Down
7 changes: 4 additions & 3 deletions src/communication.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ static const CanMember Manager{MANAGER_ID, "Manager"};
static const CanMember Kessel{KESSEL_ID, "Kessel"};
static const CanMember HK1{HK1_ID, "HK1"};
static const CanMember HK2{HK2_ID, "HK2"};
static const CanMember FET{0x402, "FET"};

static const std::vector<std::reference_wrapper<const CanMember>> canMembers{Kessel, HK1, HK2, Manager, ESPClient};
static const std::vector<std::reference_wrapper<const CanMember>> canMembers{Kessel, HK1, HK2, Manager, FET, ESPClient};

using Request = std::pair<const CanMember, const Property>;
static std::queue<Request> request_queue;
Expand Down Expand Up @@ -107,8 +108,8 @@ std::pair<Property, SimpleVariant> processCanMessage(const std::vector<std::uint
ESP_LOGI("Communication",
"Message received: Read/Write ID 0x%02x 0x%02x(0x%04x) for property %s (0x%04x) with raw value: %d",
msg[0U], msg[1U], canId, std::string(property.name).c_str(), property.id, value);
if (!isResponse(msg)) {
ESP_LOGD("Communication", "Message is not a response. Dropping it!");
if (isRequest(msg)) {
ESP_LOGD("Communication", "Message is a request. Dropping it!");
return {Property::kINDEX_NOT_FOUND, value};
}
return {property, GetValueByType(value, property.type)};
Expand Down
20 changes: 20 additions & 0 deletions src/property.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ struct Property : public detail::Property {
Property(const std::uint16_t _id) : detail::Property{getProperty(_id)} {}

PROPERTY(INDEX_NOT_FOUND, 0x0000);

#if !defined(WPL_13)
PROPERTY(FEHLERMELDUNG, 0x0001);
PROPERTY(SPEICHERSOLLTEMP, 0x0003, Type::et_dec_val);
PROPERTY(VORLAUFSOLLTEMP, 0x0004, Type::et_dec_val);
Expand Down Expand Up @@ -97,6 +99,7 @@ struct Property : public detail::Property {
PROPERTY(WAERMEERTRAG_HEIZ_TAG_KWH, 0x092f, Type::et_double_val);
PROPERTY(WAERMEERTRAG_HEIZ_SUM_KWH, 0x0930);
PROPERTY(WAERMEERTRAG_HEIZ_SUM_MWH, 0x0931, Type::et_double_val);
#endif

#if defined(THZ_504) || defined(THZ_404) || defined(THZ_5_5_ECO)
PROPERTY(RAUMSOLLTEMP_I, 0x0005, Type::et_dec_val);
Expand Down Expand Up @@ -190,6 +193,23 @@ struct Property : public detail::Property {
PROPERTY(ANLAGENFROST, 0x0a00, Type::et_dec_val);
PROPERTY(WW_ECO, 0x0a06, Type::et_dec_val);
#endif

#if defined(WPL_13)
PROPERTY(AUSSENTEMP, 0x000c, Type::et_dec_val);
PROPERTY(PUFFERISTTEMPERATUR, 0x0078, Type::et_dec_val);
PROPERTY(KOMFORTTEMPERATUR, 0x4eb8, Type::et_dec_val);
PROPERTY(ISTTEMPERATUR, 0x4eb4, Type::et_dec_val);
PROPERTY(RAUMISTTEMP, 0x4ec7, Type::et_dec_val);
PROPERTY(RAUMSOLLTEMP, 0x4ece, Type::et_dec_val);
PROPERTY(RAUMFEUCHTE, 0x4ec8, Type::et_dec_val);
PROPERTY(HEAT_EFF_1D, 0x501d, Type::et_dec_val);
PROPERTY(HEAT_EFF_1Y, 0x501e, Type::et_dec_val);
PROPERTY(VORLAUFTEMP_QUELLE, 0x4fa7, Type::et_dec_val);
PROPERTY(QUELLENDRUCK, 0x4fa8, Type::et_dec_val);
PROPERTY(LEISTUNG_QUELLENPUMPE, 0x4fa9, Type::et_dec_val);
PROPERTY(STROM_INVERTER, 0x06b2, Type::et_dec_val);
PROPERTY(SPANNUNG_INVERTER, 0x06b1, Type::et_dec_val);
#endif
};

#endif
7 changes: 4 additions & 3 deletions yaml/wp_temperature.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
defaults:
interval: $interval_very_slow
target: "Kessel"
name_suffix: ""

sensor:
- platform: template
name: ${property}
id: ${property}
name: ${property}${name_suffix}
id: ${property}${name_suffix}
unit_of_measurement: "°C"
icon: "mdi:thermometer-lines"
device_class: "temperature"
Expand All @@ -22,6 +23,6 @@ esphome:
then:
- lambda: |-
CallbackHandler::instance().addCallback(std::make_pair(${target},Property::k${property}),[](const SimpleVariant& value){
id(${property}).publish_state(value);
id(${property}${name_suffix}).publish_state(value);
});
queueRequest(${target}, Property::k${property});
88 changes: 88 additions & 0 deletions yaml/wpl13.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
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"
- "-DESPCLIENT_ID=$espclient_can_id"
- "-DMANAGER_ID=$manager_can_id"
- "-DKESSEL_ID=$kessel_can_id"
- "-DHK1_ID=$hk1_can_id"
- "-DHK2_ID=$hk2_can_id"

substitutions:
kessel_can_id: "0x180"
hk1_can_id: "0x601"
hk2_can_id: "0x602"
manager_can_id: "0x514"
espclient_can_id: "0x6a2"

#########################################
# #
# 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: $espclient_can_id
use_extended_id: false
bit_rate: 50kbps
on_frame:
- can_id: 0
can_id_mask: 0
then:
- lambda: |-
ESP_LOGD("CAN", "Can message received with CANId 0x%04lx", can_id);
const auto [property, value] = processCanMessage(x);
const auto canMember = getCanMemberByCanId(can_id);
if(canMember) {
auto callback = CallbackHandler::instance().getCallback(std::make_pair(canMember->get(),property));
callback(value);
} else {
ESP_LOGD("CAN", "No CANMember with CANId 0x%04lx available.", can_id);
}
packages:
AUSSENTEMP: !include { file: wp_temperature.yaml, vars: { property: "AUSSENTEMP" }}
ISTTEMPERATUR_HK1: !include { file: wp_temperature.yaml, vars: { property: "ISTTEMPERATUR" , name_suffix: "_HK1" , target: "HK1" }}
KOMFORTTEMPERATUR_HK1: !include { file: wp_temperature.yaml, vars: { property: "KOMFORTTEMPERATUR" , name_suffix: "_HK1" , target: "HK1" }}
ISTTEMPERATUR_HK2: !include { file: wp_temperature.yaml, vars: { property: "ISTTEMPERATUR" , name_suffix: "_HK2" , target: "HK2" }}
KOMFORTTEMPERATUR_HK2: !include { file: wp_temperature.yaml, vars: { property: "KOMFORTTEMPERATUR" , name_suffix: "_HK2" , target: "HK2" }}
PUFFERISTTEMPERATUR: !include { file: wp_temperature.yaml, vars: { property: "PUFFERISTTEMPERATUR" }}
RAUMISTTEMP_HK1: !include { file: wp_temperature.yaml, vars: { property: "RAUMISTTEMP" , name_suffix: "_HK1" , target: "HK1" }}
RAUMISTTEMP_HK2: !include { file: wp_temperature.yaml, vars: { property: "RAUMISTTEMP" , name_suffix: "_HK2" , target: "HK2" }}
RAUMSOLLTEMP_HK1: !include { file: wp_temperature.yaml, vars: { property: "RAUMSOLLTEMP" , name_suffix: "_HK1" , target: "HK1" }}
RAUMSOLLTEMP_HK2: !include { file: wp_temperature.yaml, vars: { property: "RAUMSOLLTEMP" , name_suffix: "_HK2" , target: "HK2" }}
RAUMFEUCHTE: !include { file: wp_generic.yaml, vars: { property: "RAUMFEUCHTE" , interval: $interval_very_slow, unit: "%", icon: "mdi:water-percent", accuracy_decimals: "1", target: "FET" }}
HEAT_EFF_1D: !include { file: wp_generic.yaml, vars: { property: "HEAT_EFF_1D" }}
HEAT_EFF_1Y: !include { file: wp_generic.yaml, vars: { property: "HEAT_EFF_1Y" }}
VORLAUFTEMP_QUELLE: !include { file: wp_temperature.yaml, vars: { property: "VORLAUFTEMP_QUELLE" }}
QUELLENDRUCK: !include { file: wp_generic.yaml, vars: { property: "QUELLENDRUCK" , interval: never, unit: "bar" , icon: "mdi:water-pressure" , accuracy_decimals: "1" }}
LEISTUNG_QUELLENPUMPE: !include { file: wp_generic.yaml, vars: { property: "LEISTUNG_QUELLENPUMPE" , interval: never, unit: "%" , icon: "mdi:water-percent", accuracy_decimals: "1", target: "Manager" }}
STROM_INVERTER: !include { file: wp_generic.yaml, vars: { property: "STROM_INVERTER" , interval: never, unit: "A" , target: "Manager"}}
SPANNUNG_INVERTER: !include { file: wp_generic.yaml, vars: { property: "SPANNUNG_INVERTER" , interval: never, unit: "V" , target: "Manager"}}

0 comments on commit 8c36ce2

Please sign in to comment.