ESPHome 2026.11.0b6
Loading...
Searching...
No Matches
airton_serial_climate.h
Go to the documentation of this file.
1#pragma once
2
3#include <array>
4#include <cstddef>
5#include <cstdint>
6
10
11#ifdef USE_SENSOR
13#endif
14#ifdef USE_SWITCH
16#endif
17
18namespace esphome::airton_serial {
19
20// Bits of the settings byte, one per switch.
21static constexpr uint8_t FLAG_DISPLAY = 0x80;
22static constexpr uint8_t FLAG_IONIZER = 0x40;
23static constexpr uint8_t FLAG_HEALTH = 0x10;
24static constexpr uint8_t FLAG_SLEEP = 0x02;
25static constexpr uint8_t FLAG_ECO = 0x01;
26
27static constexpr uint8_t MAX_FRAME_LEN = 64;
28
32class AirtonSerialClimate final : public uart::UARTDevice, public climate::Climate, public Component {
33 public:
35
36 void setup() override;
37 void loop() override;
38 void dump_config() override;
39
41 void control(const climate::ClimateCall &call) override;
42
44 bool set_flag(uint8_t flag, bool state);
45
46#ifdef USE_SWITCH
47 SUB_SWITCH(display)
48 SUB_SWITCH(ionizer)
49 SUB_SWITCH(sleep)
50 SUB_SWITCH(eco)
51 SUB_SWITCH(health)
52#endif
53#ifdef USE_SENSOR
54 SUB_SENSOR_WITH_DEDUP(total_usage_time, uint16_t)
55 SUB_SENSOR_WITH_DEDUP(revision, uint16_t)
56#endif
57
58 protected:
59 void send_a5_();
60 void send_ab_();
61 bool can_send_command_();
62 void send_command_();
63 void write_frame_(uint8_t *frame, size_t len);
64 void handle_byte_(uint8_t byte);
65 void drop_first_byte_();
66 void scan_buffer_();
67 void handle_frame_(const uint8_t *data, size_t len);
68 void handle_a3_(const uint8_t *data);
69 void handle_ac_(const uint8_t *data);
70 void publish_settings_();
71
72 std::array<uint8_t, MAX_FRAME_LEN> rx_buffer_;
73 uint8_t rx_pos_{0};
74 uint8_t flags_{FLAG_DISPLAY};
75 bool state_received_{false};
76 uint8_t swing_{0}; // Raw swing byte
77 uint8_t mode_bits_{0}; // Mode bits, kept while the unit is off
78 uint8_t fan_raw_{0}; // Fan nibble last reported or sent, super bit included
79 bool fahrenheit_{false};
81};
82
83} // namespace esphome::airton_serial
void control(const climate::ClimateCall &call) override
uint16_t SUB_SENSOR_WITH_DEDUP(revision, uint16_t) protected void send_ab_()
std::array< uint8_t, MAX_FRAME_LEN > rx_buffer_
bool set_flag(uint8_t flag, bool state)
Set or clear one FLAG_* bit and send it to the unit; false until the unit has reported its state.
SUB_SWITCH(display) SUB_SWITCH(ionizer) SUB_SWITCH(sleep) SUB_SWITCH(eco) SUB_SWITCH(health) SUB_SENSOR_WITH_DEDUP(total_usage_time
void handle_frame_(const uint8_t *data, size_t len)
This class is used to encode all control actions on a climate device.
Definition climate.h:31
ClimateDevice - This is the base class for all climate integrations.
Definition climate.h:192
bool state
Definition fan.h:2
const void size_t len
Definition hal.h:68
static void uint32_t