mirror of
https://github.com/GrKoR/esphome_aux_ac_component.git
synced 2025-12-31 21:59:31 +03:00
Compare commits
3 Commits
5a165d3a3d
...
v.0.3.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
efa0991dd0 | ||
|
|
2e0c421c9f | ||
|
|
53414d8ab4 |
@@ -4,183 +4,238 @@
|
|||||||
#include "esphome/core/automation.h"
|
#include "esphome/core/automation.h"
|
||||||
#include "esphome/core/component.h"
|
#include "esphome/core/component.h"
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome
|
||||||
namespace aux_ac {
|
{
|
||||||
|
namespace aux_ac
|
||||||
|
{
|
||||||
|
|
||||||
// **************************************** DISPLAY ACTIONS ****************************************
|
// **************************************** DISPLAY ACTIONS ****************************************
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
class AirConDisplayOffAction : public Action<Ts...> {
|
class AirConDisplayOffAction : public Action<Ts...>
|
||||||
public:
|
{
|
||||||
explicit AirConDisplayOffAction(AirCon *ac) : ac_(ac) {}
|
public:
|
||||||
|
explicit AirConDisplayOffAction(AirCon *ac) : ac_(ac) {}
|
||||||
|
|
||||||
void play(Ts... x) override { this->ac_->displayOffSequence(); }
|
void play(const Ts &...x) override
|
||||||
|
{
|
||||||
|
this->ac_->displayOffSequence();
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
AirCon *ac_;
|
AirCon *ac_;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
class AirConDisplayOnAction : public Action<Ts...> {
|
class AirConDisplayOnAction : public Action<Ts...>
|
||||||
public:
|
{
|
||||||
explicit AirConDisplayOnAction(AirCon *ac) : ac_(ac) {}
|
public:
|
||||||
|
explicit AirConDisplayOnAction(AirCon *ac) : ac_(ac) {}
|
||||||
|
|
||||||
void play(Ts... x) override { this->ac_->displayOnSequence(); }
|
void play(const Ts &...x) override
|
||||||
|
{
|
||||||
|
this->ac_->displayOnSequence();
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
AirCon *ac_;
|
AirCon *ac_;
|
||||||
};
|
};
|
||||||
|
|
||||||
// **************************************** VERTICAL LOUVER ACTIONS ****************************************
|
// **************************************** VERTICAL LOUVER ACTIONS ****************************************
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
class AirConVLouverSwingAction : public Action<Ts...> {
|
class AirConVLouverSwingAction : public Action<Ts...>
|
||||||
public:
|
{
|
||||||
explicit AirConVLouverSwingAction(AirCon *ac) : ac_(ac) {}
|
public:
|
||||||
|
explicit AirConVLouverSwingAction(AirCon *ac) : ac_(ac) {}
|
||||||
|
|
||||||
void play(Ts... x) override { this->ac_->setVLouverSwingSequence(); }
|
void play(const Ts &...x) override
|
||||||
|
{
|
||||||
|
this->ac_->setVLouverSwingSequence();
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
AirCon *ac_;
|
AirCon *ac_;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
class AirConVLouverStopAction : public Action<Ts...> {
|
class AirConVLouverStopAction : public Action<Ts...>
|
||||||
public:
|
{
|
||||||
explicit AirConVLouverStopAction(AirCon *ac) : ac_(ac) {}
|
public:
|
||||||
|
explicit AirConVLouverStopAction(AirCon *ac) : ac_(ac) {}
|
||||||
|
|
||||||
void play(Ts... x) override { this->ac_->setVLouverStopSequence(); }
|
void play(const Ts &...x) override
|
||||||
|
{
|
||||||
|
this->ac_->setVLouverStopSequence();
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
AirCon *ac_;
|
AirCon *ac_;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
class AirConVLouverTopAction : public Action<Ts...> {
|
class AirConVLouverTopAction : public Action<Ts...>
|
||||||
public:
|
{
|
||||||
explicit AirConVLouverTopAction(AirCon *ac) : ac_(ac) {}
|
public:
|
||||||
|
explicit AirConVLouverTopAction(AirCon *ac) : ac_(ac) {}
|
||||||
|
|
||||||
void play(Ts... x) override { this->ac_->setVLouverTopSequence(); }
|
void play(const Ts &...x) override
|
||||||
|
{
|
||||||
|
this->ac_->setVLouverTopSequence();
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
AirCon *ac_;
|
AirCon *ac_;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
class AirConVLouverMiddleAboveAction : public Action<Ts...> {
|
class AirConVLouverMiddleAboveAction : public Action<Ts...>
|
||||||
public:
|
{
|
||||||
explicit AirConVLouverMiddleAboveAction(AirCon *ac) : ac_(ac) {}
|
public:
|
||||||
|
explicit AirConVLouverMiddleAboveAction(AirCon *ac) : ac_(ac) {}
|
||||||
|
|
||||||
void play(Ts... x) override { this->ac_->setVLouverMiddleAboveSequence(); }
|
void play(const Ts &...x) override
|
||||||
|
{
|
||||||
|
this->ac_->setVLouverMiddleAboveSequence();
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
AirCon *ac_;
|
AirCon *ac_;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
class AirConVLouverMiddleAction : public Action<Ts...> {
|
class AirConVLouverMiddleAction : public Action<Ts...>
|
||||||
public:
|
{
|
||||||
explicit AirConVLouverMiddleAction(AirCon *ac) : ac_(ac) {}
|
public:
|
||||||
|
explicit AirConVLouverMiddleAction(AirCon *ac) : ac_(ac) {}
|
||||||
|
|
||||||
void play(Ts... x) override { this->ac_->setVLouverMiddleSequence(); }
|
void play(const Ts &...x) override
|
||||||
|
{
|
||||||
|
this->ac_->setVLouverMiddleSequence();
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
AirCon *ac_;
|
AirCon *ac_;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
class AirConVLouverMiddleBelowAction : public Action<Ts...> {
|
class AirConVLouverMiddleBelowAction : public Action<Ts...>
|
||||||
public:
|
{
|
||||||
explicit AirConVLouverMiddleBelowAction(AirCon *ac) : ac_(ac) {}
|
public:
|
||||||
|
explicit AirConVLouverMiddleBelowAction(AirCon *ac) : ac_(ac) {}
|
||||||
|
|
||||||
void play(Ts... x) override { this->ac_->setVLouverMiddleBelowSequence(); }
|
void play(const Ts &...x) override
|
||||||
|
{
|
||||||
|
this->ac_->setVLouverMiddleBelowSequence();
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
AirCon *ac_;
|
AirCon *ac_;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
class AirConVLouverBottomAction : public Action<Ts...> {
|
class AirConVLouverBottomAction : public Action<Ts...>
|
||||||
public:
|
{
|
||||||
explicit AirConVLouverBottomAction(AirCon *ac) : ac_(ac) {}
|
public:
|
||||||
|
explicit AirConVLouverBottomAction(AirCon *ac) : ac_(ac) {}
|
||||||
|
|
||||||
void play(Ts... x) override { this->ac_->setVLouverBottomSequence(); }
|
void play(const Ts &...x) override
|
||||||
|
{
|
||||||
|
this->ac_->setVLouverBottomSequence();
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
AirCon *ac_;
|
AirCon *ac_;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
class AirConVLouverSetAction : public Action<Ts...> {
|
class AirConVLouverSetAction : public Action<Ts...>
|
||||||
public:
|
{
|
||||||
AirConVLouverSetAction(AirCon *ac) : ac_(ac) {}
|
public:
|
||||||
TEMPLATABLE_VALUE(uint8_t, value);
|
TEMPLATABLE_VALUE(uint8_t, value);
|
||||||
|
|
||||||
void play(Ts... x) {
|
AirConVLouverSetAction(AirCon *ac) : ac_(ac) {};
|
||||||
vlpos_ = this->value_.value(x...);
|
|
||||||
this->ac_->setVLouverFrontendSequence((ac_vlouver_frontend)vlpos_);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
void play(const Ts &...x) override
|
||||||
AirCon *ac_;
|
{
|
||||||
uint8_t vlpos_;
|
vlpos_ = this->value_.value(x...);
|
||||||
};
|
this->ac_->setVLouverFrontendSequence((ac_vlouver_frontend)vlpos_);
|
||||||
|
};
|
||||||
|
|
||||||
// **************************************** SEND TEST PACKET ACTION ****************************************
|
protected:
|
||||||
template <typename... Ts>
|
AirCon *ac_;
|
||||||
class AirConSendTestPacketAction : public Action<Ts...> {
|
uint8_t vlpos_;
|
||||||
public:
|
};
|
||||||
explicit AirConSendTestPacketAction(AirCon *ac) : ac_(ac) {}
|
|
||||||
void set_data_template(std::function<std::vector<uint8_t>(Ts...)> func) {
|
|
||||||
this->data_func_ = func;
|
|
||||||
this->static_ = false;
|
|
||||||
}
|
|
||||||
void set_data_static(const std::vector<uint8_t> &data) {
|
|
||||||
this->data_static_ = data;
|
|
||||||
this->static_ = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void play(Ts... x) override {
|
// **************************************** SEND TEST PACKET ACTION ****************************************
|
||||||
if (this->static_) {
|
template <typename... Ts>
|
||||||
this->ac_->sendTestPacket(this->data_static_);
|
class AirConSendTestPacketAction : public Action<Ts...>
|
||||||
} else {
|
{
|
||||||
auto val = this->data_func_(x...);
|
public:
|
||||||
this->ac_->sendTestPacket(val);
|
explicit AirConSendTestPacketAction(AirCon *ac) : ac_(ac) {}
|
||||||
}
|
void set_data_template(std::function<std::vector<uint8_t>(Ts...)> func)
|
||||||
}
|
{
|
||||||
|
this->data_func_ = func;
|
||||||
|
this->static_ = false;
|
||||||
|
}
|
||||||
|
void set_data_static(const std::vector<uint8_t> &data)
|
||||||
|
{
|
||||||
|
this->data_static_ = data;
|
||||||
|
this->static_ = true;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
void play(const Ts &...x) override
|
||||||
AirCon *ac_;
|
{
|
||||||
bool static_{false};
|
if (this->static_)
|
||||||
std::function<std::vector<uint8_t>(Ts...)> data_func_{};
|
{
|
||||||
std::vector<uint8_t> data_static_{};
|
this->ac_->sendTestPacket(this->data_static_);
|
||||||
};
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto val = this->data_func_(x...);
|
||||||
|
this->ac_->sendTestPacket(val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// **************************************** POWER LIMITATION ACTIONS ****************************************
|
protected:
|
||||||
template <typename... Ts>
|
AirCon *ac_;
|
||||||
class AirConPowerLimitationOffAction : public Action<Ts...> {
|
bool static_{false};
|
||||||
public:
|
std::function<std::vector<uint8_t>(Ts...)> data_func_{};
|
||||||
explicit AirConPowerLimitationOffAction(AirCon *ac) : ac_(ac) {}
|
std::vector<uint8_t> data_static_{};
|
||||||
|
};
|
||||||
|
|
||||||
void play(Ts... x) override { this->ac_->powerLimitationOffSequence(); }
|
// **************************************** POWER LIMITATION ACTIONS ****************************************
|
||||||
|
template <typename... Ts>
|
||||||
|
class AirConPowerLimitationOffAction : public Action<Ts...>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit AirConPowerLimitationOffAction(AirCon *ac) : ac_(ac) {}
|
||||||
|
|
||||||
protected:
|
void play(const Ts &...x) override
|
||||||
AirCon *ac_;
|
{
|
||||||
};
|
this->ac_->powerLimitationOffSequence();
|
||||||
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
protected:
|
||||||
class AirConPowerLimitationOnAction : public Action<Ts...> {
|
AirCon *ac_;
|
||||||
public:
|
};
|
||||||
AirConPowerLimitationOnAction(AirCon *ac) : ac_(ac) {}
|
|
||||||
TEMPLATABLE_VALUE(uint8_t, value);
|
|
||||||
|
|
||||||
void play(Ts... x) {
|
template <typename... Ts>
|
||||||
this->pwr_lim_ = this->value_.value(x...);
|
class AirConPowerLimitationOnAction : public Action<Ts...>
|
||||||
this->ac_->powerLimitationOnSequence(this->pwr_lim_);
|
{
|
||||||
}
|
public:
|
||||||
|
TEMPLATABLE_VALUE(uint8_t, value);
|
||||||
|
|
||||||
protected:
|
AirConPowerLimitationOnAction(AirCon *ac) : ac_(ac) {};
|
||||||
AirCon *ac_;
|
|
||||||
uint8_t pwr_lim_;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace aux_ac
|
void play(const Ts &...x) override
|
||||||
} // namespace esphome
|
{
|
||||||
|
this->pwr_lim_ = this->value_.value(x...);
|
||||||
|
this->ac_->powerLimitationOnSequence(this->pwr_lim_);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
AirCon *ac_;
|
||||||
|
uint8_t pwr_lim_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace aux_ac
|
||||||
|
} // namespace esphome
|
||||||
@@ -26,6 +26,7 @@ from esphome.const import (
|
|||||||
DEVICE_CLASS_TEMPERATURE,
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
DEVICE_CLASS_POWER_FACTOR,
|
DEVICE_CLASS_POWER_FACTOR,
|
||||||
STATE_CLASS_MEASUREMENT,
|
STATE_CLASS_MEASUREMENT,
|
||||||
|
__version__
|
||||||
)
|
)
|
||||||
from esphome.components.climate import (
|
from esphome.components.climate import (
|
||||||
ClimateMode,
|
ClimateMode,
|
||||||
@@ -127,6 +128,12 @@ AirConPowerLimitationOnAction = aux_ac_ns.class_(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def use_new_api():
|
||||||
|
esphome_current_version = tuple(map(int, __version__.split('.')))
|
||||||
|
esphome_bc_version = tuple(map(int, "2025.11.0".split('.')))
|
||||||
|
return esphome_current_version >= esphome_bc_version
|
||||||
|
|
||||||
|
|
||||||
def validate_packet_timeout(value):
|
def validate_packet_timeout(value):
|
||||||
minV = AC_PACKET_TIMEOUT_MIN
|
minV = AC_PACKET_TIMEOUT_MIN
|
||||||
maxV = AC_PACKET_TIMEOUT_MAX
|
maxV = AC_PACKET_TIMEOUT_MAX
|
||||||
@@ -426,10 +433,20 @@ async def to_code(config):
|
|||||||
cg.add(var.set_supported_swing_modes(config[CONF_SUPPORTED_SWING_MODES]))
|
cg.add(var.set_supported_swing_modes(config[CONF_SUPPORTED_SWING_MODES]))
|
||||||
if CONF_SUPPORTED_PRESETS in config:
|
if CONF_SUPPORTED_PRESETS in config:
|
||||||
cg.add(var.set_supported_presets(config[CONF_SUPPORTED_PRESETS]))
|
cg.add(var.set_supported_presets(config[CONF_SUPPORTED_PRESETS]))
|
||||||
if CONF_CUSTOM_PRESETS in config:
|
if use_new_api():
|
||||||
cg.add(var.set_custom_presets(config[CONF_CUSTOM_PRESETS]))
|
if CONF_CUSTOM_PRESETS in config:
|
||||||
if CONF_CUSTOM_FAN_MODES in config:
|
presets = config[CONF_CUSTOM_PRESETS]
|
||||||
cg.add(var.set_custom_fan_modes(config[CONF_CUSTOM_FAN_MODES]))
|
c_str_presets = [cg.RawExpression(f"aux_ac::Constants::{p}.c_str()") for p in presets]
|
||||||
|
cg.add(var.set_custom_presets(c_str_presets))
|
||||||
|
if CONF_CUSTOM_FAN_MODES in config:
|
||||||
|
fan_modes = config[CONF_CUSTOM_FAN_MODES]
|
||||||
|
c_str_fan_modes = [cg.RawExpression(f"aux_ac::Constants::{p}.c_str()") for p in fan_modes]
|
||||||
|
cg.add(var.set_custom_fan_modes(c_str_fan_modes))
|
||||||
|
else:
|
||||||
|
if CONF_CUSTOM_PRESETS in config:
|
||||||
|
cg.add(var.set_custom_presets(config[CONF_CUSTOM_PRESETS]))
|
||||||
|
if CONF_CUSTOM_FAN_MODES in config:
|
||||||
|
cg.add(var.set_custom_fan_modes(config[CONF_CUSTOM_FAN_MODES]))
|
||||||
|
|
||||||
|
|
||||||
DISPLAY_ACTION_SCHEMA = maybe_simple_id(
|
DISPLAY_ACTION_SCHEMA = maybe_simple_id(
|
||||||
|
|||||||
Reference in New Issue
Block a user