mirror of
https://github.com/esphome/esphome.git
synced 2024-11-14 11:08:10 +01:00
[midea] Add temperature validation in do_follow_me method (bugfix) (#7736)
Some checks are pending
CI / Run script/ci-custom (push) Blocked by required conditions
CI / list-components (push) Blocked by required conditions
CI / Create common environment (push) Waiting to run
CI / Check black (push) Blocked by required conditions
CI / Check flake8 (push) Blocked by required conditions
CI / Check pylint (push) Blocked by required conditions
CI / Check pyupgrade (push) Blocked by required conditions
CI / Run pytest (push) Blocked by required conditions
CI / Check clang-format (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 1/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 2/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 3/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 4/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 IDF (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP8266 (push) Blocked by required conditions
CI / Component test (push) Blocked by required conditions
CI / Split components for testing into 20 groups maximum (push) Blocked by required conditions
CI / Test split components (push) Blocked by required conditions
CI / CI Status (push) Blocked by required conditions
YAML lint / yamllint (push) Waiting to run
Some checks are pending
CI / Run script/ci-custom (push) Blocked by required conditions
CI / list-components (push) Blocked by required conditions
CI / Create common environment (push) Waiting to run
CI / Check black (push) Blocked by required conditions
CI / Check flake8 (push) Blocked by required conditions
CI / Check pylint (push) Blocked by required conditions
CI / Check pyupgrade (push) Blocked by required conditions
CI / Run pytest (push) Blocked by required conditions
CI / Check clang-format (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 1/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 2/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 3/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 4/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 IDF (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP8266 (push) Blocked by required conditions
CI / Component test (push) Blocked by required conditions
CI / Split components for testing into 20 groups maximum (push) Blocked by required conditions
CI / Test split components (push) Blocked by required conditions
CI / CI Status (push) Blocked by required conditions
YAML lint / yamllint (push) Waiting to run
This commit is contained in:
parent
ffee2f0e88
commit
a2dccc4730
1 changed files with 17 additions and 1 deletions
|
@ -3,6 +3,8 @@
|
||||||
#include "esphome/core/log.h"
|
#include "esphome/core/log.h"
|
||||||
#include "air_conditioner.h"
|
#include "air_conditioner.h"
|
||||||
#include "ac_adapter.h"
|
#include "ac_adapter.h"
|
||||||
|
#include <cmath>
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace midea {
|
namespace midea {
|
||||||
|
@ -121,7 +123,21 @@ void AirConditioner::dump_config() {
|
||||||
|
|
||||||
void AirConditioner::do_follow_me(float temperature, bool beeper) {
|
void AirConditioner::do_follow_me(float temperature, bool beeper) {
|
||||||
#ifdef USE_REMOTE_TRANSMITTER
|
#ifdef USE_REMOTE_TRANSMITTER
|
||||||
IrFollowMeData data(static_cast<uint8_t>(lroundf(temperature)), beeper);
|
// Check if temperature is finite (not NaN or infinite)
|
||||||
|
if (!std::isfinite(temperature)) {
|
||||||
|
ESP_LOGW(Constants::TAG, "Follow me action requires a finite temperature, got: %f", temperature);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Round and convert temperature to long, then clamp and convert it to uint8_t
|
||||||
|
uint8_t temp_uint8 =
|
||||||
|
static_cast<uint8_t>(std::max(0L, std::min(static_cast<long>(UINT8_MAX), std::lroundf(temperature))));
|
||||||
|
|
||||||
|
ESP_LOGD(Constants::TAG, "Follow me action called with temperature: %f °C, rounded to: %u °C", temperature,
|
||||||
|
temp_uint8);
|
||||||
|
|
||||||
|
// Create and transmit the data
|
||||||
|
IrFollowMeData data(temp_uint8, 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");
|
||||||
|
|
Loading…
Reference in a new issue