14static const uint8_t FRAME_TEMPLATE[
MISTRAL_FRAME_SIZE] PROGMEM = {0x56, 0x00, 0x08, 0x00, 0x00, 0x00,
15 0x00, 0x00, 0xE8, 0x00, 0x60, 0x00};
16static const uint8_t FIXED_BYTES[] PROGMEM = {0, 2, 7, 8, 9, 10};
17static const uint8_t CHECKSUM_BYTES[] PROGMEM = {1, 3, 4, 5, 6, 8};
29static const ModeCode MODES[] PROGMEM = {
42static const FanCode FANS[]
PROGMEM = {
49template<
typename T>
static T load_entry(
const T &slot) {
55template<
typename T,
size_t N,
typename Pred>
static optional<T> find_entry(
const T (&table)[N], Pred pred) {
56 for (
const T &slot : table) {
57 T entry = load_entry(slot);
64static uint8_t compute_checksum(
const uint8_t *frame) {
66 for (
const uint8_t &idx : CHECKSUM_BYTES)
71static bool is_valid_frame(
const uint8_t *frame) {
72 for (
const uint8_t &slot : FIXED_BYTES) {
77 return frame[11] == compute_checksum(frame);
81 const auto mode = find_entry(MODES, [
this](
const ModeCode &
m) {
return m.mode == this->
mode; });
84 find_entry(FANS, [
fan_mode](
const FanCode &f) {
return f.fan ==
fan_mode; }).value_or(load_entry(FANS[0]));
94 frame[11] = compute_checksum(frame);
106 const uint8_t *frame = aeha->data.data();
107 if (!is_valid_frame(frame))
119 const auto mode = find_entry(MODES, [frame](
const ModeCode &
m) {
return m.code == frame[4]; });
120 const auto fan = find_entry(FANS, [frame](
const FanCode &f) {
return f.byte1 == frame[1] && f.byte6 == frame[6]; });
121 if (!
mode.has_value() || !fan.has_value())
129 ESP_LOGV(TAG,
"Received Mistral frame: mode=%d temp=%.0f fan=%d",
static_cast<int>(this->
mode),
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.
void publish_state()
Publish the state of the climate device, to be called from integrations.
bool on_receive(remote_base::RemoteReceiveData data) override
void transmit_state() override
optional< AEHAData > decode(RemoteReceiveData src)
void encode(RemoteTransmitData *dst, const AEHAData &data)
RemoteTransmitterBase * transmitter_
constexpr float BME680_GAS_LOOKUP_TABLE_1[16] PROGMEM
ClimateMode
Enum for all modes a climate device can be in.
@ 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.
ClimateFanMode
NOTE: If adding values, update ClimateFanModeMask in climate_traits.h to use the new last value.
@ 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.
constexpr uint8_t MISTRAL_POWER_OFF
ESPHOME_LOG_TAG(TAG, "mistral_ir.climate")
constexpr uint8_t MISTRAL_TEMP_OFFSET
constexpr size_t MISTRAL_FRAME_SIZE
constexpr uint8_t MISTRAL_TEMP_MAX
constexpr uint8_t MISTRAL_POWER_ON
constexpr uint8_t MISTRAL_TEMP_MIN
constexpr uint8_t MISTRAL_MODE_AUTO
constexpr uint16_t MISTRAL_ADDRESS
void progmem_memcpy(void *dst, const void *src, size_t len)
uint8_t reverse_bits(uint8_t x)
Reverse the order of 8 bits.
uint8_t progmem_read_byte(const uint8_t *addr)