diff --git a/nspanel_blueprint.yaml b/nspanel_blueprint.yaml index edd3347..310252d 100644 --- a/nspanel_blueprint.yaml +++ b/nspanel_blueprint.yaml @@ -6526,6 +6526,8 @@ condition: - current_state_entity31 - current_state_entity32 - '{{ page.current in page.buttonpages }}' + - '{{ page.current in [page.light, page.cover, page.climate, page.fan, page.alarm] and trigger.entity_id == states(detailed_entity) }}' + ############################################################# ##### START - Action ##### ############################################################# @@ -6728,7 +6730,7 @@ action: else ((hardware.relays.relay2.icon_color_rgb[0] //(2**3)) *(2**11))+((hardware.relays.relay2.icon_color_rgb[1] //(2**2)) *(2**5))+(hardware.relays.relay2.icon_color_rgb[2] //(2**3)) }} relay2_fallback: '{{ hardware.relays.relay2.fallback }}' - embedded_climate: '{{ embedded_climate }}' + embedded_climate: '{{ climate == thermostat_embedded }}' embedded_climate_friendly_name: '{{ (state_attr(climate, "friendly_name") | default("")) if embedded_climate else "" }}' embedded_indoor_temperature: '{{ embedded_indoor_temperature }}' temperature_unit_is_fahrenheit: '{{ state_attr((nspaneltemp if embedded_indoor_temperature else indoor_temperature_sensor), "unit_of_measurement") | default("") in ["°F", "F"]}}' @@ -8193,8 +8195,8 @@ action: total_steps: '{{ total_steps }}' temp_offset: '{{ temp_offset }}' climate_icon: '{{ climate_icon }}' - embedded_climate: '{{ embedded_climate }}' - entity: '{{ climate_entity }}' + embedded_climate: '{{ climate_entity == thermostat_embedded }}' + entity: '{{ "embedded_climate" if climate_entity == thermostat_embedded else climate_entity }}' continue_on_error: true ##### Climate buttons ##### diff --git a/nspanel_esphome_core.yaml b/nspanel_esphome_core.yaml index 4ae50f2..9959780 100644 --- a/nspanel_esphome_core.yaml +++ b/nspanel_esphome_core.yaml @@ -1724,41 +1724,48 @@ script: climate_icon: string embedded_climate: bool then: - - if: - condition: - - text_sensor.state: # Is climate page visible? - id: current_page - state: 'climate' - then: - - lambda: |- - addon_climate_set_climate->execute(embedded_climate); - disp1->send_command_printf("climateslider.maxval=%i", total_steps); - disp1->set_component_value("temp_offset", temp_offset); - disp1->set_component_value("temp_step", temp_step); - disp1->set_component_text_printf("current_temp", "%.1f°", current_temp); - disp1->show_component("current_temp"); - disp1->show_component("current_icon"); - if (target_temp > -999) - { - float slider_val = round(((10*target_temp) - temp_offset) / temp_step); - disp1->set_component_value("climateslider", slider_val); - disp1->set_component_text_printf("target_temp", "%.1f°", target_temp); - disp1->set_component_text_printf("target_icon", "%s", climate_icon.c_str()); - disp1->show_component("target_icon"); - disp1->show_component("target_temp"); - disp1->show_component("climateslider"); - disp1->show_component("decrease_temp"); - disp1->show_component("increase_temp"); - } - else - { - disp1->hide_component("target_icon"); - disp1->hide_component("target_temp"); - disp1->hide_component("climateslider"); - disp1->hide_component("decrease_temp"); - disp1->hide_component("increase_temp"); - } - disp1->set_component_value("embedded", (embedded_climate) ? 1 : 0); + - lambda: |- + static const char *const TAG = "script.set_climate"; + ESP_LOGV(TAG, "Starting"); + ESP_LOGV(TAG, " current_temp: %f", current_temp); + ESP_LOGV(TAG, " target_temp: %f", target_temp); + ESP_LOGV(TAG, " temp_step: %d", temp_step); + ESP_LOGV(TAG, " total_steps: %d", total_steps); + ESP_LOGV(TAG, " temp_offset: %i", temp_offset); + ESP_LOGV(TAG, " climate_icon: %s", climate_icon.c_str()); + ESP_LOGV(TAG, " embedded_climate: %s", embedded_climate ? "True" : "False"); + if (current_page->state == "climate") { + ESP_LOGV(TAG, "Page climate is visible"); + addon_climate_set_climate->execute(embedded_climate); + disp1->send_command_printf("climateslider.maxval=%i", total_steps); + disp1->set_component_value("temp_offset", temp_offset); + disp1->set_component_value("temp_step", temp_step); + disp1->set_component_text_printf("current_temp", "%.1f°", current_temp); + disp1->show_component("current_temp"); + disp1->show_component("current_icon"); + if (target_temp > -999) + { + float slider_val = round(((10*target_temp) - temp_offset) / temp_step); + disp1->set_component_value("climateslider", slider_val); + disp1->set_component_text_printf("target_temp", "%.1f°", target_temp); + disp1->set_component_text_printf("target_icon", "%s", climate_icon.c_str()); + disp1->show_component("target_icon"); + disp1->show_component("target_temp"); + disp1->show_component("climateslider"); + disp1->show_component("decrease_temp"); + disp1->show_component("increase_temp"); + } + else + { + disp1->hide_component("target_icon"); + disp1->hide_component("target_temp"); + disp1->hide_component("climateslider"); + disp1->hide_component("decrease_temp"); + disp1->hide_component("increase_temp"); + } + disp1->set_component_value("embedded", (embedded_climate) ? 1 : 0); + } + ESP_LOGV(TAG, "Finished"); - id: refresh_datetime mode: restart @@ -1873,12 +1880,15 @@ script: embedded: bool then: - lambda: |- + static const char *const TAG = "script.service_call_climate"; + ESP_LOGV(TAG, "Calling climate service"); if (embedded) addon_climate_service_call->execute(key.c_str(), value.c_str()); else if (key == "set_temperature") ha_call_service->execute("climate.set_temperature", "temperature", 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()); + ESP_LOGV(TAG, "Finished"); - id: ha_call_service mode: restart @@ -1889,6 +1899,13 @@ script: entity: string then: - lambda: |- + static const char *const TAG = "script.ha_call_service"; + ESP_LOGV(TAG, "Calling Home Assisant service"); + ESP_LOGV(TAG, " Type: service_call"); + ESP_LOGV(TAG, " Service: %s", service.c_str()); + ESP_LOGV(TAG, " Entity: %s", entity.c_str()); + ESP_LOGV(TAG, " Key: %s", key.c_str()); + ESP_LOGV(TAG, " Value: %s", value.c_str()); if (service != "" and not service.empty()) { auto ha_event = new esphome::api::CustomAPIDevice(); @@ -1901,6 +1918,7 @@ script: {"value", value} }); } + ESP_LOGV(TAG, "Finished"); - id: ha_button mode: parallel