14static constexpr uint32_t ECHO_WINDOW_MS = 1000;
20 climate_ir::ClimateIR::setup();
27 climate_ir::ClimateIR::dump_config();
28 ESP_LOGCONFIG(TAG,
" Model: %s",
29 LOG_STR_ARG(ModelStrings::get_log_str(
static_cast<uint8_t
>(this->
model_), ModelStrings::LAST_INDEX)));
33 if (index > VANE_V_LOWEST) {
34 ESP_LOGW(TAG,
"Vane position %u out of range",
static_cast<unsigned>(index));
61 if (this->vane_select_ ==
nullptr)
63 const uint8_t vane = this->
vane_v_();
64 const size_t index = vane == VANE_V_AUTO ? 0 : vane;
65 if (this->vane_select_->active_index().value_or(SIZE_MAX) != index)
66 this->vane_select_->publish_state(index);
72 if (
call.has_custom_fan_mode()) {
74 }
else if (
call.get_fan_mode().has_value()) {
84 }
else if (in_maintenance &&
85 (
call.get_mode().has_value() ||
call.get_target_temperature().has_value() ||
86 call.get_fan_mode().has_value() ||
call.has_custom_fan_mode() ||
call.get_swing_mode().has_value())) {
102 return FAN_SPEED_LOW;
104 return FAN_SPEED_MEDIUM;
106 return FAN_SPEED_HIGH;
108 return FAN_SPEED_AUTO;
127 switch (this->
mode) {
157 params.
power = power;
162 :
static_cast<uint8_t
>(lroundf(clamp<float>(this->
target_temperature, TEMP_MIN, TEMP_MAX)));
166 uint8_t
state[STATE_LENGTH];
168 memcpy(this->
echo_, state + SECTION1_LENGTH, SECTION2_LENGTH);
172 auto *data = transmit.get_data();
173 data->set_carrier_frequency(CARRIER_FREQUENCY);
175 data->reserve(2 * 3 + STATE_LENGTH * 16 + 1);
177 data->item(HEADER_MARK, HEADER_SPACE);
178 data->item_bytes<BIT_TIMINGS>(
state, SECTION1_LENGTH);
179 data->item(BIT_MARK, SECTION_GAP);
180 data->item(HEADER_MARK, HEADER_SPACE);
181 data->item_bytes<BIT_TIMINGS>(
state + SECTION1_LENGTH, SECTION2_LENGTH);
182 data->mark(BIT_MARK);
189 uint8_t
state[STATE_LENGTH];
196 ESP_LOGD(TAG,
"Received frame is not a valid Panasonic state");
203 memcmp(
state + SECTION1_LENGTH, this->
echo_, SECTION2_LENGTH) == 0) {
204 ESP_LOGD(TAG,
"Ignoring the echo of our own frame");
214 bool power = params.
power;
226 switch (params.
mode) {
247 const bool maintenance = params.
temperature < TEMP_MIN;
260 case FAN_SPEED_MEDIUM:
276 if (params.
vane_v == VANE_V_AUTO) {
278 }
else if (params.
vane_v >= VANE_V_HIGHEST && params.
vane_v <= VANE_V_LOWEST) {
282 ESP_LOGV(TAG,
"Ignoring vane value %u", params.
vane_v);
This class is used to encode all control actions on a climate device.
const optional< ClimatePreset > & get_preset() const
StringRef get_custom_fan_mode() const
ClimateMode mode
The active mode of the climate device.
optional< ClimateFanMode > fan_mode
The active fan mode of the climate device.
float target_temperature
The target temperature of the climate device.
ClimateSwingMode swing_mode
The active swing mode of the climate device.
bool set_fan_mode_(ClimateFanMode mode)
Set fan mode. Reset custom fan mode. Return true if fan mode has been changed.
void clear_custom_fan_mode_()
Clear custom fan mode.
virtual void control(const ClimateCall &call)=0
Control the climate device, this is a virtual method that each climate integration must implement.
void publish_state()
Publish the state of the climate device, to be called from integrations.
bool has_custom_fan_mode() const
Check if a custom fan mode is currently active.
optional< ClimatePreset > preset
The active preset of the climate device.
bool set_custom_fan_mode_(const char *mode)
Set custom fan mode. Reset primary fan mode. Return true if fan mode has been changed.
StringRef get_custom_fan_mode() const
Get the active custom fan mode (read-only access). Returns StringRef.
void control(const climate::ClimateCall &call) override
Override control to change settings of the climate device.
uint8_t fan_speed_() const
uint8_t echo_[SECTION2_LENGTH]
void apply_received_(const FrameParams ¶ms)
bool on_receive(remote_base::RemoteReceiveData data) override
Handle received IR buffer.
void set_vane_position(size_t index)
Set the vertical vane from the select: 0 is auto (swing vertical), 1 (highest) to 5 (lowest) are fixe...
void dump_config() override
SUB_SELECT(vane) protected void transmit_state() override
Transmit via IR the state of this climate controller.
RemoteTransmitterBase * transmitter_
@ CLIMATE_PRESET_NONE
No preset is active.
@ CLIMATE_PRESET_AWAY
Device is in away preset.
@ CLIMATE_SWING_OFF
The swing mode is set to Off.
@ CLIMATE_SWING_VERTICAL
The fan mode is set to Vertical.
@ CLIMATE_MODE_DRY
The climate device is set to dry/humidity mode.
@ CLIMATE_MODE_FAN_ONLY
The climate device only has the fan enabled, no heating or cooling is taking place.
@ CLIMATE_MODE_HEAT
The climate device is set to heat to reach the target temperature.
@ CLIMATE_MODE_COOL
The climate device is set to cool to reach the target temperature.
@ CLIMATE_MODE_HEAT_COOL
The climate device is set to heat/cool to reach the target temperature.
@ CLIMATE_MODE_OFF
The climate device is off.
@ 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.
void encode_frame(const FrameParams &p, uint8_t *state)
Encodes p as is: the temperature is not clamped, except that fan only mode always sends 27 C.
bool decode_frame(const uint8_t *state, FrameParams &p)
Decode a state. Returns false if the state doesn't look like a valid Panasonic A/C state.
ESPHOME_LOG_TAG(TAG, "panasonic_ir.climate")
PROGMEM_STRING_TABLE(ModelStrings, "DKE", "JKE", "LKE", "NKE", "CKP", "RKR", "PKE")
bool read_state(remote_base::RemoteReceiveData &data, uint8_t *state)
Reads a state from a received capture.
uint32_t IRAM_ATTR HOT millis()