mirror of
https://github.com/GrKoR/esphome_aux_ac_component.git
synced 2025-12-31 11:56:22 +03:00
Compare commits
9 Commits
2e0c421c9f
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
36dc1fe15f | ||
|
|
8597e46e3f | ||
|
|
c49bed261d | ||
|
|
babcb8f895 | ||
|
|
0a09ad6642 | ||
|
|
fa0b698afa | ||
|
|
3391368179 | ||
|
|
fc56fb7966 | ||
|
|
efa0991dd0 |
@@ -4,144 +4,192 @@
|
|||||||
#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:
|
public:
|
||||||
explicit AirConDisplayOffAction(AirCon *ac) : ac_(ac) {}
|
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:
|
public:
|
||||||
explicit AirConDisplayOnAction(AirCon *ac) : ac_(ac) {}
|
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:
|
public:
|
||||||
explicit AirConVLouverSwingAction(AirCon *ac) : ac_(ac) {}
|
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:
|
public:
|
||||||
explicit AirConVLouverStopAction(AirCon *ac) : ac_(ac) {}
|
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:
|
public:
|
||||||
explicit AirConVLouverTopAction(AirCon *ac) : ac_(ac) {}
|
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:
|
public:
|
||||||
explicit AirConVLouverMiddleAboveAction(AirCon *ac) : ac_(ac) {}
|
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:
|
public:
|
||||||
explicit AirConVLouverMiddleAction(AirCon *ac) : ac_(ac) {}
|
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:
|
public:
|
||||||
explicit AirConVLouverMiddleBelowAction(AirCon *ac) : ac_(ac) {}
|
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:
|
public:
|
||||||
explicit AirConVLouverBottomAction(AirCon *ac) : ac_(ac) {}
|
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:
|
public:
|
||||||
AirConVLouverSetAction(AirCon *ac) : ac_(ac) {}
|
|
||||||
TEMPLATABLE_VALUE(uint8_t, value);
|
TEMPLATABLE_VALUE(uint8_t, value);
|
||||||
|
|
||||||
void play(Ts... x) {
|
AirConVLouverSetAction(AirCon *ac) : ac_(ac) {};
|
||||||
|
|
||||||
|
void play(const Ts &...x) override
|
||||||
|
{
|
||||||
vlpos_ = this->value_.value(x...);
|
vlpos_ = this->value_.value(x...);
|
||||||
this->ac_->setVLouverFrontendSequence((ac_vlouver_frontend)vlpos_);
|
this->ac_->setVLouverFrontendSequence((ac_vlouver_frontend)vlpos_);
|
||||||
}
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
AirCon *ac_;
|
AirCon *ac_;
|
||||||
uint8_t vlpos_;
|
uint8_t vlpos_;
|
||||||
};
|
};
|
||||||
|
|
||||||
// **************************************** SEND TEST PACKET ACTION ****************************************
|
// **************************************** SEND TEST PACKET ACTION ****************************************
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
class AirConSendTestPacketAction : public Action<Ts...> {
|
class AirConSendTestPacketAction : public Action<Ts...>
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
explicit AirConSendTestPacketAction(AirCon *ac) : ac_(ac) {}
|
explicit AirConSendTestPacketAction(AirCon *ac) : ac_(ac) {}
|
||||||
void set_data_template(std::function<std::vector<uint8_t>(Ts...)> func) {
|
void set_data_template(std::function<std::vector<uint8_t>(Ts...)> func)
|
||||||
|
{
|
||||||
this->data_func_ = func;
|
this->data_func_ = func;
|
||||||
this->static_ = false;
|
this->static_ = false;
|
||||||
}
|
}
|
||||||
void set_data_static(const std::vector<uint8_t> &data) {
|
void set_data_static(const std::vector<uint8_t> &data)
|
||||||
|
{
|
||||||
this->data_static_ = data;
|
this->data_static_ = data;
|
||||||
this->static_ = true;
|
this->static_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void play(Ts... x) override {
|
void play(const Ts &...x) override
|
||||||
if (this->static_) {
|
{
|
||||||
|
if (this->static_)
|
||||||
|
{
|
||||||
this->ac_->sendTestPacket(this->data_static_);
|
this->ac_->sendTestPacket(this->data_static_);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
auto val = this->data_func_(x...);
|
auto val = this->data_func_(x...);
|
||||||
this->ac_->sendTestPacket(val);
|
this->ac_->sendTestPacket(val);
|
||||||
}
|
}
|
||||||
@@ -152,27 +200,34 @@ class AirConSendTestPacketAction : public Action<Ts...> {
|
|||||||
bool static_{false};
|
bool static_{false};
|
||||||
std::function<std::vector<uint8_t>(Ts...)> data_func_{};
|
std::function<std::vector<uint8_t>(Ts...)> data_func_{};
|
||||||
std::vector<uint8_t> data_static_{};
|
std::vector<uint8_t> data_static_{};
|
||||||
};
|
};
|
||||||
|
|
||||||
// **************************************** POWER LIMITATION ACTIONS ****************************************
|
// **************************************** POWER LIMITATION ACTIONS ****************************************
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
class AirConPowerLimitationOffAction : public Action<Ts...> {
|
class AirConPowerLimitationOffAction : public Action<Ts...>
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
explicit AirConPowerLimitationOffAction(AirCon *ac) : ac_(ac) {}
|
explicit AirConPowerLimitationOffAction(AirCon *ac) : ac_(ac) {}
|
||||||
|
|
||||||
void play(Ts... x) override { this->ac_->powerLimitationOffSequence(); }
|
void play(const Ts &...x) override
|
||||||
|
{
|
||||||
|
this->ac_->powerLimitationOffSequence();
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
AirCon *ac_;
|
AirCon *ac_;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
class AirConPowerLimitationOnAction : public Action<Ts...> {
|
class AirConPowerLimitationOnAction : public Action<Ts...>
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
AirConPowerLimitationOnAction(AirCon *ac) : ac_(ac) {}
|
|
||||||
TEMPLATABLE_VALUE(uint8_t, value);
|
TEMPLATABLE_VALUE(uint8_t, value);
|
||||||
|
|
||||||
void play(Ts... x) {
|
AirConPowerLimitationOnAction(AirCon *ac) : ac_(ac) {};
|
||||||
|
|
||||||
|
void play(const Ts &...x) override
|
||||||
|
{
|
||||||
this->pwr_lim_ = this->value_.value(x...);
|
this->pwr_lim_ = this->value_.value(x...);
|
||||||
this->ac_->powerLimitationOnSequence(this->pwr_lim_);
|
this->ac_->powerLimitationOnSequence(this->pwr_lim_);
|
||||||
}
|
}
|
||||||
@@ -180,7 +235,7 @@ class AirConPowerLimitationOnAction : public Action<Ts...> {
|
|||||||
protected:
|
protected:
|
||||||
AirCon *ac_;
|
AirCon *ac_;
|
||||||
uint8_t pwr_lim_;
|
uint8_t pwr_lim_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace aux_ac
|
} // namespace aux_ac
|
||||||
} // namespace esphome
|
} // namespace esphome
|
||||||
@@ -1476,13 +1476,12 @@ namespace esphome
|
|||||||
small_info_body = (packet_small_info_body_t *)(_inPacket.body);
|
small_info_body = (packet_small_info_body_t *)(_inPacket.body);
|
||||||
|
|
||||||
// в малом пакете передается большое количество установленных пользователем параметров работы
|
// в малом пакете передается большое количество установленных пользователем параметров работы
|
||||||
// stateFloat = 8 + (small_info_body->target_temp_int_and_v_louver >> 3) + 0.5 * (float)(small_info_body->target_temp_frac >> 7);
|
// stateFloat = 8.0 + (float)(small_info_body->target_temp_int) + ((small_info_body->target_temp_frac_bool) ? 0.5 : 0.0);
|
||||||
stateFloat = 8.0 + (float)(small_info_body->target_temp_int) + ((small_info_body->target_temp_frac_bool) ? 0.5 : 0.0);
|
stateFloat = 8.0 + (float)(small_info_body->target_temp_int) + (small_info_body->target_temp_frac_dec / 10.0);
|
||||||
stateChangedFlag = stateChangedFlag || (_current_ac_state.temp_target != stateFloat);
|
stateChangedFlag = stateChangedFlag || (_current_ac_state.temp_target != stateFloat);
|
||||||
_current_ac_state.temp_target = stateFloat;
|
_current_ac_state.temp_target = stateFloat;
|
||||||
_current_ac_state.temp_target_matter = true;
|
_current_ac_state.temp_target_matter = true;
|
||||||
|
|
||||||
// stateByte = small_info_body->target_temp_int_and_v_louver & AC_LOUVERV_MASK;
|
|
||||||
stateByte = small_info_body->v_louver;
|
stateByte = small_info_body->v_louver;
|
||||||
stateChangedFlag = stateChangedFlag || (_current_ac_state.louver.louver_v != (ac_louver_V)stateByte);
|
stateChangedFlag = stateChangedFlag || (_current_ac_state.louver.louver_v != (ac_louver_V)stateByte);
|
||||||
_current_ac_state.louver.louver_v = (ac_louver_V)stateByte;
|
_current_ac_state.louver.louver_v = (ac_louver_V)stateByte;
|
||||||
@@ -1946,6 +1945,7 @@ namespace esphome
|
|||||||
{
|
{
|
||||||
pack->body[4] = (pack->body[4] & ~AC_TEMP_TARGET_FRAC_PART_MASK);
|
pack->body[4] = (pack->body[4] & ~AC_TEMP_TARGET_FRAC_PART_MASK);
|
||||||
}
|
}
|
||||||
|
pack->body[14] = ((uint8_t)(cmd->temp_target * 10)) % 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
// значение ограничения мощности инвертора
|
// значение ограничения мощности инвертора
|
||||||
@@ -4025,7 +4025,7 @@ namespace esphome
|
|||||||
// initAC() в формируемом питоном коде вызывается до вызова aux_ac.set_supported_***() с установленными пользователем в конфиге параметрами
|
// initAC() в формируемом питоном коде вызывается до вызова aux_ac.set_supported_***() с установленными пользователем в конфиге параметрами
|
||||||
#if ESPHOME_VERSION_CODE >= VERSION_CODE(2025, 11, 0)
|
#if ESPHOME_VERSION_CODE >= VERSION_CODE(2025, 11, 0)
|
||||||
_traits.add_feature_flags(climate::CLIMATE_SUPPORTS_CURRENT_TEMPERATURE);
|
_traits.add_feature_flags(climate::CLIMATE_SUPPORTS_CURRENT_TEMPERATURE);
|
||||||
_traits.add_feature_flags(climate::CLIMATE_REQUIRES_TWO_POINT_TARGET_TEMPERATURE);
|
// NOT setting CLIMATE_REQUIRES_TWO_POINT_TARGET_TEMPERATURE - this device uses single target temperature
|
||||||
#else
|
#else
|
||||||
_traits.set_supports_current_temperature(true);
|
_traits.set_supports_current_temperature(true);
|
||||||
_traits.set_supports_two_point_target_temperature(false); // if the climate device's target temperature should be split in target_temperature_low and target_temperature_high instead of just the single target_temperature
|
_traits.set_supports_two_point_target_temperature(false); // if the climate device's target temperature should be split in target_temperature_low and target_temperature_high instead of just the single target_temperature
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ from esphome.components.climate import (
|
|||||||
ClimateSwingMode,
|
ClimateSwingMode,
|
||||||
)
|
)
|
||||||
|
|
||||||
AUX_AC_FIRMWARE_VERSION = '0.3.1'
|
AUX_AC_FIRMWARE_VERSION = '0.3.2'
|
||||||
AC_PACKET_TIMEOUT_MIN = 150
|
AC_PACKET_TIMEOUT_MIN = 150
|
||||||
AC_PACKET_TIMEOUT_MAX = 600
|
AC_PACKET_TIMEOUT_MAX = 600
|
||||||
AC_POWER_LIMIT_MIN = 30
|
AC_POWER_LIMIT_MIN = 30
|
||||||
|
|||||||
Reference in New Issue
Block a user