ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
pd_pioneer_ir.cpp
Go to the documentation of this file.
1#include "pd_pioneer_ir.h"
2#include "esphome/core/log.h"
3
5
6ESPHOME_LOG_TAG(TAG, "pd_pioneer_ir");
7
12
14 ControlData data;
15 data.set_mode(this->mode);
17 data.set_temp(this->target_temperature);
19 data.set_swing_mode(this->swing_mode);
20 // ECO shares the power byte, so it must not undo an off command
22 data.finalize();
23 // The remote sends the two bursts as separate transmissions
26}
27
29 auto frame = remote_base::PDPioneerProtocol().decode(data);
30 if (!frame.has_value())
31 return false;
32 if (frame->is_odd_burst()) {
34 return false;
35 }
36 // decode() only returns odd or even bursts; a mode byte this remote never sends is another device's frame
37 const optional<climate::ClimateMode> decoded = ControlData::get_mode(*frame);
38 if (!decoded.has_value())
39 return false;
40 // An auto-mode frame from the remote must not publish HEAT_COOL when the traits leave it out
41 if (this->get_traits().supports_mode(*decoded)) {
42 this->mode = *decoded;
43 } else {
44 ESP_LOGD(TAG, "Received mode %s is not enabled, keeping the current mode",
45 LOG_STR_ARG(climate::climate_mode_to_string(*decoded)));
46 }
47 // Off and fan-only bursts carry no target temperature
48 if (*decoded != climate::CLIMATE_MODE_OFF && *decoded != climate::CLIMATE_MODE_FAN_ONLY)
50 this->fan_mode = ControlData::get_fan_mode(*frame);
52 // A missed odd burst must not carry this command's horizontal swing into the next one
53 this->rx_horizontal_swing_ = false;
55 this->publish_state();
56 return true;
57}
58
59} // namespace esphome::pd_pioneer_ir
ClimateMode mode
The active mode of the climate device.
Definition climate.h:304
optional< ClimateFanMode > fan_mode
The active fan mode of the climate device.
Definition climate.h:298
ClimateTraits get_traits()
Get the traits of this climate device with all overrides applied.
Definition climate.cpp:479
float target_temperature
The target temperature of the climate device.
Definition climate.h:285
ClimateSwingMode swing_mode
The active swing mode of the climate device.
Definition climate.h:310
void publish_state()
Publish the state of the climate device, to be called from integrations.
Definition climate.cpp:429
optional< ClimatePreset > preset
The active preset of the climate device.
Definition climate.h:301
static optional< ClimateMode > get_mode(const PDPioneerData &even)
Empty for a mode byte this remote does not use.
static float get_temp(const PDPioneerData &even)
Clamped to the set point range, so a frame from a sibling remote cannot publish an impossible value.
void set_swing_mode(climate::ClimateSwingMode mode)
static bool get_horizontal_swing(const PDPioneerData &odd)
Only the odd burst carries horizontal swing; the even burst carries vertical swing.
static ClimateFanMode get_fan_mode(const PDPioneerData &even)
void finalize()
Write the fan and swing positions, which share bytes, then the checksums.
const PDPioneerData & even() const
static bool get_eco(const PDPioneerData &even)
static climate::ClimateSwingMode get_swing_mode(const PDPioneerData &even, bool horizontal)
const PDPioneerData & odd() const
void set_fan_mode(ClimateFanMode mode)
bool on_receive(remote_base::RemoteReceiveData data) override
optional< PDPioneerData > decode(RemoteReceiveData src)
void transmit_(const typename Protocol::ProtocolData &data, uint32_t send_times=1, uint32_t send_wait=0)
@ CLIMATE_PRESET_NONE
No preset is active.
@ CLIMATE_PRESET_ECO
Device is running an energy-saving preset.
@ CLIMATE_MODE_FAN_ONLY
The climate device only has the fan enabled, no heating or cooling is taking place.
@ CLIMATE_MODE_OFF
The climate device is off.
const LogString * climate_mode_to_string(ClimateMode mode)
Convert the given ClimateMode to a human-readable string.
@ CLIMATE_FAN_AUTO
The fan mode is set to Auto.
ESPHOME_LOG_TAG(TAG, "pd_pioneer_ir")