Skip to content

Commit

Permalink
setLight and setTemp
Browse files Browse the repository at this point in the history
  • Loading branch information
netmindz committed Oct 7, 2023
1 parent c5531d0 commit 8e38ff1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 45 deletions.
23 changes: 10 additions & 13 deletions components/BalboaGL/ESPBalboaGL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
// }
Expand Down Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion components/BalboaGL/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,5 @@ def to_code(config):
cg.add_library(
name="balboaGL",
repository="https://github.com/netmindz/balboaGL.git",
version="ec30c86f8100fb8cd6562ba4e333cda527b62704",
version="e5b7e189f4b687295f66075c1bdfa8b3ce5f06be",
)
33 changes: 2 additions & 31 deletions sensor/src/sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 8e38ff1

Please sign in to comment.