ESPHome 2026.11.0b6
Loading...
Searching...
No Matches
hon_water_heater.h
Go to the documentation of this file.
1#pragma once
2
3#include "hon_parser.h"
7#ifdef USE_SENSOR
9#endif
10#ifdef USE_BINARY_SENSOR
12#endif
13#ifdef USE_TEXT_SENSOR
15#endif
16
18
20 public:
21 void setup() override;
22 void loop() override;
23 void dump_config() override;
25
27#ifdef USE_SENSOR
28 SUB_SENSOR(primary_temperature)
29 SUB_SENSOR(secondary_temperature)
30 SUB_SENSOR(target_temperature)
31 SUB_SENSOR(estimated_heating_time)
32 SUB_SENSOR(available_water)
33#endif
34#ifdef USE_BINARY_SENSOR
35 SUB_BINARY_SENSOR(communication)
36 SUB_BINARY_SENSOR(power)
37 SUB_BINARY_SENSOR(heating)
38#endif
39#ifdef USE_TEXT_SENSOR
40 SUB_TEXT_SENSOR(mode)
41#endif
42
43 protected:
44 static constexpr uint32_t NETWORK_STATUS_INTERVAL_ID = 0;
45 static constexpr uint32_t STATUS_POLL_INTERVAL_ID = 1;
46 static constexpr uint32_t NETWORK_STATUS_INTERVAL_MS = 500;
47 static constexpr uint32_t POLL_INTERVAL_MS = 5000;
48 static constexpr uint32_t RESPONSE_TIMEOUT_MS = 5000; // a polled or controlled reply
49 static constexpr uint32_t NETWORK_ACK_TIMEOUT_MS = 2000; // the CONFIRM of a network status
50 static constexpr uint32_t NETWORK_REFRESH_MS = 30000; // resend the network status this often
51 static constexpr uint32_t CONTROL_STATUS_MAX_AGE_MS = 15000; // a control needs a status this fresh
52 static constexpr uint32_t FRAME_GAP_MS = 300; // silence that ends a partial frame
53 static constexpr uint8_t POLL_CYCLE = 12; // version and id are re-read once per cycle
54 static constexpr uint8_t MAX_BYTES_PER_LOOP = 255;
55 static constexpr uint8_t MIN_TARGET_TEMPERATURE = 35;
56 static constexpr uint8_t MAX_TARGET_TEMPERATURE = 75;
57 static constexpr uint8_t NETWORK_READY = 0x07;
58 static constexpr uint8_t NETWORK_NOT_READY = 0x05;
59
60 // The link carries one request at a time; this is the one whose answer is outstanding.
62
63 void control(const water_heater::WaterHeaterCall &call) override;
65 void check_timeouts_(uint32_t now);
66 void send_pending_(uint32_t now);
67 void read_frames_(uint32_t now);
68 void poll_status_();
70 void publish_communication_(bool connected);
71 void send_frame_(water_heater_protocol::FrameType type, const uint8_t *payload = nullptr, size_t size = 0);
72 void send_request_(uint32_t now, Awaiting kind, water_heater_protocol::FrameType type, const uint8_t *payload,
73 size_t size, water_heater_protocol::FrameType expected);
75 void process_frame_();
79
87 std::array<water_heater_protocol::Command, 4> commands_{}; // power, to Normal, mode, temperature at most
92 uint8_t command_count_{0};
93 uint8_t command_index_{0};
94 uint8_t poll_stage_{0};
95 bool network_pending_{true};
96 bool have_status_{false};
97 bool pending_off_{false};
98};
99
100} // namespace esphome::haier_water_heater
BedjetMode mode
BedJet operating mode.
water_heater::WaterHeaterCallInternal make_call() override
void handle_frame_type_(water_heater_protocol::FrameType type)
static SUB_SENSOR(primary_temperature) SUB_SENSOR(secondary_temperature) SUB_SENSOR(target_temperature) SUB_SENSOR(estimated_heating_time) SUB_SENSOR(available_water) SUB_BINARY_SENSOR(communication) SUB_BINARY_SENSOR(power) SUB_BINARY_SENSOR(heating) SUB_TEXT_SENSOR(mode) protected constexpr uint32_t STATUS_POLL_INTERVAL_ID
void send_request_(uint32_t now, Awaiting kind, water_heater_protocol::FrameType type, const uint8_t *payload, size_t size, water_heater_protocol::FrameType expected)
water_heater_protocol::FrameType expected_type_
void publish_status_(const water_heater_protocol::Status &status)
void send_frame_(water_heater_protocol::FrameType type, const uint8_t *payload=nullptr, size_t size=0)
water_heater_protocol::HonMode reported_mode_
static constexpr uint32_t NETWORK_ACK_TIMEOUT_MS
water_heater::WaterHeaterMode last_active_mode_
void control(const water_heater::WaterHeaterCall &call) override
void confirm_control_(const water_heater_protocol::Status &status)
static constexpr uint32_t NETWORK_STATUS_INTERVAL_MS
static constexpr uint32_t CONTROL_STATUS_MAX_AGE_MS
water_heater::WaterHeaterTraits traits() override
water_heater_protocol::FrameParser parser_
std::array< water_heater_protocol::Command, 4 > commands_
float target_temperature
Definition climate.h:0
uint8_t type
uint32_t value
Definition hal.cpp:41
uint16_t size
Definition helpers.cpp:34
static void uint32_t