Rebuild embedded climate changing calls

Solves #1613
Solves #1627
This commit is contained in:
Edward Firmo
2024-01-16 09:43:26 +01:00
parent c34018c021
commit 59cc6a536e
2 changed files with 60 additions and 45 deletions

View File

@@ -79,17 +79,34 @@ switch:
optimistic: true
script:
- id: !extend addon_climate_service_call
- id: !extend change_climate_state
then:
- lambda: |-
id(is_addon_climate_visible) = true;
disp1->set_component_value("climate.embedded", 1);
auto call = thermostat_embedded->make_call();
if (key == "set_temperature")
call.set_target_temperature(stof(value) / 10);
else if (key == "hvac_mode")
call.set_mode(value);
call.perform();
if (embedded) {
static const char *const TAG = "addon_climate_base.script.change_climate_state";
id(is_addon_climate_visible) = true;
disp1->set_component_value("climate.embedded", 1);
auto call = thermostat_embedded->make_call();
if (key == "temperature") {
ESP_LOGD(TAG, "set_target_temperature(%f)", (stof(value) / 10));
call.set_target_temperature(stof(value) / 10);
} else if (key == "target_temp_high") {
ESP_LOGD(TAG, "set_target_temperature_high(%f)", (stof(value) / 10));
call.set_target_temperature_high(stof(value) / 10);
} else if (key == "target_temp_low") {
ESP_LOGD(TAG, "set_target_temperature_low(%f)", (stof(value) / 10));
call.set_target_temperature_low(stof(value) / 10);
} else if (key == "hvac_mode") {
ESP_LOGD(TAG, "hvac_mode(%s)", value.c_str());
call.set_mode(value);
} else {
ESP_LOGE(TAG, "Invalid call:");
ESP_LOGE(TAG, " Embedded: %s", embedded ? "True" : "False");
ESP_LOGE(TAG, " Key: %s", key.c_str());
ESP_LOGE(TAG, " Value: %s", value.c_str());
}
call.perform();
}
- id: !extend global_settings
then: