Fix bathroomheater entity (broken by HA update)

This commit is contained in:
2024-12-13 19:52:15 +01:00
parent 4460a5aec7
commit 534feaed82
+22 -13
View File
@@ -11,7 +11,7 @@ namespace {
class Zehnder : public Component, public Climate { class Zehnder : public Component, public Climate {
public: public:
void retransmit() { void retransmit() {
this->transmit_temperature_(this->target_temperature); this->transmit_temperature_(&this->target_temperature);
} }
void control(const ClimateCall &call) override { void control(const ClimateCall &call) override {
@@ -50,7 +50,7 @@ class Zehnder : public Component, public Climate {
} }
} }
if (this->transmit_temperature_(target_temp)) { if (this->transmit_temperature_(&target_temp)) {
this->mode = target_mode; this->mode = target_mode;
this->target_temperature = target_temp; this->target_temperature = target_temp;
this->publish_state(); this->publish_state();
@@ -63,9 +63,11 @@ class Zehnder : public Component, public Climate {
traits.set_visual_min_temperature(MIN_TEMPERATURE); traits.set_visual_min_temperature(MIN_TEMPERATURE);
traits.set_visual_max_temperature(MAX_TEMPERATURE); traits.set_visual_max_temperature(MAX_TEMPERATURE);
traits.set_visual_temperature_step( // Must be
(MAX_TEMPERATURE - MIN_TEMPERATURE) / (TEMPERATURE_LEVELS - 1) // (MAX_TEMPERATURE - MIN_TEMPERATURE) / (TEMPERATURE_LEVELS - 1)
); // but no longer supported by HA, because this component
// uses the same value to transmit precision.
traits.set_visual_temperature_step(1);
if (has_temperature_sensor_) { if (has_temperature_sensor_) {
traits.set_supports_current_temperature(true); traits.set_supports_current_temperature(true);
@@ -95,16 +97,23 @@ class Zehnder : public Component, public Climate {
remote_transmitter::RemoteTransmitterComponent *transmitter_ = nullptr; remote_transmitter::RemoteTransmitterComponent *transmitter_ = nullptr;
bool has_temperature_sensor_ = false; bool has_temperature_sensor_ = false;
bool transmit_temperature_(float temp) { bool transmit_temperature_(float* temp) {
return this->transmit_level_(temp == 0 uint8_t level;
? 0 if (*temp == 0) {
: ( level = 0;
(temp - MIN_TEMPERATURE) * } else {
level =
(*temp - MIN_TEMPERATURE) *
(TEMPERATURE_LEVELS - 1) / (TEMPERATURE_LEVELS - 1) /
(MAX_TEMPERATURE - MIN_TEMPERATURE) + (MAX_TEMPERATURE - MIN_TEMPERATURE) +
1 1;
) *temp =
); (MAX_TEMPERATURE - MIN_TEMPERATURE) /
(TEMPERATURE_LEVELS - 1) *
level +
MIN_TEMPERATURE;
}
return this->transmit_level_(level);
} }
bool transmit_level_(uint8_t level) { bool transmit_level_(uint8_t level) {