Skip to content

Commit

Permalink
Merge pull request #210 from melyux/update-on-changes
Browse files Browse the repository at this point in the history
Publish updates only on changes
  • Loading branch information
echavet authored Jan 5, 2025
2 parents 89e525a + 8c8c238 commit 106a2d3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions components/cn105/Globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,8 @@ struct heatpumpStatus {
float runtimeHours;

bool operator==(const heatpumpStatus& other) const {
return roomTemperature == other.roomTemperature &&
outsideAirTemperature == other.outsideAirTemperature &&
return (std::isnan(roomTemperature) ? std::isnan(other.roomTemperature) : roomTemperature == other.roomTemperature) &&
(std::isnan(outsideAirTemperature) ? std::isnan(other.outsideAirTemperature) : outsideAirTemperature == other.outsideAirTemperature) &&
operating == other.operating &&
//timers == other.timers && // Assurez-vous que l'opérateur == est également défini pour heatpumpTimers
compressorFrequency == other.compressorFrequency &&
Expand Down
11 changes: 7 additions & 4 deletions components/cn105/hp_readings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,16 @@ void CN105Climate::getPowerFromResponsePacket() {
ESP_LOGD("Decoder", "[Auto Mode Sub Mode : %s]", receivedSettings.auto_sub_mode);

//this->heatpumpUpdate(receivedSettings);
if (this->Stage_sensor_ != nullptr) {
if (this->Stage_sensor_ != nullptr && (!this->currentSettings.stage || strcmp(receivedSettings.stage, this->currentSettings.stage) != 0)) {
this->currentSettings.stage = receivedSettings.stage;
this->Stage_sensor_->publish_state(receivedSettings.stage);
}
if (this->Sub_mode_sensor_ != nullptr) {
if (this->Sub_mode_sensor_ != nullptr && (!this->currentSettings.sub_mode || strcmp(receivedSettings.sub_mode, this->currentSettings.sub_mode) != 0)) {
this->currentSettings.sub_mode = receivedSettings.sub_mode;
this->Sub_mode_sensor_->publish_state(receivedSettings.sub_mode);
}
if (this->Auto_sub_mode_sensor_ != nullptr) {
if (this->Auto_sub_mode_sensor_ != nullptr && (!this->currentSettings.sub_mode || strcmp(receivedSettings.auto_sub_mode, this->currentSettings.auto_sub_mode) != 0)) {

This comment has been minimized.

Copy link
@somlefant

somlefant Jan 5, 2025

Typo?
Should be:
if (this->Auto_sub_mode_sensor_ != nullptr && (!this->currentSettings.auto_sub_mode || strcmp(receivedSettings.auto_sub_mode, this->currentSettings.auto_sub_mode) != 0)) {

My ESP hangs without this fix.

@echavet can you check?

this->currentSettings.auto_sub_mode = receivedSettings.auto_sub_mode;
this->Auto_sub_mode_sensor_->publish_state(receivedSettings.auto_sub_mode);
}
}
Expand Down Expand Up @@ -517,8 +520,8 @@ void CN105Climate::heatpumpUpdate(heatpumpSettings& settings) {

if (this->currentSettings != settings) {
ESP_LOGD(LOG_SETTINGS_TAG, "Settings changed, updating HA states");
this->publishStateToHA(settings);
}
this->publishStateToHA(settings);
}

void CN105Climate::checkVaneSettings(heatpumpSettings& settings, bool updateCurrentSettings) {
Expand Down
2 changes: 1 addition & 1 deletion components/cn105/hp_writings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ void CN105Climate::createPacket(uint8_t* packet) {

void CN105Climate::publishWantedSettingsStateToHA() {

if ((this->wantedSettings.mode != nullptr) || (this->wantedSettings.mode != nullptr)) {
if ((this->wantedSettings.mode != nullptr) || (this->wantedSettings.power != nullptr)) {
checkPowerAndModeSettings(this->wantedSettings, false);
this->updateAction(); // update action info on HA climate component
}
Expand Down

3 comments on commit 106a2d3

@drew-hill
Copy link

@drew-hill drew-hill commented on 106a2d3 Jan 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<nvm: I’ll just file an issue>

@somlefant
Copy link

@somlefant somlefant commented on 106a2d3 Jan 5, 2025 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@drew-hill
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I saw that, but couldn't determine if it was likely to be the underlying cause, so I submitted an Issue with more info: #215.

Please sign in to comment.