Compare commits

...

2 Commits

Author SHA1 Message Date
J. Nick Koston
c51282cee9 [sml] Use constexpr std::array for START_SEQ constant 2026-01-23 22:50:51 -10:00
Peter Meiser
60968d311b [thermostat] make comparisons consistent with documentation (#13499) 2026-01-24 00:20:18 -06:00
2 changed files with 15 additions and 13 deletions

View File

@@ -1,5 +1,6 @@
#pragma once
#include <array>
#include <cstdint>
namespace esphome {
@@ -21,7 +22,7 @@ enum SmlMessageType : uint16_t { SML_PUBLIC_OPEN_RES = 0x0101, SML_GET_LIST_RES
const uint16_t START_MASK = 0x55aa; // 0x1b 1b 1b 1b 01 01 01 01
const uint16_t END_MASK = 0x0157; // 0x1b 1b 1b 1b 1a
const std::vector<uint8_t> START_SEQ = {0x1b, 0x1b, 0x1b, 0x1b, 0x01, 0x01, 0x01, 0x01};
constexpr std::array<uint8_t, 8> START_SEQ = {0x1b, 0x1b, 0x1b, 0x1b, 0x01, 0x01, 0x01, 0x01};
} // namespace sml
} // namespace esphome

View File

@@ -1060,11 +1060,11 @@ bool ThermostatClimate::cooling_required_() {
auto temperature = this->supports_two_points_ ? this->target_temperature_high : this->target_temperature;
if (this->supports_cool_) {
if (this->current_temperature > temperature + this->cooling_deadband_) {
// if the current temperature exceeds the target + deadband, cooling is required
if (this->current_temperature >= temperature + this->cooling_deadband_) {
// if the current temperature reaches or exceeds the target + deadband, cooling is required
return true;
} else if (this->current_temperature < temperature - this->cooling_overrun_) {
// if the current temperature is less than the target - overrun, cooling should stop
} else if (this->current_temperature <= temperature - this->cooling_overrun_) {
// if the current temperature is less than or equal to the target - overrun, cooling should stop
return false;
} else {
// if we get here, the current temperature is between target + deadband and target - overrun,
@@ -1081,11 +1081,11 @@ bool ThermostatClimate::fanning_required_() {
if (this->supports_fan_only_) {
if (this->supports_fan_only_cooling_) {
if (this->current_temperature > temperature + this->cooling_deadband_) {
// if the current temperature exceeds the target + deadband, fanning is required
if (this->current_temperature >= temperature + this->cooling_deadband_) {
// if the current temperature reaches or exceeds the target + deadband, fanning is required
return true;
} else if (this->current_temperature < temperature - this->cooling_overrun_) {
// if the current temperature is less than the target - overrun, fanning should stop
} else if (this->current_temperature <= temperature - this->cooling_overrun_) {
// if the current temperature is less than or equal to the target - overrun, fanning should stop
return false;
} else {
// if we get here, the current temperature is between target + deadband and target - overrun,
@@ -1103,11 +1103,12 @@ bool ThermostatClimate::heating_required_() {
auto temperature = this->supports_two_points_ ? this->target_temperature_low : this->target_temperature;
if (this->supports_heat_) {
if (this->current_temperature < temperature - this->heating_deadband_) {
// if the current temperature is below the target - deadband, heating is required
if (this->current_temperature <= temperature - this->heating_deadband_) {
// if the current temperature is below or equal to the target - deadband, heating is required
return true;
} else if (this->current_temperature > temperature + this->heating_overrun_) {
// if the current temperature is above the target + overrun, heating should stop
} else if (this->current_temperature >= temperature + this->heating_overrun_) {
// if the current temperature is above or equal to the target + overrun, heating should stop
return false;
} else {
// if we get here, the current temperature is between target - deadband and target + overrun,