mirror of
https://github.com/esphome/esphome.git
synced 2024-12-02 11:44:13 +01:00
7b9c2d2978
* Added options to control pulse duration on Climate_IR_LG Component. This is usefull as some equipment from LG (Tested in Brazil AC unit) use different pulse durations in their protocol. * Fixed C++ linting issues * Fixed Python linting issues * fixed spaces on parameters linting issue * fixed spacing clint * Removed unused constants * Removed wrong spacing * Changed int to time period in all new fields Changed cv._int to cv.positive_time_period_microseconds in the time definitions for the new options * Fixed the time defaults Time defaults fixed for Climate_IR_LG.
55 lines
2 KiB
C++
55 lines
2 KiB
C++
#pragma once
|
|
|
|
#include "esphome/components/climate_ir/climate_ir.h"
|
|
|
|
namespace esphome {
|
|
namespace climate_ir_lg {
|
|
|
|
// Temperature
|
|
const uint8_t TEMP_MIN = 18; // Celsius
|
|
const uint8_t TEMP_MAX = 30; // Celsius
|
|
|
|
class LgIrClimate : public climate_ir::ClimateIR {
|
|
public:
|
|
LgIrClimate()
|
|
: climate_ir::ClimateIR(TEMP_MIN, TEMP_MAX, 1.0f, true, false,
|
|
{climate::CLIMATE_FAN_AUTO, climate::CLIMATE_FAN_LOW, climate::CLIMATE_FAN_MEDIUM,
|
|
climate::CLIMATE_FAN_HIGH},
|
|
{climate::CLIMATE_SWING_OFF, climate::CLIMATE_SWING_VERTICAL}) {}
|
|
|
|
/// Override control to change settings of the climate device.
|
|
void control(const climate::ClimateCall &call) override {
|
|
send_swing_cmd_ = call.get_swing_mode().has_value();
|
|
// swing resets after unit powered off
|
|
if (call.get_mode().has_value() && *call.get_mode() == climate::CLIMATE_MODE_OFF)
|
|
this->swing_mode = climate::CLIMATE_SWING_OFF;
|
|
climate_ir::ClimateIR::control(call);
|
|
}
|
|
void set_header_high(uint32_t header_high) { this->header_high_ = header_high; }
|
|
void set_header_low(uint32_t header_low) { this->header_low_ = header_low; }
|
|
void set_bit_high(uint32_t bit_high) { this->bit_high_ = bit_high; }
|
|
void set_bit_one_low(uint32_t bit_one_low) { this->bit_one_low_ = bit_one_low; }
|
|
void set_bit_zero_low(uint32_t bit_zero_low) { this->bit_zero_low_ = bit_zero_low; }
|
|
|
|
protected:
|
|
/// Transmit via IR the state of this climate controller.
|
|
void transmit_state() override;
|
|
/// Handle received IR Buffer
|
|
bool on_receive(remote_base::RemoteReceiveData data) override;
|
|
|
|
bool send_swing_cmd_{false};
|
|
|
|
void calc_checksum_(uint32_t &value);
|
|
void transmit_(uint32_t value);
|
|
|
|
uint32_t header_high_;
|
|
uint32_t header_low_;
|
|
uint32_t bit_high_;
|
|
uint32_t bit_one_low_;
|
|
uint32_t bit_zero_low_;
|
|
|
|
climate::ClimateMode mode_before_{climate::CLIMATE_MODE_OFF};
|
|
};
|
|
|
|
} // namespace climate_ir_lg
|
|
} // namespace esphome
|