ESPHome 2026.11.0-dev
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();
93 void set_setting(AirtonSetting setting, bool state) {
94 const bool changed = setting == AirtonSetting::AIRTON_SETTING_DISPLAY ? this->set_display_state(state)
95 : this->set_sleep_mode_state(state);
96 if (changed)
97 this->send_settings();
98 }
99
100#ifdef USE_SWITCH
103#endif
104#ifdef USE_SELECT
106#endif
107
108 protected:
109 void publish_settings_();
110 void save_settings_();
111 void sync_swing_mode_();
112 bool sleep_mode_allowed_() const;
113
114 void transmit_state() override;
115 uint8_t operation_mode_();
116 uint8_t fan_speed_();
117 uint8_t temperature_();
118 uint8_t operation_settings_();
119
120 bool on_receive(remote_base::RemoteReceiveData data) override;
121 void parse_state_frame_(const uint8_t *frame);
122
123#ifdef USE_SWITCH
126#endif
127#ifdef USE_SELECT
129#endif
131 // The unit's own defaults: display lit, no sleep mode, flap still
133 // The last mode sent, so turning off repeats it with the power bit cleared
134 uint8_t previous_mode_{0};
135};
136
137} // namespace esphome::airton
bool set_display_state(bool state)
Definition airton.cpp:69
switch_::Switch * display_switch_
Definition airton.h:125
void set_display_switch(switch_::Switch *sw)
Definition airton.h:102
void set_setting(AirtonSetting setting, bool state)
Definition airton.h:93
void set_sleep_mode_switch(switch_::Switch *sw)
Definition airton.h:101
bool sleep_mode_allowed_() const
Definition airton.cpp:49
void control(const climate::ClimateCall &call) override
Definition airton.cpp:101
bool set_sleep_mode_state(bool state)
Definition airton.cpp:55
void transmit_state() override
Definition airton.cpp:112
void parse_state_frame_(const uint8_t *frame)
Definition airton.cpp:222
void set_vertical_direction_select(select::Select *sel)
Definition airton.h:105
void set_default_vertical_direction(VerticalDirection direction)
Definition airton.h:84
select::Select * vertical_direction_select_
Definition airton.h:128
bool set_vertical_direction_state(VerticalDirection direction)
Definition airton.cpp:82
switch_::Switch * sleep_mode_switch_
Definition airton.h:124
ESPPreferenceObject settings_pref_
Definition airton.h:130
bool on_receive(remote_base::RemoteReceiveData data) override
Definition airton.cpp:282
ClimateIR(float minimum_temperature, float maximum_temperature, float temperature_step=1.0f, bool supports_dry=false, bool supports_fan_only=false, climate::ClimateFanModeMask fan_modes=climate::ClimateFanModeMask(), climate::ClimateSwingModeMask swing_modes=climate::ClimateSwingModeMask(), climate::ClimatePresetMask presets=climate::ClimatePresetMask())
Definition climate_ir.h:25
Base-class for all selects.
Definition select.h:28
Base class for all switches.
Definition switch.h:43
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