ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
hon_water_heater.h
Go to the documentation of this file.
1#pragma once
2
3#include "hon_parser.h"
10
12
14 public:
15 void setup() override;
16 void loop() override;
17 void dump_config() override;
19
30
31 protected:
33 static constexpr uint32_t STATUS_POLL_INTERVAL_ID = 1;
34 static constexpr uint32_t NETWORK_STATUS_INTERVAL_MS = 500;
35 static constexpr uint32_t POLL_INTERVAL_MS = 5000;
36 static constexpr uint32_t RESPONSE_TIMEOUT_MS = 5000; // a polled or controlled reply
37 static constexpr uint32_t NETWORK_ACK_TIMEOUT_MS = 2000; // the CONFIRM of a network status
38 static constexpr uint32_t NETWORK_REFRESH_MS = 30000; // resend the network status this often
39 static constexpr uint32_t CONTROL_STATUS_MAX_AGE_MS = 15000; // a control needs a status this fresh
40 static constexpr uint32_t FRAME_GAP_MS = 300; // silence that ends a partial frame
41 static constexpr uint8_t POLL_CYCLE = 12; // version and id are re-read once per cycle
42 static constexpr uint8_t MAX_BYTES_PER_LOOP = 255;
43 static constexpr uint8_t MIN_TARGET_TEMPERATURE = 35;
44 static constexpr uint8_t MAX_TARGET_TEMPERATURE = 75;
45 static constexpr uint8_t NETWORK_READY = 0x07;
46 static constexpr uint8_t NETWORK_NOT_READY = 0x05;
47
48 // The link carries one request at a time; this is the one whose answer is outstanding.
50
51 void control(const water_heater::WaterHeaterCall &call) override;
53 void check_timeouts_(uint32_t now);
54 void send_pending_(uint32_t now);
55 void read_frames_(uint32_t now);
56 void poll_status_();
58 void send_frame_(water_heater_protocol::FrameType type, const uint8_t *payload = nullptr, size_t size = 0);
59 void send_request_(uint32_t now, Awaiting kind, water_heater_protocol::FrameType type, const uint8_t *payload,
60 size_t size, water_heater_protocol::FrameType expected);
62 void process_frame_();
66
83 std::array<water_heater_protocol::Command, 4> commands_{}; // power, to Normal, mode, temperature at most
88 uint8_t command_count_{0};
89 uint8_t command_index_{0};
90 uint8_t poll_stage_{0};
91 bool network_pending_{true};
92 bool have_status_{false};
93 bool pending_off_{false};
94};
95
96} // namespace esphome::haier_water_heater
Base class for all binary_sensor-type classes.
water_heater::WaterHeaterCallInternal make_call() override
void handle_frame_type_(water_heater_protocol::FrameType type)
static constexpr uint32_t NETWORK_STATUS_INTERVAL_ID
binary_sensor::BinarySensor * communication_sensor_
void set_heating_sensor(binary_sensor::BinarySensor *value)
void set_mode_sensor(text_sensor::TextSensor *value)
static 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_
binary_sensor::BinarySensor * heating_sensor_
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)
binary_sensor::BinarySensor * power_sensor_
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 set_power_sensor(binary_sensor::BinarySensor *value)
void confirm_control_(const water_heater_protocol::Status &status)
static constexpr uint32_t NETWORK_STATUS_INTERVAL_MS
void set_available_water_sensor(sensor::Sensor *value)
void set_communication_sensor(binary_sensor::BinarySensor *value)
void set_primary_temperature_sensor(sensor::Sensor *value)
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_
void set_secondary_temperature_sensor(sensor::Sensor *value)
void set_target_temperature_sensor(sensor::Sensor *value)
void set_estimated_heating_time_sensor(sensor::Sensor *value)
Base-class for all sensors.
Definition sensor.h:47
uint8_t type
uint16_t size
Definition helpers.cpp:34
static void uint32_t