make use_fahrenheit consistent in follow me action

This commit is contained in:
Djordje 2024-11-22 00:57:34 +01:00
parent 5499e2ec2f
commit d80d9e1395
4 changed files with 7 additions and 7 deletions

View file

@ -19,11 +19,11 @@ template<typename... Ts> class MideaActionBase : public Action<Ts...> {
template<typename... Ts> class FollowMeAction : public MideaActionBase<Ts...> { template<typename... Ts> class FollowMeAction : public MideaActionBase<Ts...> {
TEMPLATABLE_VALUE(float, temperature) TEMPLATABLE_VALUE(float, temperature)
TEMPLATABLE_VALUE(bool, fahrenheit) TEMPLATABLE_VALUE(bool, use_fahrenheit)
TEMPLATABLE_VALUE(bool, beeper) TEMPLATABLE_VALUE(bool, beeper)
void play(Ts... x) override { void play(Ts... x) override {
this->parent_->do_follow_me(this->temperature_.value(x...), this->fahrenheit_.value(x...), this->parent_->do_follow_me(this->temperature_.value(x...), this->use_fahrenheit_.value(x...),
this->beeper_.value(x...)); this->beeper_.value(x...));
} }
}; };

View file

@ -122,7 +122,7 @@ void AirConditioner::dump_config() {
/* ACTIONS */ /* ACTIONS */
void AirConditioner::do_follow_me(float temperature, bool fahrenheit, bool beeper) { void AirConditioner::do_follow_me(float temperature, bool use_fahrenheit, bool beeper) {
#ifdef USE_REMOTE_TRANSMITTER #ifdef USE_REMOTE_TRANSMITTER
// Check if temperature is finite (not NaN or infinite) // Check if temperature is finite (not NaN or infinite)
if (!std::isfinite(temperature)) { if (!std::isfinite(temperature)) {
@ -134,12 +134,12 @@ void AirConditioner::do_follow_me(float temperature, bool fahrenheit, bool beepe
uint8_t temp_uint8 = uint8_t temp_uint8 =
static_cast<uint8_t>(esphome::clamp<long>(std::lroundf(temperature), 0L, static_cast<long>(UINT8_MAX))); static_cast<uint8_t>(esphome::clamp<long>(std::lroundf(temperature), 0L, static_cast<long>(UINT8_MAX)));
char temp_symbol = fahrenheit ? 'F' : 'C'; char temp_symbol = use_fahrenheit ? 'F' : 'C';
ESP_LOGD(Constants::TAG, "Follow me action called with temperature: %f °%c, rounded to: %u °%c", temperature, ESP_LOGD(Constants::TAG, "Follow me action called with temperature: %f °%c, rounded to: %u °%c", temperature,
temp_symbol, temp_uint8, temp_symbol); temp_symbol, temp_uint8, temp_symbol);
// Create and transmit the data // Create and transmit the data
IrFollowMeData data(temp_uint8, fahrenheit, beeper); IrFollowMeData data(temp_uint8, use_fahrenheit, beeper);
this->transmitter_.transmit(data); this->transmitter_.transmit(data);
#else #else
ESP_LOGW(Constants::TAG, "Action needs remote_transmitter component"); ESP_LOGW(Constants::TAG, "Action needs remote_transmitter component");

View file

@ -32,7 +32,7 @@ class AirConditioner : public ApplianceBase<dudanov::midea::ac::AirConditioner>,
/* ### ACTIONS ### */ /* ### ACTIONS ### */
/* ############### */ /* ############### */
void do_follow_me(float temperature, bool fahrenheit, bool beeper = false); void do_follow_me(float temperature, bool use_fahrenheit, bool beeper = false);
void do_display_toggle(); void do_display_toggle();
void do_swing_step(); void do_swing_step();
void do_beeper_on() { this->set_beeper_feedback(true); } void do_beeper_on() { this->set_beeper_feedback(true); }

View file

@ -187,7 +187,7 @@ async def follow_me_to_code(var, config, args):
template_ = await cg.templatable(config[CONF_BEEPER], args, cg.bool_) template_ = await cg.templatable(config[CONF_BEEPER], args, cg.bool_)
cg.add(var.set_beeper(template_)) cg.add(var.set_beeper(template_))
template_ = await cg.templatable(config[CONF_USE_FAHRENHEIT], args, cg.bool_) template_ = await cg.templatable(config[CONF_USE_FAHRENHEIT], args, cg.bool_)
cg.add(var.set_fahrenheit(template_)) cg.add(var.set_use_fahrenheit(template_))
template_ = await cg.templatable(config[CONF_TEMPERATURE], args, cg.float_) template_ = await cg.templatable(config[CONF_TEMPERATURE], args, cg.float_)
cg.add(var.set_temperature(template_)) cg.add(var.set_temperature(template_))