Files
esphome-dev/esphome/components/midea_ac/midea_climate.h
T
Sergey V. DUDANOV f34c9b33fc Midea climate support (#1328)
* Added support for Midea IoT climate devices via UART interface (USB-dongle)

* Fixed lint checks

* Fixed lint checks

* CODEOWNERS update

* Clang-format

* Clang-format

* Add network device notification message support (show WiFi sign on devices)

* Make wifi_signal_sensor optional component

* Some optimization

* Optimizations and code formatting

* Fixed lint checks

* Fixed lint checks

* Fixed sign error

* Code changes

* Network notify repeat every 10 min

* Added log messages

* Fixed lint checks

* Refactoring: MideaClimate => MideaAC

* Using enums instead literals in Midea states

* Enum changed to be more correct

* Shrink notify frame to 32 bytes

* Fixed lint checks

* Change notify frame appliance type to common broadcast

* Control optimization

* Fixed control error

* Control command now don't reset others uncontrollable properties of device

* Fixed lint checks

* Some optimization

* on_receive callback give const Frame

* Fix control

* Fixes

* Some minor changes

* Fixed lint error

* No dependency from wifi_signal sensor for stretched WiFi icon. New option: stretched_icon instead wifi_signal_id.

* Fix option name

* Added export of outdoor temperature as sensor value

* Fixed lint errors

* Fixed pylint error

* Minor fix

* Fix temperature overflow in some cases

* Added answer on QueryNetwork command from appliance. Now don't wait for ack on 0x0D command.

* Fix lint error

* Added humidity setpoint optional sensor

* Added boolean options 'swing_horizontal' and 'swing_both'

* Added debug frame output

* Added debug frame output

* Fix lints error

* Some debug output optimization

* Fix lint check

* Some code optimization: adding templates

* Fix lint error

* Added sensors device classes

* Python code reformatted with black formatter

* RX frame debug message

RX frame debug message now prints before checking

* Remove CRC check for receiving frames

* Added experimental power usage option

* Added power usage option

* Fixed lint errors

* Major changes. See esp-docs.

* Added tests in test4.yaml

* Added tests in test1.yaml

* Added wifi dependency

* Fix test1.yaml

* Some fix :)

* One more refactoring

* One more refactoring

* One more refactoring
2021-03-17 17:27:50 -03:00

48 lines
1.9 KiB
C++

#pragma once
#include "esphome/core/component.h"
#include "esphome/components/sensor/sensor.h"
#include "esphome/components/midea_dongle/midea_dongle.h"
#include "esphome/components/climate/climate.h"
#include "midea_frame.h"
namespace esphome {
namespace midea_ac {
class MideaAC : public midea_dongle::MideaAppliance, public climate::Climate, public Component {
public:
float get_setup_priority() const override { return setup_priority::LATE; }
void on_frame(const midea_dongle::Frame &frame) override;
void on_update() override;
void setup() override { this->parent_->set_appliance(this); }
void set_midea_dongle_parent(midea_dongle::MideaDongle *parent) { this->parent_ = parent; }
void set_outdoor_temperature_sensor(sensor::Sensor *sensor) { this->outdoor_sensor_ = sensor; }
void set_humidity_setpoint_sensor(sensor::Sensor *sensor) { this->humidity_sensor_ = sensor; }
void set_power_sensor(sensor::Sensor *sensor) { this->power_sensor_ = sensor; }
void set_beeper_feedback(bool state) { this->beeper_feedback_ = state; }
void set_swing_horizontal(bool state) { this->traits_swing_horizontal_ = state; }
void set_swing_both(bool state) { this->traits_swing_both_ = state; }
protected:
/// Override control to change settings of the climate device.
void control(const climate::ClimateCall &call) override;
/// Return the traits of this controller.
climate::ClimateTraits traits() override;
const QueryFrame query_frame_;
const PowerQueryFrame power_frame_;
CommandFrame cmd_frame_;
midea_dongle::MideaDongle *parent_{nullptr};
sensor::Sensor *outdoor_sensor_{nullptr};
sensor::Sensor *humidity_sensor_{nullptr};
sensor::Sensor *power_sensor_{nullptr};
uint8_t request_num_{0};
bool ctrl_request_{false};
bool beeper_feedback_{false};
bool traits_swing_horizontal_{false};
bool traits_swing_both_{false};
};
} // namespace midea_ac
} // namespace esphome