ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
ras_25j2kvsg_nd.h
Go to the documentation of this file.
1#pragma once
2
4
5#ifdef USE_TOSHIBA_RAS_25J2KVSG_ND
6
8#include "toshiba.h"
9#ifdef USE_SELECT
11#endif
12
13namespace esphome::toshiba {
14
15static constexpr float TOSHIBA_RAS_25J2KVSG_ND_FROST_TEMP_C_MIN = 5.0f;
16static constexpr float TOSHIBA_RAS_25J2KVSG_ND_FROST_TEMP_C_MAX = 13.0f;
17
20 public:
21 static constexpr uint32_t POWER_SELECTION_RESTORE_VERSION = 0x5371E24D;
22
24
25 void setup() override;
26 void step_vane();
27 void set_power_selection(size_t index);
28#ifdef USE_SELECT
29 SUB_SELECT(power_selection)
30#endif
31
32 protected:
33 enum class ToshibaPreset : uint8_t {
34 TOSHIBA_PRESET_NONE,
35 TOSHIBA_PRESET_BOOST,
36 TOSHIBA_PRESET_ECO,
37 TOSHIBA_PRESET_FIREPLACE_1,
38 TOSHIBA_PRESET_FIREPLACE_2,
39 TOSHIBA_PRESET_FROST_PROTECTION,
40 TOSHIBA_PRESET_HADA_CARE,
41 TOSHIBA_PRESET_SLEEP_1H,
42 TOSHIBA_PRESET_SLEEP_3H,
43 TOSHIBA_PRESET_SLEEP_5H,
44 TOSHIBA_PRESET_SLEEP_9H,
45 };
46 // In the order of the select's options; 75% and 50% are also their byte 7 power bits.
55
56 static bool is_heating_preset(ToshibaPreset preset) {
57 return preset >= ToshibaPreset::TOSHIBA_PRESET_FIREPLACE_1 &&
58 preset <= ToshibaPreset::TOSHIBA_PRESET_FROST_PROTECTION;
59 }
60 static bool is_sleep_preset(ToshibaPreset preset) { return preset >= ToshibaPreset::TOSHIBA_PRESET_SLEEP_1H; }
64 static ToshibaPreset custom_preset_at(size_t index) {
65 return static_cast<ToshibaPreset>(index + static_cast<uint8_t>(ToshibaPreset::TOSHIBA_PRESET_FIREPLACE_1));
66 }
67 static size_t custom_preset_index(ToshibaPreset preset) {
68 return static_cast<uint8_t>(preset) - static_cast<uint8_t>(ToshibaPreset::TOSHIBA_PRESET_FIREPLACE_1);
69 }
71 static ToshibaPreset preset_from_custom(const char *custom_preset);
72 static bool power_preset_supported(ToshibaPowerSelection power, ToshibaPreset preset);
73 // Validates a 9 to 12 byte state frame and reads its preset and power selection.
74 static bool parse_state(const uint8_t *message, uint8_t length, ToshibaPreset &preset, ToshibaPowerSelection &power);
75
76 void control(const climate::ClimateCall &call) override;
77 void transmit_state() override;
79 // control() enforces the separate normal range.
80 float temperature_min() override { return TOSHIBA_RAS_25J2KVSG_ND_FROST_TEMP_C_MIN; }
83
84 void transmit_frame_(ToshibaPreset preset);
85 void transmit_motion_(uint8_t command, uint8_t repeat);
86 void encode_motion_(remote_base::RemoteTransmitData *data, uint8_t command, uint8_t repeat);
88 bool receive_frame_(const uint8_t *message, uint8_t length);
89 bool receive_motion_(uint8_t command);
90 ToshibaPreset toshiba_preset_() const;
91 void apply_toshiba_preset_(ToshibaPreset preset);
92 // Saves what leaving the preset restores; call before the target and fan change.
93 void enter_preset_(ToshibaPreset previous, ToshibaPreset preset);
94 uint8_t fan_code_() const;
95 void apply_fan_code_(uint8_t code);
96 // Returns true when the selection changed.
99
101 // millis() until which a received SWING is an echo of our own send
103 // FNV-1a hash and millis() of the last applied frame, to skip its repeated copy
106 // The target to return to when frost protection ends
109 uint8_t sleep_fan_{0};
110};
111
112} // namespace esphome::toshiba
113
114#endif // USE_TOSHIBA_RAS_25J2KVSG_ND
This class is used to encode all control actions on a climate device.
Definition climate.h:31
optional< ClimatePreset > preset
The active preset of the climate device.
Definition climate.h:314
void set_model(Model model)
Definition toshiba.h:62
RAS-25J2KVSG-ND, driven like its WH-TA15PE remote.
void transmit_motion_(uint8_t command, uint8_t repeat)
void perform_(remote_base::RemoteTransmitterBase::TransmitCall &transmit, bool swing)
static ToshibaPreset custom_preset_at(size_t index)
bool on_receive(remote_base::RemoteReceiveData data) override
bool store_power_selection_(ToshibaPowerSelection power)
static bool power_preset_supported(ToshibaPowerSelection power, ToshibaPreset preset)
static bool is_sleep_preset(ToshibaPreset preset)
static bool parse_state(const uint8_t *message, uint8_t length, ToshibaPreset &preset, ToshibaPowerSelection &power)
bool receive_frame_(const uint8_t *message, uint8_t length)
void sanitize_restore_state(climate::ClimateDeviceRestoreState &restore) override
void enter_preset_(ToshibaPreset previous, ToshibaPreset preset)
static ToshibaPreset preset_from_climate(climate::ClimatePreset preset)
static bool is_silent(ToshibaPowerSelection power)
static constexpr uint32_t POWER_SELECTION_RESTORE_VERSION
static size_t custom_preset_index(ToshibaPreset preset)
void encode_motion_(remote_base::RemoteTransmitData *data, uint8_t command, uint8_t repeat)
void control(const climate::ClimateCall &call) override
static ToshibaPreset preset_from_custom(const char *custom_preset)
static bool is_heating_preset(ToshibaPreset preset)
uint8_t custom_preset
Definition climate.h:9
const LogString * message
Definition component.cpp:35
ClimatePreset
Enum for all preset modes NOTE: If adding values, update ClimatePresetMask in climate_traits....
@ MODEL_RAS_25J2KVSG_ND
Definition toshiba.h:41
static void uint32_t
Struct used to save the state of the climate device in restore memory.
Definition climate.h:149