From 8e38ff1aef647fd09f86b3773b627594ffad9e8f Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 7 Oct 2023 15:45:42 +0100 Subject: [PATCH] setLight and setTemp --- components/BalboaGL/ESPBalboaGL.cpp | 23 +++++++++----------- components/BalboaGL/climate.py | 2 +- sensor/src/sensor.cpp | 33 ++--------------------------- 3 files changed, 13 insertions(+), 45 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 0666c98..1bd515a 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -119,7 +119,7 @@ void BalboaGL::control(const climate::ClimateCall &call) { // bool updated = false; // bool has_mode = call.get_mode().has_value(); -// bool has_temp = call.get_target_temperature().has_value(); + bool has_temp = call.get_target_temperature().has_value(); // if (has_mode){ // this->mode = *call.get_mode(); // } @@ -187,23 +187,20 @@ void BalboaGL::control(const climate::ClimateCall &call) { // break; // } -// if (has_temp){ -// ESP_LOGV( -// "control", "Sending target temp: %.1f", -// *call.get_target_temperature() -// ); -// hp->setTemperature(*call.get_target_temperature()); -// this->target_temperature = *call.get_target_temperature(); -// updated = true; -// } + if (has_temp){ + ESP_LOGV( + "control", "Sending target temp: %.1f", + *call.get_target_temperature() + ); + this->spa->setTemp(*call.get_target_temperature()); + updated = true; + } -// ESP_LOGD(TAG, "control - Was HeatPump updated? %s", YESNO(updated)); +// ESP_LOGD(TAG, "control - Was SPA updated? %s", YESNO(updated)); // send the update back to esphome: this->publish_state(); -// // and the heat pump: -// hp->update(); } // void BalboaGL::hpSettingsChanged() { diff --git a/components/BalboaGL/climate.py b/components/BalboaGL/climate.py index 26e9177..80901c3 100644 --- a/components/BalboaGL/climate.py +++ b/components/BalboaGL/climate.py @@ -95,5 +95,5 @@ def to_code(config): cg.add_library( name="balboaGL", repository="https://github.com/netmindz/balboaGL.git", - version="ec30c86f8100fb8cd6562ba4e333cda527b62704", + version="e5b7e189f4b687295f66075c1bdfa8b3ce5f06be", ) diff --git a/sensor/src/sensor.cpp b/sensor/src/sensor.cpp index c6514ba..4bf3390 100644 --- a/sensor/src/sensor.cpp +++ b/sensor/src/sensor.cpp @@ -116,12 +116,7 @@ int lastUptime = 0; void onSwitchStateChanged(bool state, HASwitch* sender) { Serial.printf("Switch %s changed - ", sender->getName()); - if (state != status.light) { - Serial.println("Toggle"); - sendBuffer.enqueue(COMMAND_LIGHT); - } else { - Serial.println("No change needed"); - } + spa.setLight(state); } void onPumpSwitchStateChanged(int8_t index, HASelect* sender) { @@ -165,31 +160,7 @@ void onTargetTemperatureCommand(HANumeric temperature, HAHVAC* sender) { Serial.print("Target temperature: "); Serial.println(temperatureFloat); - if (status.targetTemp <= 0) { - Serial.print("ERROR: can't adjust target as current value not known"); - sendBuffer.enqueue( - COMMAND_UP); // Enter set temp mode - won't change, but should allow us to capture the set target value - return; - } - - int target = temperatureFloat * 2; // 0.5 inc so double - int current = status.targetTemp * 2; - sendBuffer.enqueue(COMMAND_UP); // Enter set temp mode - sendBuffer.enqueue(COMMAND_EMPTY); - - if (temperatureFloat > status.targetTemp) { - for (int i = 0; i < (target - current); i++) { - Serial.println("Raise the temp"); - sendBuffer.enqueue(COMMAND_UP); - // sendBuffer.enqueue(COMMAND_EMPTY); - } - } else { - for (int i = 0; i < (current - target); i++) { - Serial.println("Lower the temp"); - sendBuffer.enqueue(COMMAND_DOWN); - // sendBuffer.enqueue(COMMAND_EMPTY); - } - } + spa.setTemp(temperatureFloat); // sender->setTargetTemperature(temperature); // report target temperature back to the HA panel - better to see what // the control unit reports that assume our commands worked