ESPHome 2026.11.0b6
Loading...
Searching...
No Matches
airton.h
Go to the documentation of this file.
1#pragma once
2
6
7#ifdef USE_SWITCH
9#endif
10
11#ifdef USE_SELECT
13#endif
14
15namespace esphome::airton {
16
17// Values for Airton SMVH09B-2A2A3NH IR Controllers
18static constexpr uint8_t AIRTON_TEMP_MIN = 16; // Celsius
19static constexpr uint8_t AIRTON_TEMP_MAX = 31; // Celsius
20static constexpr uint8_t AIRTON_AUTO_MODE_TEMP = 25; // The fixed setpoint the unit uses in auto mode
21
22static constexpr uint8_t AIRTON_MODE_AUTO = 0b000;
23static constexpr uint8_t AIRTON_MODE_COOL = 0b001;
24static constexpr uint8_t AIRTON_MODE_HEAT = 0b100;
25static constexpr uint8_t AIRTON_MODE_DRY = 0b010;
26static constexpr uint8_t AIRTON_MODE_FAN = 0b011;
27
28static constexpr uint8_t AIRTON_FAN_AUTO = 0b000;
29static constexpr uint8_t AIRTON_FAN_1 = 0b001;
30static constexpr uint8_t AIRTON_FAN_2 = 0b010;
31static constexpr uint8_t AIRTON_FAN_3 = 0b011;
32static constexpr uint8_t AIRTON_FAN_4 = 0b100;
33static constexpr uint8_t AIRTON_FAN_5 = 0b101;
34
35static constexpr uint32_t AIRTON_IR_FREQUENCY = 38000;
36static constexpr uint32_t AIRTON_HEADER_MARK = 6630;
37static constexpr uint32_t AIRTON_HEADER_SPACE = 3350;
38static constexpr uint32_t AIRTON_BIT_MARK = 400;
39static constexpr remote_base::BitTimings AIRTON_BIT_TIMINGS{
40 .bit_mark = AIRTON_BIT_MARK, .one_space = 1260, .zero_space = 430};
41static constexpr uint32_t AIRTON_MESSAGE_SPACE = 100000;
42
43static constexpr uint8_t AIRTON_STATE_FRAME_SIZE = 7;
44// Every frame starts with these two bytes
45static constexpr uint8_t AIRTON_HEADER_BYTE0 = 0xD3;
46static constexpr uint8_t AIRTON_HEADER_BYTE1 = 0x11;
47
48// Position of the air outlet flap; the values are the nibble the frame carries and the index
49// of the option in the vertical direction select
59
60// The on/off settings the switch platform exposes
65
66// The settings the unit keeps that the climate state does not carry; saved to flash when they change
72
74 public:
80 void setup() override;
81 void control(const climate::ClimateCall &call) override;
82
83 // The direction the settings start from until a saved one is restored in setup()
85
86 // The setters update the state, publish their entity and save; they return whether anything changed.
87 // A change made here (switch, select, action) is then sent with send_settings(); a frame from the
88 // remote only reports what the unit already did.
89 bool set_sleep_mode_state(bool state);
90 bool set_display_state(bool state);
92 void send_settings();
97 void set_setting(AirtonSetting setting, bool state) {
98 const bool changed = setting == AirtonSetting::AIRTON_SETTING_DISPLAY ? this->set_display_state(state)
99 : this->set_sleep_mode_state(state);
100 if (changed)
101 this->send_settings();
102 }
103
104#ifdef USE_SWITCH
105 SUB_SWITCH(sleep_mode)
106 SUB_SWITCH(display)
107#endif
108#ifdef USE_SELECT
109 SUB_SELECT(vertical_direction)
110#endif
111
112 protected:
113 void publish_settings_();
114 void save_settings_();
115 void sync_swing_mode_();
116 bool sleep_mode_allowed_() const;
117
118 void transmit_state() override;
119 uint8_t operation_mode_();
120 uint8_t fan_speed_();
121 uint8_t temperature_();
122 uint8_t operation_settings_();
123
124 bool on_receive(remote_base::RemoteReceiveData data) override;
125 void parse_state_frame_(const uint8_t *frame);
126
128 // The unit's own defaults: display lit, no sleep mode, flap still
130 // The last mode sent, so turning off repeats it with the power bit cleared
131 uint8_t previous_mode_{0};
132};
133
134} // namespace esphome::airton
bool set_display_state(bool state)
Definition airton.cpp:65
void set_setting(AirtonSetting setting, bool state)
Definition airton.h:97
bool sleep_mode_allowed_() const
Definition airton.cpp:46
void control(const climate::ClimateCall &call) override
Definition airton.cpp:95
bool set_sleep_mode_state(bool state)
Definition airton.cpp:52
void transmit_state() override
Definition airton.cpp:106
void parse_state_frame_(const uint8_t *frame)
Definition airton.cpp:216
void set_default_vertical_direction(VerticalDirection direction)
Definition airton.h:84
bool set_vertical_direction_state(VerticalDirection direction)
Definition airton.cpp:77
SUB_SWITCH(sleep_mode) SUB_SWITCH(display) SUB_SELECT(vertical_direction) protected void save_settings_()
Definition airton.cpp:37
ESPPreferenceObject settings_pref_
Definition airton.h:127
bool on_receive(remote_base::RemoteReceiveData data) override
Definition airton.cpp:276
void control_vertical_direction(VerticalDirection direction)
Definition airton.h:93
FanDirection direction
Definition fan.h:5
bool state
Definition fan.h:2
@ CLIMATE_SWING_OFF
The swing mode is set to Off.
@ CLIMATE_SWING_VERTICAL
The fan mode is set to Vertical.
@ CLIMATE_FAN_MEDIUM
The fan mode is set to Medium.
@ CLIMATE_FAN_AUTO
The fan mode is set to Auto.
@ CLIMATE_FAN_LOW
The fan mode is set to Low.
@ CLIMATE_FAN_HIGH
The fan mode is set to High.
static void uint32_t
VerticalDirection vertical_direction
Definition airton.h:70