@@ -79,17 +79,34 @@ switch:
|
|||||||
optimistic: true
|
optimistic: true
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- id: !extend addon_climate_service_call
|
- id: !extend change_climate_state
|
||||||
then:
|
then:
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
|
if (embedded) {
|
||||||
|
static const char *const TAG = "addon_climate_base.script.change_climate_state";
|
||||||
id(is_addon_climate_visible) = true;
|
id(is_addon_climate_visible) = true;
|
||||||
disp1->set_component_value("climate.embedded", 1);
|
disp1->set_component_value("climate.embedded", 1);
|
||||||
auto call = thermostat_embedded->make_call();
|
auto call = thermostat_embedded->make_call();
|
||||||
if (key == "set_temperature")
|
if (key == "temperature") {
|
||||||
|
ESP_LOGD(TAG, "set_target_temperature(%f)", (stof(value) / 10));
|
||||||
call.set_target_temperature(stof(value) / 10);
|
call.set_target_temperature(stof(value) / 10);
|
||||||
else if (key == "hvac_mode")
|
} 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);
|
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();
|
call.perform();
|
||||||
|
}
|
||||||
|
|
||||||
- id: !extend global_settings
|
- id: !extend global_settings
|
||||||
then:
|
then:
|
||||||
|
|||||||
@@ -1637,28 +1637,19 @@ text_sensor:
|
|||||||
else service_call_alarm_control_panel->execute(entity.c_str(), key.c_str(), code_format.c_str(), "");
|
else service_call_alarm_control_panel->execute(entity.c_str(), key.c_str(), code_format.c_str(), "");
|
||||||
}
|
}
|
||||||
else if (page == "climate") {
|
else if (page == "climate") {
|
||||||
if (embedded==1)
|
change_climate_state->execute((embedded==1), key.c_str(), value.c_str());
|
||||||
addon_climate_service_call->execute(key.c_str(), value.c_str());
|
|
||||||
else if (key == "temperature" or key == "target_temp_high" or key == "target_temp_low")
|
|
||||||
ha_call_service->execute("climate.set_temperature", key.c_str(), to_string(stof(value) / 10), entity.c_str());
|
|
||||||
else if (key == "hvac_mode")
|
|
||||||
ha_call_service->execute("climate.set_hvac_mode", key.c_str(), value.c_str(), entity.c_str());
|
|
||||||
}
|
}
|
||||||
else if (page == "cover")
|
else if (page == "cover") {
|
||||||
{
|
|
||||||
if (key == "position") ha_call_service->execute("cover.set_cover_position", key.c_str(), value.c_str(), entity.c_str());
|
if (key == "position") ha_call_service->execute("cover.set_cover_position", key.c_str(), value.c_str(), entity.c_str());
|
||||||
else ha_call_service->execute((std::string("cover.") + key.c_str()), "", "", entity.c_str());
|
else ha_call_service->execute((std::string("cover.") + key.c_str()), "", "", entity.c_str());
|
||||||
}
|
}
|
||||||
else if (page == "fan")
|
else if (page == "fan") {
|
||||||
{
|
|
||||||
if (key == "stop" or value == "0") ha_call_service->execute("fan.turn_off", "", "", entity.c_str());
|
if (key == "stop" or value == "0") ha_call_service->execute("fan.turn_off", "", "", entity.c_str());
|
||||||
else ha_call_service->execute("fan.turn_on", key.c_str(), value.c_str(), entity.c_str());
|
else ha_call_service->execute("fan.turn_on", key.c_str(), value.c_str(), entity.c_str());
|
||||||
}
|
}
|
||||||
else if (page == "keyb_num")
|
else if (page == "keyb_num") {
|
||||||
{
|
|
||||||
std::string base_domain = doc["base_domain"];
|
std::string base_domain = doc["base_domain"];
|
||||||
if (base_domain == "alarm")
|
if (base_domain == "alarm") {
|
||||||
{
|
|
||||||
std::string code_format = doc["code_format"];
|
std::string code_format = doc["code_format"];
|
||||||
std::string pin = doc["pin"];
|
std::string pin = doc["pin"];
|
||||||
service_call_alarm_control_panel->execute(entity.c_str(), key.c_str(), code_format.c_str(), pin.c_str());
|
service_call_alarm_control_panel->execute(entity.c_str(), key.c_str(), code_format.c_str(), pin.c_str());
|
||||||
@@ -1667,8 +1658,7 @@ text_sensor:
|
|||||||
disp1->goto_page(base_domain.c_str());
|
disp1->goto_page(base_domain.c_str());
|
||||||
}
|
}
|
||||||
else if (page == "light") ha_call_service->execute("light.turn_on", key.c_str(), value.c_str(), entity.c_str());
|
else if (page == "light") ha_call_service->execute("light.turn_on", key.c_str(), value.c_str(), entity.c_str());
|
||||||
else if (page == "media_player")
|
else if (page == "media_player") {
|
||||||
{
|
|
||||||
if (key == "volume_mute") ha_call_service->execute("media_player.volume_mute", "is_volume_muted", value.c_str(), entity.c_str());
|
if (key == "volume_mute") ha_call_service->execute("media_player.volume_mute", "is_volume_muted", value.c_str(), entity.c_str());
|
||||||
else if (key == "volume_set") ha_call_service->execute("media_player.volume_set", "volume_level", to_string(stof(value) / 100), entity.c_str());
|
else if (key == "volume_set") ha_call_service->execute("media_player.volume_set", "volume_level", to_string(stof(value) / 100), entity.c_str());
|
||||||
else if (not key.empty()) ha_call_service->execute((std::string("media_player.") + key.c_str()), "", "", entity.c_str());
|
else if (not key.empty()) ha_call_service->execute((std::string("media_player.") + key.c_str()), "", "", entity.c_str());
|
||||||
@@ -1693,12 +1683,20 @@ text_sensor:
|
|||||||
|
|
||||||
### Scripts ######
|
### Scripts ######
|
||||||
script:
|
script:
|
||||||
- id: addon_climate_service_call
|
- id: change_climate_state
|
||||||
mode: restart
|
mode: restart
|
||||||
parameters:
|
parameters:
|
||||||
|
embedded: bool
|
||||||
key: string
|
key: string
|
||||||
value: string
|
value: string
|
||||||
then: # Reserved for Add-on Climate
|
then:
|
||||||
|
- lambda: |-
|
||||||
|
if (!embedded) {
|
||||||
|
if (key == "temperature" or key == "target_temp_high" or key == "target_temp_low")
|
||||||
|
ha_call_service->execute("climate.set_temperature", key.c_str(), to_string(stof(value) / 10), detailed_entity->state.c_str());
|
||||||
|
else if (key == "hvac_mode")
|
||||||
|
ha_call_service->execute("climate.set_hvac_mode", key.c_str(), value.c_str(), detailed_entity->state.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
- id: check_versions
|
- id: check_versions
|
||||||
mode: restart
|
mode: restart
|
||||||
@@ -2805,7 +2803,7 @@ script:
|
|||||||
- lambda: |-
|
- lambda: |-
|
||||||
static const char *const TAG = "script.stop_all";
|
static const char *const TAG = "script.stop_all";
|
||||||
ESP_LOGD(TAG, "Stopping scripts...");
|
ESP_LOGD(TAG, "Stopping scripts...");
|
||||||
addon_climate_service_call->stop();
|
change_climate_state->stop();
|
||||||
check_versions->stop();
|
check_versions->stop();
|
||||||
display_embedded_temp->stop();
|
display_embedded_temp->stop();
|
||||||
display_wrapped_text->stop();
|
display_wrapped_text->stop();
|
||||||
|
|||||||
Reference in New Issue
Block a user