Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Wpl13 #70

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
15 changes: 9 additions & 6 deletions src/communication.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@ 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 CanMember R2D2{0x700, "R2D2"};
static const CanMember C3PO{0x480, "C3PO"};

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, R2D2, C3PO, ESPClient};

using Request = std::pair<const CanMember, const Property>;
static std::queue<Request> request_queue;
Expand All @@ -51,9 +55,8 @@ std::optional<std::reference_wrapper<const CanMember>> getCanMemberByCanId(CANId
*/
bool isRequest(const std::vector<std::uint8_t>& msg) {
const auto id{msg[1U] | (msg[0U] << 8U)};
const auto it = std::find_if(canMembers.cbegin(), canMembers.cend(), [id](const auto& member) {
return member.get().getReadId() == id || member.get().getWriteId() == id;
});
const auto it = std::find_if(canMembers.cbegin(), canMembers.cend(),
[id](const auto& member) { return member.get().getReadId() == id; });
return it != canMembers.cend();
}

Expand Down Expand Up @@ -107,8 +110,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
7 changes: 5 additions & 2 deletions src/mapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,14 @@ Mapper::Mapper() {
{0x001f, "ERR HD-SENSOR"},
{0x0020, "Einfrierschutz"},
{0x0021, "KEINE LEISTUNG"}};

#if defined(WPL_13)
betriebsartMap = {{0x0000, "Notbetrieb"}, {0x0001, "Bereitschaft"}, {0x0002, "Programm"},
{0x0003, "Komfort"}, {0x0004, "Eco"}, {0x0005, "Warmwasser"}};
#else
betriebsartMap = {{0x0000, "Notbetrieb"}, {0x0100, "Bereitschaft"}, {0x0300, "Tagbetrieb"},
{0x0400, "Absenkbetrieb"}, {0x0500, "Warmwasser"}, {0x0B00, "Automatik"},
{0x0E00, "Handbetrieb"}};

#endif
kuehlmodusMap = {{0x0000, "Flaechenkuehlung"}, {0x0001, "Geblaesekuehlung"}};

passivkuehlungMap = {
Expand Down
28 changes: 28 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,31 @@ 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);
PROPERTY(EINSTELL_SPEICHERSOLLTEMP, 0x0013, Type::et_dec_val);
PROPERTY(SPEICHERISTTEMP, 0x000e, Type::et_dec_val);
PROPERTY(ANLAGENFROST, 0xfe07, Type::et_dec_val);
PROPERTY(VORLAUFISTTEMP, 0xfdf3, Type::et_dec_val);
PROPERTY(VOLUMENSTROM, 0x02e2, Type::et_dec_val);
PROPERTY(VERDICHTER_STARTS, 0x4ef1);
PROPERTY(VERDICHTER_STARTS_K, 0x4ef0);
PROPERTY(PROGRAMMSCHALTER, 0x4f1b);
#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});
118 changes: 118 additions & 0 deletions yaml/wpl13.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
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);
}

select:
- platform: template
name: "PROGRAMMSCHALTER"
id: PROGRAMMSCHALTER
options:
- "Notbetrieb"
- "Bereitschaft"
- "Programm"
- "Komfort"
- "Eco"
- "Unbekannt"
initial_option: "Unbekannt"
optimistic: true
setup_priority: 100
set_action:
then:
- lambda: |-
const auto betriebsartId = Mapper::instance().getBetriebsartId(x);
if(betriebsartId.has_value()) {
sendData(Kessel, Property::kPROGRAMMSCHALTER, betriebsartId.value());
}

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" }}
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" }}
PUFFERISTTEMPERATUR: !include { file: wp_temperature.yaml, vars: { property: "PUFFERISTTEMPERATUR" }}
EINSTELL_SPEICHERSOLLTEMP: !include { file: wp_temperature.yaml, vars: { property: "EINSTELL_SPEICHERSOLLTEMP" }}
SPEICHERISTTEMP: !include { file: wp_temperature.yaml, vars: { property: "SPEICHERISTTEMP" , interval: $interval_medium }}
ANLAGENFROST: !include { file: wp_temperature.yaml, vars: { property: "ANLAGENFROST" , target: "R2D2" }}
VORLAUFISTTEMP: !include { file: wp_temperature.yaml, vars: { property: "VORLAUFISTTEMP" , target: "R2D2" }}
VORLAUFTEMP_QUELLE: !include { file: wp_temperature.yaml, vars: { property: "VORLAUFTEMP_QUELLE" , target: "Manager" }}

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" , target: "C3PO" }}
HEAT_EFF_1Y: !include { file: wp_generic.yaml, vars: { property: "HEAT_EFF_1Y" , target: "C3PO" }}
QUELLENDRUCK: !include { file: wp_generic.yaml, vars: { property: "QUELLENDRUCK" , interval: never, unit: "bar" , icon: "mdi:water-pressure" , accuracy_decimals: "1", target: "Manager" }}
LEISTUNG_QUELLENPUMPE: !include { file: wp_generic.yaml, vars: { property: "LEISTUNG_QUELLENPUMPE" , interval: never, unit: "%" , icon: "mdi:water-percent", accuracy_decimals: "1", target: "Manager" }}
VOLUMENSTROM: !include { file: wp_generic.yaml, vars: { property: "VOLUMENSTROM" , interval: never, unit: "l/min", icon: "mdi:flow" , 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" }}

VERDICHTER_STARTS: !include { file: wp_generic_combined.yaml, vars: { sensor_name: "VERDICHTER_STARTS" , scaled_property: "VERDICHTER_STARTS_K" , property: "VERDICHTER_STARTS" , unit: "" , accuracy_decimals: "0", scaler: "1000", icon: "mdi:counter" , target: "Manager" }}
Loading