Skip to content

Commit f69c3a2

Browse files
committed
Refactor error messages and options for clarity and consistency in mapper.cpp and wp_base.yaml; update README.md for project focus on Tecalor THZ504
1 parent 72438ea commit f69c3a2

File tree

5 files changed

+168
-92
lines changed

5 files changed

+168
-92
lines changed

README.md

Lines changed: 95 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,120 @@
1-
This project aims to provide all kinds of useful features for your Home Assistant instance using a single ESP32 board.
1+
# OneESP32ToRuleThemAll - THZ504 Simplified
2+
3+
This project is a simplified version derived from [OneESP32ToRuleThemAll](https://github.com/kr0ner/OneESP32ToRuleThemAll), specifically focused on controlling the **Tecalor THZ504** heat pump via CAN bus using an ESP32 board and Home Assistant.
4+
5+
## About
6+
7+
This codebase has been streamlined from the original OneESP32ToRuleThemAll project to focus exclusively on the Tecalor THZ504 model, removing support for smart meters, water meters, and other heat pump variants to provide a cleaner, more targeted solution.
28

39
## Features:
410

5-
- SmartMeter readings via optical sensor [https://amzn.eu/d/1a28LBy]
6-
- WaterMeter readings via [https://amzn.eu/d/8Rx0UVJ]
7-
- Controlling a Tecalor THZ 504 (or other Tecalor | Stiebel Eltron heat pumps) via CAN [https://amzn.eu/d/5nJJK3r]
11+
- **Tecalor THZ504 Heat Pump Control** via CAN bus using SN65HVD230 transceiver [https://www.amazon.de/dp/B00KM6XMXO]
12+
- Complete climate control (heating, cooling, hot water)
13+
- Energy monitoring (daily/total consumption, COP calculations)
14+
- Ventilation control with multiple speed levels
15+
- Temperature sensors (room, storage, flow, return temperatures)
16+
- Binary sensors for system status (compressor, pumps, filters)
17+
- Custom ESPHome climate entities with Home Assistant integration
818

919
## Prerequisites:
1020

1121
- A working Home Assistant installation [https://www.home-assistant.io/]
1222
- ESPHome AddOn installed [https://www.home-assistant.io/integrations/esphome/]
1323

14-
## HowTo:
24+
## Hardware Requirements:
25+
26+
- ESP32-C6-Zero board
27+
- SN65HVD230 CAN bus transceiver module [https://www.amazon.de/dp/B00KM6XMXO]
28+
- Tecalor THZ504 heat pump with CAN bus interface
29+
30+
## Setup Instructions:
31+
32+
1. **Hardware Connection:**
33+
- Connect SN65HVD230 CAN transceiver to ESP32-C6-Zero:
34+
- TX: GPIO5
35+
- RX: GPIO4
36+
- VCC: 3.3V
37+
- GND: GND
38+
- Connect CAN H/L to your THZ504's CAN bus
39+
40+
2. **ESPHome Configuration:**
41+
- Navigate to your ESPHome folder
42+
- Clone or copy this repository
43+
- Use `esp32-c6-thz504.yaml` as your main configuration file
44+
- Update `secrets.yaml` with your WiFi credentials and API keys
45+
- Modify Home Assistant entity IDs in `common.yaml` for room temperature and humidity sensors
1546

16-
1. navigate to your esphome folder
17-
2. clone the repo (git clone https://github.com/kr0ner/OneESP32ToRuleThemAll.git)
18-
3. copy or symlink OneESP32ToRuleThemAll/esp32-poe-technik.yaml to your esphome folder
19-
4. change board type if needed
20-
5. comment out packages you don't want/need
21-
6. add Wifi if necessary
22-
7. change pins for SPI/CAN if needed
23-
8. provide HA entities for temperature and humidity
47+
3. **Home Assistant Integration:**
48+
- Install ESPHome add-on if not already installed
49+
- Add the device to ESPHome dashboard
50+
- Flash the firmware to your ESP32-C6-Zero
51+
- Configure room temperature and humidity sensors in Home Assistant
2452

25-
## Add new readings from heat pump / adopt to your device
53+
## Project Structure
2654

27-
1. Navigate through the menu of the display, mounted to your heat pump
28-
2. Try to match the values (e.g. 237) to the values you see in the display (23.7°)
29-
3. Use the existing templates to add new sensors
30-
4. Add the newly added ids along with their types to property.h
31-
5. Guard the newly added ids with e.g. #if defined(THZ_5_5_ECO) ... #endif to express that it was tested with that version once it is confirmed for the others, the guards can be removed
32-
6. Add the entities to the respective yaml and use the already existing templates. For config values that can be set, use the wp_number.yaml. For sensors that are updated automatically chose the template that fits best.
33-
7. profit
55+
- **`esp32-c6-thz504.yaml`** - Main ESP32-C6-Zero configuration file
56+
- **`yaml/thz504.yaml`** - THZ504-specific sensor definitions
57+
- **`yaml/common.yaml`** - Common CAN bus and core functionality (configured for SN65HVD230)
58+
- **`yaml/wp_base.yaml`** - Base heat pump sensors and climate entities
59+
- **`src/`** - C++ source files for custom components
60+
- **`components/`** - Custom ESPHome components
61+
62+
## Available Entities
63+
64+
The configuration provides comprehensive control and monitoring:
65+
66+
- **Climate Controls:** Heating Day/Night, Hot Water Day/Night with temperature setpoints
67+
- **Binary Sensors:** Compressor, heating, cooling, ventilation, pumps, filter status
68+
- **Temperature Sensors:** Room, storage tank, flow/return, outdoor, evaporator
69+
- **Energy Monitoring:** Daily energy consumption, COP calculations, total energy counters
70+
- **Ventilation:** 3-speed fan control with airflow monitoring
71+
- **System Status:** Operating modes, error messages, service indicators
72+
73+
## Customization for THZ504
74+
75+
This version is specifically configured for THZ504 with:
76+
- ESP32-C6-Zero with built-in CAN controller using SN65HVD230 transceiver
77+
- CAN bus IDs optimized for THZ504 communication
78+
- Temperature sensor mappings verified for THZ504
79+
- Energy calculation formulas based on THZ504 specifications
80+
- Ventilation control adapted to THZ504 fan characteristics
3481

3582
## Troubleshooting
36-
### You are not able to control your heat pump
37-
--> Increase the log level and try to find out which CAN identifiers to use. Also check the forum and communciation.h
3883

39-
### You get garbage values for certain sensors
40-
--> There is no offical description of the IDs available. Everything is somewhat trial-and-error.
41-
Also there are many differences between the different heat pumps. Play around with the display and try to find out
42-
the correct IDs.
84+
### Heat Pump Control Issues
85+
- Increase log level to DEBUG in your YAML configuration
86+
- Check CAN bus wiring (CAN H/L connections)
87+
- Verify CAN bus termination resistors are properly installed
88+
- Monitor CAN traffic using the built-in logging
89+
90+
### Sensor Value Issues
91+
- THZ504-specific sensor mappings are pre-configured in this version
92+
- If values appear incorrect, check the heat pump display to verify scaling
93+
- Some sensors may take time to populate after initial connection
4394

95+
### Connection Problems
96+
- Ensure ESP32-C6-Zero is properly powered and connected to WiFi
97+
- Check that the SN65HVD230 CAN transceiver is receiving 3.3V power
98+
- Verify CAN H/L wiring connections to the THZ504
99+
- Verify Home Assistant can communicate with the ESPHome device
44100

45-
Forked from https://github.com/kr0ner/OneESP32ToRuleThemAll
101+
## Credits & Acknowledgments
46102

47-
Heavily inspired by this post in HA community forum:
103+
This project is **derived from** [OneESP32ToRuleThemAll](https://github.com/kr0ner/OneESP32ToRuleThemAll) by [@kr0ner](https://github.com/kr0ner) and has been simplified to focus specifically on the **Tecalor THZ504** heat pump model.
48104

49-
https://community.home-assistant.io/t/configured-my-esphome-with-mcp2515-can-bus-for-stiebel-eltron-heating-pump/366053
105+
**Original project inspiration:**
106+
- [OneESP32ToRuleThemAll](https://github.com/kr0ner/OneESP32ToRuleThemAll) - The comprehensive multi-device ESP32 solution
107+
- Home Assistant Community Forum: [Configured my ESPHome with MCP2515 CAN bus for Stiebel Eltron heating pump](https://community.home-assistant.io/t/configured-my-esphome-with-mcp2515-can-bus-for-stiebel-eltron-heating-pump/366053)
108+
- [ha-stiebel-control](https://github.com/bullitt186/ha-stiebel-control) by [@bullitt186](https://github.com/bullitt186)
50109

51-
and
110+
**Special thanks to:**
111+
- [@kr0ner](https://github.com/kr0ner) for the original comprehensive implementation
112+
- [@hovhannes85](https://github.com/hovhannes85) for contributions to the original project
113+
- The Home Assistant and ESPHome communities for their ongoing support
52114

53-
https://github.com/bullitt186/ha-stiebel-control
115+
## License
54116

55-
special thanks to [@hovhannes85](https://github.com/hovhannes85)
117+
This project maintains the same license as the original OneESP32ToRuleThemAll project.
56118

57119
### Useful links
58120
https://www.stiebel-eltron.de/content/dam/ste/cdbassets/historic/bedienungs-_u_installationsanleitungen/ISG_Modbus__b89c1c53-6d34-4243-a630-b42cf0633361.pdf

esp32-c6-thz504.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ sensor:
7272

7373
# Memory and system info
7474
text_sensor:
75-
- platform: debug
76-
device:
77-
name: "ESP32-C6 Device Info"
78-
reset_reason:
79-
name: "ESP32-C6 Reset Reason"
75+
# - platform: debug
76+
# device:
77+
# name: "ESP32-C6 Device Info"
78+
# reset_reason:
79+
# name: "ESP32-C6 Reset Reason"
8080

8181
- platform: wifi_info
8282
ip_address:

src/mapper.cpp

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -48,42 +48,37 @@ std::optional<std::uint16_t> Mapper::getPassivkuehlungId(const std::string& pass
4848
}
4949

5050
Mapper::Mapper() {
51-
errorMap = {{0x0002, "Schuetz klebt"},
51+
errorMap = {{0x0002, "CONTACTOR_STUCK"},
5252
{0x0003, "ERR HD-SENSOR"},
53-
{0x0004, "Hochdruck"},
54-
{0x0005, "Verdampferfuehler"},
55-
{0x0006, "Relaistreiber"},
56-
{0x0007, "Relaispegel"},
57-
{0x0008, "Hexschalter"},
58-
{0x0009, "Drehzahl Luefter"},
59-
{0x000a, "Lueftertreiber"},
53+
{0x0004, "HIGH_PRESSURE"},
54+
{0x0005, "EVAPORATOR_SENSOR_ERROR"},
55+
{0x0006, "RELAY_DRIVER_ERROR"},
56+
{0x0007, "RELAY_LEVEL_ERROR"},
57+
{0x0008, "HEX_SWITCH_ERROR"},
58+
{0x0009, "FAN_SPEED_ERROR"},
59+
{0x000a, "FAN_DRIVER_ERROR"},
6060
{0x000b, "Reset Baustein"},
6161
{0x000c, "ND"},
62-
{0x000d, "ROM"},
63-
{0x000e, "QUELLEN MINTEMP"},
64-
{0x0010, "Abtauen"},
62+
{0x000d, "ROM_ERROR"},
63+
{0x000e, "SOURCE_MIN_TEMP"},
64+
{0x0010, "DEFROST_ERROR"},
6565
{0x0012, "ERR T-HEI IWS"},
6666
{0x0017, "ERR T-FRO IWS"},
67-
{0x001a, "Niederdruck"},
67+
{0x001a, "LOW_PRESSURE"},
6868
{0x001b, "ERR ND-DRUCK"},
6969
{0x001c, "ERR HD-DRUCK"},
7070
{0x001d, "HD-SENSOR-MAX"},
7171
{0x001e, "HEISSGAS-MAX"},
7272
{0x001f, "ERR HD-SENSOR"},
73-
{0x0020, "Einfrierschutz"},
74-
{0x0021, "KEINE LEISTUNG"}};
73+
{0x0020, "FREEZE_PROTECTION"},
74+
{0x0021, "NO_POWER"}};
7575

76-
#if defined(TTF_07_C) | defined(WPL_13)
77-
betriebsartMap = {{0x0000, "Notbetrieb"}, {0x0100, "Bereitschaft"}, {0x0200, "Programm"},
78-
{0x0300, "Komfort"}, {0x0400, "Eco"}, {0x0500, "Warmwasser"}};
79-
#else
80-
betriebsartMap = {{0x0000, "Notbetrieb"}, {0x0100, "Bereitschaft"}, {0x0300, "Tagbetrieb"},
81-
{0x0400, "Absenkbetrieb"}, {0x0500, "Warmwasser"}, {0x0B00, "Automatik"},
82-
{0x0E00, "Handbetrieb"}};
83-
#endif
76+
betriebsartMap = {{0x0000, "EMERGENCY_MODE"}, {0x0100, "STANDBY_MODE"}, {0x0300, "DAY_MODE"},
77+
{0x0400, "HOLIDAY_MODE"}, {0x0500, "DHW_MODE"}, {0x0B00, "AUTO_MODE"},
78+
{0x0E00, "MANUAL_MODE"}};
8479

85-
kuehlmodusMap = {{0x0000, "Flaechenkuehlung"}, {0x0001, "Geblaesekuehlung"}};
80+
kuehlmodusMap = {{0x0000, "SURFACE_COOLING"}, {0x0001, "FAN_COOLING"}};
8681

8782
passivkuehlungMap = {
88-
{0x0000, "Aus"}, {0x0001, "Ablüften"}, {0x0002, "Zulüften"}, {0x0003, "Bypass"}, {0x0004, "Sommerkassette"}};
83+
{0x0000, "OFF"}, {0x0001, "EXHAUST_FLUSH"}, {0x0002, "FRESH_AIR_INTAKE"}, {0x0003, "BYPASS_MODE"}, {0x0004, "SUMMER_CASSETTE"}};
8984
}

upload-log.txt

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,28 @@
11

2-
[2025-09-28 23:22:52] Starting ESPHome direct upload process...
3-
[2025-09-28 23:22:52] Project path: C:\dev\repos\OneESP32ToRuleThemAll
4-
[2025-09-28 23:22:52] Config file: esp32-c6-thz504.yaml
5-
[2025-09-28 23:22:52] Device IP: 192.168.200.80
6-
[2025-09-28 23:22:53] ESPHome found: Version: 2025.5.1
7-
[2025-09-28 23:22:53] Starting compilation of esp32-c6-thz504.yaml...
8-
[2025-09-28 23:22:53] Running: esphome compile esp32-c6-thz504.yaml
9-
[2025-09-28 23:23:04] Compilation completed successfully!
10-
[2025-09-28 23:23:04] Testing connection to device at 192.168.200.80...
11-
[2025-09-28 23:23:05] Device is reachable at 192.168.200.80
12-
[2025-09-28 23:23:05] Starting upload to device at 192.168.200.80...
13-
[2025-09-28 23:23:05] Running: esphome upload esp32-c6-thz504.yaml --device 192.168.200.80
2+
[2025-09-29 00:04:56] Starting ESPHome direct upload process...
3+
[2025-09-29 00:04:56] Project path: C:\dev\repos\OneESP32ToRuleThemAll
4+
[2025-09-29 00:04:56] Config file: esp32-c6-thz504.yaml
5+
[2025-09-29 00:04:56] Device IP: 192.168.200.80
6+
[2025-09-29 00:04:57] ESPHome found: Version: 2025.5.1
7+
[2025-09-29 00:04:57] Starting compilation of esp32-c6-thz504.yaml...
8+
[2025-09-29 00:04:57] Running: esphome compile esp32-c6-thz504.yaml
9+
[2025-09-29 00:05:07] Compilation completed successfully!
10+
[2025-09-29 00:05:07] Testing connection to device at 192.168.200.80...
11+
[2025-09-29 00:05:08] Device is reachable at 192.168.200.80
12+
[2025-09-29 00:05:08] Starting upload to device at 192.168.200.80...
13+
[2025-09-29 00:05:08] Running: esphome upload esp32-c6-thz504.yaml --device 192.168.200.80
14+
[2025-09-29 00:05:22] Upload completed successfully!
15+
[2025-09-29 00:05:22] Device should be rebooting now...
16+
[2025-09-29 00:05:22] === OPERATION SUMMARY ===
17+
[2025-09-29 00:05:22] Config File: esp32-c6-thz504.yaml
18+
[2025-09-29 00:05:22] Device IP: 192.168.200.80
19+
[2025-09-29 00:05:22] Project: C:\dev\repos\OneESP32ToRuleThemAll
20+
[2025-09-29 00:05:22]
21+
[2025-09-29 00:05:22] Compilation: SUCCESS
22+
[2025-09-29 00:05:22] Upload: SUCCESS
23+
[2025-09-29 00:05:22]
24+
[2025-09-29 00:05:22] Log file: C:\dev\repos\OneESP32ToRuleThemAll\upload-log.txt
25+
[2025-09-29 00:05:22] Next steps:
26+
[2025-09-29 00:05:22] - Device should be running new firmware
27+
[2025-09-29 00:05:22] - Check Home Assistant for updated sensors
28+
[2025-09-29 00:05:22] - Monitor device logs with: .\upload-to-esp32.ps1 -Logs

yaml/wp_base.yaml

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ esphome:
66
then:
77
- lambda: |-
88
CallbackHandler::instance().addCallback(std::make_pair(Kessel,Property::kPASSIVE_COOLING),[](const SimpleVariant& value){
9-
const auto stringValue{Mapper::instance().getPassivkuehlung(value).value_or("Unbekannt")};
9+
const auto stringValue{Mapper::instance().getPassivkuehlung(value).value_or("UNKNOWN")};
1010
const auto index = id(PASSIVE_COOLING).index_of(stringValue);
1111
if(index.has_value()) {
1212
id(PASSIVE_COOLING).publish_state(stringValue);
@@ -41,7 +41,10 @@ esphome:
4141
});
4242
4343
id(ELECTRIC_BACKUP_HEATING).add_on_state_callback([](const bool state){
44-
const auto electricHeatingPower = state ? id(BACKUP_HEATER_LEVEL_DHW).state * 230.0 /*V*/ * 12.6 /*A*/ : 0.0f;
44+
float electricHeatingPower = 0.0f;
45+
if (state && !isnan(id(BACKUP_HEATER_LEVEL_DHW).state)) {
46+
electricHeatingPower = id(BACKUP_HEATER_LEVEL_DHW).state * 230.0 /*V*/ * 12.6 /*A*/;
47+
}
4548
id(ELECTRIC_HEATING_POWER).publish_state(electricHeatingPower);
4649
});
4750
@@ -91,13 +94,13 @@ select:
9194
name: "PASSIVE_COOLING"
9295
id: PASSIVE_COOLING
9396
options:
94-
- "Aus"
95-
- "Ablüften"
96-
- "Zulüften"
97-
- "Bypass"
98-
- "Sommerkassette"
99-
- "Unbekannt"
100-
initial_option: "Unbekannt"
97+
- "OFF"
98+
- "EXHAUST_FLUSH"
99+
- "FRESH_AIR_INTAKE"
100+
- "BYPASS_MODE"
101+
- "SUMMER_CASSETTE"
102+
- "UNKNOWN"
103+
initial_option: "UNKNOWN"
101104
optimistic: true
102105
setup_priority: 100
103106
set_action:
@@ -112,15 +115,15 @@ select:
112115
name: "PROGRAM_SWITCH"
113116
id: PROGRAM_SWITCH
114117
options:
115-
- "Notbetrieb"
116-
- "Bereitschaft"
117-
- "Automatik"
118-
- "Tagbetrieb"
119-
- "Absenkbetrieb"
120-
- "Warmwasser"
121-
- "Handbetrieb"
122-
- "Unbekannt"
123-
initial_option: "Unbekannt"
118+
- "EMERGENCY_MODE"
119+
- "STANDBY_MODE"
120+
- "AUTO_MODE"
121+
- "DAY_MODE"
122+
- "HOLIDAY_MODE"
123+
- "DHW_MODE"
124+
- "MANUAL_MODE"
125+
- "UNKNOWN_MODE"
126+
initial_option: "UNKNOWN_MODE"
124127
optimistic: true
125128
setup_priority: 100
126129
set_action:
@@ -149,6 +152,7 @@ sensor:
149152
state_class: measurement
150153
device_class: power
151154
unit_of_measurement: "W"
155+
lambda: "return 0.0f;" # Initialize with 0W (updated by callback)
152156

153157
#########################################
154158
# #

0 commit comments

Comments
 (0)