mirror of
https://github.com/esphome/esphome.git
synced 2024-11-27 17:27:59 +01:00
make use_fahrenheit consistent in follow me action
This commit is contained in:
parent
5499e2ec2f
commit
d80d9e1395
4 changed files with 7 additions and 7 deletions
|
@ -19,11 +19,11 @@ template<typename... Ts> class MideaActionBase : public Action<Ts...> {
|
|||
|
||||
template<typename... Ts> class FollowMeAction : public MideaActionBase<Ts...> {
|
||||
TEMPLATABLE_VALUE(float, temperature)
|
||||
TEMPLATABLE_VALUE(bool, fahrenheit)
|
||||
TEMPLATABLE_VALUE(bool, use_fahrenheit)
|
||||
TEMPLATABLE_VALUE(bool, beeper)
|
||||
|
||||
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...));
|
||||
}
|
||||
};
|
||||
|
|
|
@ -122,7 +122,7 @@ void AirConditioner::dump_config() {
|
|||
|
||||
/* 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
|
||||
// Check if temperature is finite (not NaN or infinite)
|
||||
if (!std::isfinite(temperature)) {
|
||||
|
@ -134,12 +134,12 @@ void AirConditioner::do_follow_me(float temperature, bool fahrenheit, bool beepe
|
|||
uint8_t temp_uint8 =
|
||||
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,
|
||||
temp_symbol, temp_uint8, temp_symbol);
|
||||
|
||||
// Create and transmit the data
|
||||
IrFollowMeData data(temp_uint8, fahrenheit, beeper);
|
||||
IrFollowMeData data(temp_uint8, use_fahrenheit, beeper);
|
||||
this->transmitter_.transmit(data);
|
||||
#else
|
||||
ESP_LOGW(Constants::TAG, "Action needs remote_transmitter component");
|
||||
|
|
|
@ -32,7 +32,7 @@ class AirConditioner : public ApplianceBase<dudanov::midea::ac::AirConditioner>,
|
|||
/* ### 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_swing_step();
|
||||
void do_beeper_on() { this->set_beeper_feedback(true); }
|
||||
|
|
|
@ -187,7 +187,7 @@ async def follow_me_to_code(var, config, args):
|
|||
template_ = await cg.templatable(config[CONF_BEEPER], args, cg.bool_)
|
||||
cg.add(var.set_beeper(template_))
|
||||
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_)
|
||||
cg.add(var.set_temperature(template_))
|
||||
|
||||
|
|
Loading…
Reference in a new issue