Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- INFO Reading configuration /config/esphome/nspanel.yaml...
- INFO Updating https://github.com/Blackymas/NSPanel_HA_Blueprint@main
- INFO Detected timezone 'Europe/Warsaw'
- WARNING GPIO4 is a Strapping PIN and should be avoided.
- Attaching external pullup/down resistors to strapping pins can cause unexpected failures.
- See https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins
- Failed config
- esphome: None
- name: nspanel1
- [min_version] is an invalid option for [esphome]. Please check the indentation.
- min_version: 2023.5.0 None
- build_path: .esphome/build/nspanel1
- api: [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:130]
- id: api_server
- reboot_timeout: 0s
- services: [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:136]
- - service: upload_tft
- then:
- - logger.log: Service: upload_tft
- - binary_sensor.template.publish:
- id: nextion_init
- state: False
- - lambda: id(disp1)->upload_tft();
- - service: upload_tft_url
- variables:
- url: string
- then:
- - logger.log: Service: upload_tft_url
- - binary_sensor.template.publish:
- id: nextion_init
- state: False
- - lambda: id(disp1)->set_tft_url(url.c_str());
- - lambda: id(disp1)->upload_tft();
- - service: send_command_printf
- variables:
- cmd: string
- then:
- - lambda: id(disp1).send_command_printf("%s", cmd.c_str());
- - service: send_command_text_printf
- variables:
- component: string
- message: string
- then:
- - lambda: id(disp1).set_component_text_printf(component.c_str(), "%s", message.c_str());
- - service: send_command_value
- variables:
- component: string
- message: int
- then:
- - lambda: id(disp1).set_component_value(component.c_str(), message);
- - service: send_command_hide
- variables:
- component: string
- then:
- - lambda: id(disp1).hide_component(component.c_str());
- - service: send_command_show
- variables:
- component: string
- then:
- - lambda: id(disp1).show_component(component.c_str());
- - service: send_command_show_all
- then:
- - lambda: id(disp1).show_component("255");
- - service: set_component_color
- variables:
- component: string
- foreground: int[]
- background: int[]
- then:
- - lambda: id(set_component_color).execute(component, foreground, background);
- - service: notification_show
- variables:
- label: string
- text: string
- then:
- - lambda: |-
- ESP_LOGV("service.notification_show", "Starting");
- id(disp1).send_command_printf("is_notification=1");
- id(disp1).goto_page("notification");
- id(disp1).set_component_text_printf("notification.notifi_label", "%s", label.c_str());
- id(display_wrapped_text).execute("notification.notifi_text01", text.c_str(), id(display_mode) == 2 ? 23 : 32);
- id(notification_label).publish_state(label.c_str());
- id(notification_text).publish_state(text.c_str());
- id(timer_reset_all).execute(id(current_page).state.c_str());
- - switch.turn_on: notification_unread
- - if:
- condition:
- - switch.is_on: notification_sound
- then:
- - rtttl.play: two short:d=4,o=5,b=100:16e6,16e6
- - service: notification_clear
- then:
- - logger.log: Service: notification_clear
- - lambda: |-
- id(disp1).send_command_printf("is_notification=0");
- id(notification_label).publish_state("");
- id(notification_text).publish_state("");
- - switch.turn_off: notification_unread
- - service: open_entity_settings_page
- variables:
- page: string
- page_label: string
- page_icon: string
- page_icon_color: int[]
- entity: string
- back_page: string
- then:
- - lambda: |-
- id(entity_id) = entity;
- std::string cmd_page = std::string("page ") + page.c_str();
- id(disp1).send_command_printf(cmd_page.c_str());
- id(disp1).set_component_text_printf("page_label", "%s", page_label.c_str());
- id(disp1).set_component_text_printf("back_page", "%s", back_page.c_str());
- if (page == "climate")
- {
- if (entity == "embedded_climate") id(addon_climate_set_climate_friendly_name).execute(page_label.c_str());
- id(disp1).set_component_value("embedded", (entity == "embedded_climate") ? 1 : 0);
- }
- else
- {
- if ((page_icon.c_str() != std::string()) and (page_icon.c_str() != ""))
- id(disp1).set_component_text_printf("icon_state", "%s", page_icon.c_str());
- id(set_component_color).execute("icon_state", page_icon_color, {});
- }
- - service: play_rtttl
- variables:
- song_str: string
- then:
- - rtttl.play:
- rtttl: !lambda |-
- return song_str;
- - service: qrcode
- variables:
- title: string
- qrcode: string
- show: bool
- then:
- - lambda: |-
- id(disp1).set_component_text_printf("qrcode.qrcode_label", "%s", title.c_str());
- id(disp1).set_component_text_printf("qrcode.qrcode_value", "%s", qrcode.c_str());
- if (show) id(disp1).goto_page("qrcode");
- - [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:293]
- service: set_climate
- variables:
- current_temp: float
- target_temp: float
- temp_step: int
- total_steps: int
- temp_offset: int
- climate_icon: string
- embedded_climate: bool
- entity: string
- then: [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:304]
- - lambda: if (id(current_page).state == "climate") id(entity_id) = entity;
- - [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:307]
- script.execute: [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:308]
- id: set_climate
- [current_temp] is an invalid option for [script.execute].
- current_temp: !lambda |-
- return current_temp; [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:309]
- [target_temp] is an invalid option for [script.execute].
- target_temp: !lambda |-
- return target_temp; [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:310]
- [temp_step] is an invalid option for [script.execute].
- temp_step: !lambda |-
- return temp_step; [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:311]
- [total_steps] is an invalid option for [script.execute].
- total_steps: !lambda |-
- return total_steps; [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:312]
- [temp_offset] is an invalid option for [script.execute].
- temp_offset: !lambda |-
- return temp_offset; [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:313]
- [climate_icon] is an invalid option for [script.execute].
- climate_icon: !lambda |-
- return climate_icon; [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:314]
- [embedded_climate] is an invalid option for [script.execute].
- embedded_climate: !lambda |-
- return embedded_climate; [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:315]
- - service: set_button
- variables:
- btn_id: string
- btn_pic: int
- btn_bg: int[]
- btn_icon_font: int[]
- btn_txt_font: int[]
- btn_bri_font: int[]
- btn_icon: string
- btn_label: string
- btn_bri_txt: string
- then:
- - lambda: |-
- std::string btnicon = btn_id.c_str() + std::string("icon");
- std::string btntext = btn_id.c_str() + std::string("text");
- std::string btnbri = btn_id.c_str() + std::string("bri");
- id(disp1).send_command_printf("%spic.pic=%i", btn_id.c_str(), btn_pic);
- id(set_component_color).execute(btnicon.c_str(), btn_icon_font, btn_bg);
- id(set_component_color).execute(btntext.c_str(), btn_txt_font, btn_bg);
- id(set_component_color).execute(btnbri.c_str(), btn_bri_font, btn_bg);
- id(disp1).set_component_text_printf(btnicon.c_str(), "%s", btn_icon.c_str());
- id(display_wrapped_text).execute(btntext.c_str(), btn_label.c_str(), 10);
- if (strcmp(btn_bri_txt.c_str(), "0") != 0)
- id(disp1).set_component_text_printf(btnbri.c_str(), "%s", btn_bri_txt.c_str());
- else
- id(disp1).set_component_text_printf(btnbri.c_str(), " ");
- - service: wake_up
- variables:
- reset_timer: bool
- then:
- - lambda: |-
- if (id(current_page).state == "screensaver") id(disp1).goto_page(id(wakeup_page_name).state.c_str());
- if (reset_timer)
- id(timer_reset_all).execute(id(wakeup_page_name).state.c_str());
- else
- {
- id(timer_sleep).execute(id(wakeup_page_name).state.c_str(), int(id(timeout_sleep).state));
- id(timer_dim).execute(id(wakeup_page_name).state.c_str(), int(id(timeout_dim).state));
- }
- - service: set_entity
- variables:
- ent_id: string
- ent_icon: string
- ent_label: string
- ent_value: string
- ent_value_xcen: string
- then:
- - lambda: |-
- std::string enticon = ent_id.c_str() + std::string("_pic");
- std::string entlabel = ent_id.c_str() + std::string("_label");
- std::string entxcen = ent_id.c_str() + std::string(".xcen=") + ent_value_xcen.c_str();
- id(disp1).set_component_text_printf(enticon.c_str(), "%s", ent_icon.c_str());
- if (strcmp(ent_icon.c_str(), "0") != 0) id(disp1).set_component_text_printf(enticon.c_str(), "%s", ent_icon.c_str());
- id(disp1).set_component_text_printf(entlabel.c_str(), "%s", ent_label.c_str());
- id(disp1).set_component_text_printf(ent_id.c_str(), "%s", ent_value.c_str());
- if (strcmp(ent_value_xcen.c_str(), "0") != 0) id(disp1).send_command_printf("%s", entxcen.c_str());
- - service: global_settings
- variables:
- blueprint_version: string
- relay1_local_control: bool
- relay1_icon: string
- relay1_icon_color: int
- relay1_fallback: bool
- relay2_local_control: bool
- relay2_icon: string
- relay2_icon_color: int
- relay2_fallback: bool
- date_color: int
- time_format: string
- time_color: int
- embedded_climate: bool
- embedded_indoor_temperature: bool
- temperature_unit_is_fahrenheit: bool
- mui_please_confirm: string
- then:
- - lambda: |-
- // Blueprint version
- id(version_blueprint) = blueprint_version;
- id(check_versions).execute();
- // Relays
- id(relay1_local).publish_state(relay1_local_control);
- id(relay2_local).publish_state(relay2_local_control);
- id(home_relay1_icon) = relay1_icon.c_str();
- id(home_relay2_icon) = relay2_icon.c_str();
- id(home_relay1_icon_color) = relay1_icon_color;
- id(home_relay2_icon_color) = relay2_icon_color;
- id(relay_1_fallback) = relay1_fallback;
- id(relay_2_fallback) = relay2_fallback;
- // Localization
- id(mui_time_format) = time_format;
- // Date/Time colors
- id(home_date_color) = date_color;
- id(home_time_color) = time_color;
- // Embedded thermostat
- id(is_embedded_thermostat) = embedded_climate;
- // Indoor temperature
- id(embedded_indoor_temp) = embedded_indoor_temperature;
- id(temp_unit_fahrenheit) = temperature_unit_is_fahrenheit;
- id(display_embedded_temp).execute();
- // Confirm page
- id(display_wrapped_text).execute("confirm.title", mui_please_confirm.c_str(), 15);
- // Refresh colors of global components
- id(disp1).set_component_font_color("home.date", id(home_date_color));
- id(disp1).set_component_font_color("home.time", id(home_time_color));
- id(disp1).set_component_font_color("home.icon_top_01", id(home_relay1_icon_color));
- id(disp1).set_component_font_color("home.icon_top_02", id(home_relay2_icon_color));
- // Update home page
- id(update_page_home).execute();
- - if:
- condition:
- - text_sensor.state:
- id: current_page
- state: boot
- then:
- - lambda: |-
- id(disp1).set_component_text_printf("boot.bluep_version", "%s", blueprint_version.c_str());
- - wait_until:
- condition:
- - not:
- - text_sensor.state:
- id: current_page
- state: boot
- timeout: 2s
- - if:
- condition:
- - text_sensor.state:
- id: current_page
- state: boot
- then:
- - if:
- condition:
- switch.is_on: notification_sound
- then:
- - rtttl.play:
- rtttl: two short:d=4,o=5,b=100:16e6,16e6
- - lambda: |-
- ESP_LOGD("service.global_settings", "Jump to wake-up page: %s", id(wakeup_page_name).state.c_str());
- id(disp1).goto_page(id(wakeup_page_name).state.c_str());
- id(timer_reset_all).execute(id(wakeup_page_name).state.c_str());
- - service: page_home
- variables:
- notification_icon: string
- notification_icon_color_normal: int[]
- notification_icon_color_unread: int[]
- qrcode: bool
- qrcode_icon: string
- qrcode_icon_color: int[]
- entities_pages: bool
- entities_pages_icon: string
- entities_pages_icon_color: int[]
- alarm_state: string
- then:
- - lambda: |-
- // Notification button
- id(disp1).send_command_printf("is_notification=%i", (id(notification_text).state.empty() and id(notification_label).state.empty()) ? 0 : 1);
- id(disp1).set_component_text_printf("home.bt_notific", "%s", notification_icon.c_str());
- id(set_component_color).execute("home.bt_notific", id(notification_unread).state ? notification_icon_color_unread : notification_icon_color_normal, {});
- id(home_notify_icon_color_normal) = notification_icon_color_normal;
- id(home_notify_icon_color_unread) = notification_icon_color_unread;
- // QRCode button
- id(disp1).send_command_printf("is_qrcode=%i", (qrcode) ? 1 : 0);
- id(disp1).set_component_text_printf("home.bt_qrcode", "%s", qrcode_icon.c_str());
- id(set_component_color).execute("home.bt_qrcode", qrcode_icon_color, {});
- // Entities pages button
- id(disp1).send_command_printf("is_entities=%i", (entities_pages) ? 1 : 0);
- id(disp1).set_component_text_printf("home.bt_entities", "%s", entities_pages_icon.c_str());
- id(set_component_color).execute("home.bt_entities", entities_pages_icon_color, {});
- // Alarm button
- id(disp1).send_command_printf("is_alarm=%i", (alarm_state=="" or alarm_state.empty()) ? 0 : 1);
- id(update_alarm_icon).execute("home.bt_alarm", alarm_state.c_str());
- - service: page_settings
- variables:
- reboot: string
- brightness: string
- bright: string
- dim: string
- then:
- - lambda: |-
- if (not reboot.empty()) id(disp1).set_component_text_printf("settings.lbl_reboot", " %s", reboot.c_str());
- id(disp1).set_component_text_printf("settings.lbl_brightness", " %s", brightness.c_str());
- id(display_wrapped_text).execute("settings.lbl_bright", bright.c_str(), id(display_mode) == 2 ? 25 : 10);
- id(display_wrapped_text).execute("settings.lbl_dim", dim.c_str(), id(display_mode) == 2 ? 25 : 10);
- - service: alarm_settings
- variables:
- page_title: string
- state: string
- supported_features: int
- code_format: string
- code_arm_required: bool
- entity: string
- mui_alarm: string[]
- then:
- - lambda: |-
- // set alarm icon on home page
- id(disp1).send_command_printf("is_alarm=%i", (state=="" or state.empty()) ? 0 : 1);
- id(update_alarm_icon).execute("home.bt_alarm", state.c_str());
- // Is page Alarm visible?
- if (id(current_page).state=="alarm")
- { // Update alarm page
- id(entity_id) = entity;
- // Alarm page - Header
- id(update_alarm_icon).execute("icon_state", state.c_str());
- id(disp1).set_component_text_printf("page_label", "%s", page_title.c_str());
- id(disp1).set_component_text_printf("code_format", "%s", code_format.c_str());
- if (code_arm_required) id(disp1).set_component_text_printf("code_arm_req", "1"); else id(disp1).set_component_text_printf("code_arm_req", "0");
- // Alarm page - Button's icons
- id(disp1).set_component_text_printf("bt_home_icon", "\uE689"); //mdi:shield-home
- id(disp1).set_component_text_printf("bt_away_icon", "\uE99C"); //mdi:shield-lock
- id(disp1).set_component_text_printf("bt_night_icon", "\uF827"); //mdi:shield-moon
- id(disp1).set_component_text_printf("bt_vacat_icon", "\uE6BA"); //mdi:shield-airplane
- id(disp1).set_component_text_printf("bt_bypass_icon", "\uE77F"); //mdi:shield-half-full
- id(disp1).set_component_text_printf("bt_disarm_icon", "\uE99D"); //mdi:shield-off
- // Alarm page - Button's text
- id(display_wrapped_text).execute("bt_home_text", mui_alarm[0].c_str(), 10);
- id(display_wrapped_text).execute("bt_away_text", mui_alarm[1].c_str(), 10);
- id(display_wrapped_text).execute("bt_night_text", mui_alarm[2].c_str(), 10);
- id(display_wrapped_text).execute("bt_vacat_text", mui_alarm[3].c_str(), 10);
- id(display_wrapped_text).execute("bt_bypass_text", mui_alarm[4].c_str(), 10);
- id(display_wrapped_text).execute("bt_disarm_text", mui_alarm[5].c_str(), 10);
- // Alarm page - Buttons
- if (supported_features & 1) // Alarm - Button - Home
- {
- id(disp1).send_command_printf("bt_home_pic.pic=%i", (state=="armed_home") ? 43 : 42);
- id(disp1).set_component_background_color("bt_home_text", (state=="armed_home") ? 19818 : 52857);
- id(disp1).set_component_background_color("bt_home_icon", (state=="armed_home") ? 19818 : 52857);
- id(disp1).set_component_font_color("bt_home_text", (state=="armed_home") ? 65535 : 0);
- id(disp1).set_component_font_color("bt_home_icon", (state=="armed_home") ? 65535 : 0);
- if (state=="armed_home") id(disp1).hide_component("bt_home"); else id(disp1).show_component("bt_home");
- }
- if (supported_features & 2) // Alarm - Button - Away
- {
- id(disp1).send_command_printf("bt_away_pic.pic=%i", (state=="armed_away") ? 43 : 42);
- id(disp1).set_component_background_color("bt_away_text", (state=="armed_away") ? 19818 : 52857);
- id(disp1).set_component_background_color("bt_away_icon", (state=="armed_away") ? 19818 : 52857);
- id(disp1).set_component_font_color("bt_away_text", (state=="armed_away") ? 65535 : 0);
- id(disp1).set_component_font_color("bt_away_icon", (state=="armed_away") ? 65535 : 0);
- if (state=="armed_away") id(disp1).hide_component("bt_away"); else id(disp1).show_component("bt_away");
- }
- if (supported_features & 4) // Alarm - Button - Night
- {
- id(disp1).send_command_printf("bt_night_pic.pic=%i", (state=="armed_night") ? 43 : 42);
- id(disp1).set_component_background_color("bt_night_text", (state=="armed_night") ? 19818 : 52857);
- id(disp1).set_component_background_color("bt_night_icon", (state=="armed_night") ? 19818 : 52857);
- id(disp1).set_component_font_color("bt_night_text", (state=="armed_night") ? 65535 : 0);
- id(disp1).set_component_font_color("bt_night_icon", (state=="armed_night") ? 65535 : 0);
- if (state=="armed_night") id(disp1).hide_component("bt_night"); else id(disp1).show_component("bt_night");
- }
- if (supported_features & 32) // Alarm - Button - Vacation
- {
- id(disp1).send_command_printf("bt_vacat_pic.pic=%i", (state=="armed_vacation") ? 43 : 42);
- id(disp1).set_component_background_color("bt_vacat_text", (state=="armed_vacation") ? 19818 : 52857);
- id(disp1).set_component_background_color("bt_vacat_icon", (state=="armed_vacation") ? 19818 : 52857);
- id(disp1).set_component_font_color("bt_vacat_text", (state=="armed_vacation") ? 65535 : 0);
- id(disp1).set_component_font_color("bt_vacat_icon", (state=="armed_vacation") ? 65535 : 0);
- if (state=="armed_vacation") id(disp1).hide_component("bt_vacat"); else id(disp1).show_component("bt_vacat");
- }
- if (supported_features & 16) // Alarm - Button - Custom bypass
- {
- id(disp1).send_command_printf("bt_bypass_pic.pic=%i", (state=="armed_bypass") ? 43 : 42);
- id(disp1).set_component_background_color("bt_bypass_text", (state=="armed_bypass") ? 19818 : 52857);
- id(disp1).set_component_background_color("bt_bypass_icon", (state=="armed_bypass") ? 19818 : 52857);
- id(disp1).set_component_font_color("bt_bypass_text", (state=="armed_bypass") ? 65535 : 0);
- id(disp1).set_component_font_color("bt_bypass_icon", (state=="armed_bypass") ? 65535 : 0);
- if (state=="armed_bypass") id(disp1).hide_component("bt_bypass"); else id(disp1).show_component("bt_bypass");
- }
- if ( true ) // Alarm - Button - Disarm
- {
- id(disp1).send_command_printf("bt_disarm_pic.pic=%i", (state=="disarmed") ? 43 : 42);
- id(disp1).set_component_background_color("bt_disarm_text", (state=="disarmed") ? 19818 : 52857);
- id(disp1).set_component_background_color("bt_disarm_icon", (state=="disarmed") ? 19818 : 52857);
- id(disp1).set_component_font_color("bt_disarm_text", (state=="disarmed") ? 65535 : 0);
- id(disp1).set_component_font_color("bt_disarm_icon", (state=="disarmed") ? 65535 : 0);
- if (state=="disarmed") id(disp1).hide_component("bt_disarm"); else id(disp1).show_component("bt_disarm");
- }
- }
- - service: media_player
- variables:
- entity: string
- state: string
- is_volume_muted: bool
- friendly_name: string
- volume_level: int
- media_title: string
- media_artist: string
- media_duration: float
- media_position: float
- media_position_delta: float
- supported_features: int
- then:
- - lambda: |-
- if (id(current_page).state == "media_player")
- {
- id(entity_id) = entity;
- id(disp1).set_component_text_printf("page_label", "%s", friendly_name.c_str());
- id(display_wrapped_text).execute("track", media_title.c_str(), id(display_mode) == 2 ? 16 : 27);
- id(display_wrapped_text).execute("artist", media_artist.c_str(), id(display_mode) == 2 ? 26 : 40);
- // on/off button
- if (supported_features & 128 and state == "off") //TURN_ON
- {
- id(set_component_color).execute("bt_on_off", { 65535 }, {} );
- id(disp1).show_component("bt_on_off");
- }
- else if (supported_features & 256 and state != "off") //TURN_OFF
- {
- id(set_component_color).execute("bt_on_off", { 10597 }, {} );
- id(disp1).show_component("bt_on_off");
- }
- else id(disp1).hide_component("bt_on_off");
- // play/pause button
- if ((supported_features & 512 or supported_features & 16384) and state != "playing" and state != "off") //PLAY_MEDIA+PLAY
- {
- id(disp1).set_component_text_printf("bt_play_pause", "%s", "\uE409"); // mdi:play
- id(disp1).show_component("bt_play_pause");
- }
- else if (supported_features & 1 and state == "playing" ) //PAUSE
- {
- id(disp1).set_component_text_printf("bt_play_pause", "%s", "\uE3E3"); // mdi:pause
- id(disp1).show_component("bt_play_pause");
- }
- else id(disp1).hide_component("bt_play_pause");
- // bt_prev button - PREVIOUS_TRACK
- if (supported_features & 16 and state != "off") id(disp1).show_component("bt_prev"); else id(disp1).hide_component("bt_prev");
- // bt_next button - NEXT_TRACK
- if (supported_features & 32 and state != "off") id(disp1).show_component("bt_next"); else id(disp1).hide_component("bt_next");
- // Stop button - STOP
- //if (supported_features & 4096 and (state == "playing" or state == "paused")) id(disp1).show_component("bt_stop"); else id(disp1).hide_component("bt_stop");
- // mute/unmute button - VOLUME_MUTE
- id(disp1).set_component_value("is_muted", (is_volume_muted) ? 1 : 0);
- if (supported_features & 8 and is_volume_muted) // unmute
- {
- id(disp1).set_component_text_printf("bt_mute", "%s", "\uEE07"); // mdi:volume-variant-off
- id(disp1).show_component("bt_mute");
- }
- else if (supported_features & 8) // mute
- {
- id(disp1).set_component_text_printf("bt_mute", "%s", "\uE57E"); // mdi:volume-low
- id(disp1).show_component("bt_mute");
- }
- else id(disp1).hide_component("bt_mute");
- // VOLUME_SET
- if (supported_features & 4)
- {
- if (volume_level != id(last_volume_level))
- {
- id(last_volume_level) = volume_level;
- id(disp1).set_component_text_printf("vol_text", "%i%%", volume_level);
- id(disp1).set_component_value("vol_slider", volume_level);
- }
- id(disp1).show_component("vol_slider");
- id(disp1).show_component("bt_vol_down");
- id(disp1).show_component("bt_vol_up");
- id(disp1).show_component("vol_text");
- }
- else
- {
- id(disp1).hide_component("vol_slider");
- id(disp1).hide_component("bt_vol_down");
- id(disp1).hide_component("bt_vol_up");
- id(disp1).hide_component("vol_text");
- }
- if (media_duration > 0)
- {
- if (media_duration != id(last_media_duration) or media_position != id(last_media_position))
- {
- id(last_media_duration) = media_duration;
- id(last_media_position) = media_position;
- id(disp1).set_component_value("prg_current", int(round(min(media_position + media_position_delta, media_duration))));
- }
- id(disp1).set_component_value("prg_total", int(round(media_duration)));
- id(disp1).send_command_printf("prg_timer.en=%i", (state == "playing") ? 1 : 0);
- id(disp1).show_component("time_current");
- id(disp1).show_component("time_total");
- id(disp1).show_component("time_progress");
- }
- else
- {
- id(disp1).send_command_printf("prg_timer.en=0");
- id(disp1).hide_component("time_current");
- id(disp1).hide_component("time_total");
- id(disp1).hide_component("time_progress");
- }
- }
- binary_sensor.gpio: [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:881]
- name: nspanel1 Left Button
- platform: gpio
- id: left_button
- pin:
- number: 14
- inverted: True
- on_multi_click: [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:888]
- - [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:888]
- timing:
- - ON for at least 0.8s
- then: [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:891]
- - logger.log: Left button - Long click
- - [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:892]
- script.execute: [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:893]
- id: ha_button
- [page] is an invalid option for [script.execute].
- page: !lambda |-
- return id(current_page).state; [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:894]
- [component] is an invalid option for [script.execute].
- component: hw_bt_left [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:895]
- [command] is an invalid option for [script.execute].
- command: long_click [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:896]
- - timing:
- - ON for at most 0.8s
- then:
- - logger.log: Left button - Short click
- - if:
- condition:
- or:
- - switch.is_on: relay1_local
- - and:
- - lambda: !lambda |-
- return id(relay_1_fallback);
- - or:
- - not:
- - api.connected:
- - not:
- - wifi.connected:
- then:
- - switch.toggle: relay_1
- - script.execute:
- id: ha_button
- page: !lambda |-
- return id(current_page).state;
- component: hw_bt_left
- command: short_click
- binary_sensor.gpio: [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:921]
- name: nspanel1 Right Button
- platform: gpio
- id: right_button
- pin:
- number: 27
- inverted: True
- on_multi_click: [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:928]
- - [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:928]
- timing:
- - ON for at least 0.8s
- then: [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:930]
- - logger.log: Right button - Long click
- - [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:931]
- script.execute: [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:932]
- id: ha_button
- [page] is an invalid option for [script.execute].
- page: !lambda |-
- return id(current_page).state; [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:933]
- [component] is an invalid option for [script.execute].
- component: hw_bt_right [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:934]
- [command] is an invalid option for [script.execute].
- command: long_click [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:935]
- - timing:
- - ON for at most 0.8s
- then:
- - logger.log: Right button - Short click
- - if:
- condition:
- or:
- - switch.is_on: relay2_local
- - and:
- - lambda: !lambda |-
- return id(relay_2_fallback);
- - or:
- - not:
- - api.connected:
- - not:
- - wifi.connected:
- then:
- - switch.toggle: relay_2
- - script.execute:
- id: ha_button
- page: !lambda |-
- return id(current_page).state;
- component: hw_bt_right
- command: short_click
- binary_sensor.template: [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:977]
- name: nspanel1 Nextion display
- id: nextion_init
- platform: template
- device_class: connectivity
- [publish_initial_state] is an invalid option for [binary_sensor.template]. Please check the indentation.
- publish_initial_state: True [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:981]
- entity_category: diagnostic
- icon: mdi:tablet-dashboard
- switch.template: [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:1434]
- name: nspanel1 Notification unread
- platform: template
- id: notification_unread
- entity_category: config
- optimistic: True
- [restore_mode] is an invalid option for [switch.template]. Did you mean [restore_state]?
- restore_mode: ALWAYS_OFF [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:1439]
- on_turn_on:
- - lambda: |-
- id(set_component_color).execute("home.bt_notific", id(home_notify_icon_color_unread), {});
- on_turn_off:
- - lambda: |-
- id(set_component_color).execute("home.bt_notific", id(home_notify_icon_color_normal), {});
- switch.template: [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:1446]
- name: nspanel1 Notification sound
- platform: template
- id: notification_sound
- entity_category: config
- optimistic: True
- [restore_mode] is an invalid option for [switch.template]. Did you mean [restore_state]?
- restore_mode: RESTORE_DEFAULT_OFF [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:1451]
- switch.template: [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:1496]
- name: nspanel1 Relay 1 Local
- platform: template
- id: relay1_local
- entity_category: config
- optimistic: True
- [restore_mode] is an invalid option for [switch.template]. Did you mean [restore_state]?
- restore_mode: RESTORE_DEFAULT_OFF [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:1501]
- internal: True
- on_turn_on:
- - logger.log: Relay 1 Local turned On!
- on_turn_off:
- - logger.log: Relay 1 Local turned Off!
- switch.template: [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:1507]
- name: nspanel1 Relay 2 Local
- platform: template
- id: relay2_local
- entity_category: config
- optimistic: True
- [restore_mode] is an invalid option for [switch.template]. Did you mean [restore_state]?
- restore_mode: RESTORE_DEFAULT_OFF [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:1512]
- internal: True
- on_turn_on:
- - logger.log: Relay 2 Local turned On!
- on_turn_off:
- - logger.log: Relay 2 Local turned Off!
- display.nextion: [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:1663]
- id: disp1
- platform: nextion
- uart_id: tf_uart
- tft_url: http://HOME-ASSISTANT-IP:8123/local/nspanel.tft
- [on_page] is an invalid option for [display.nextion]. Did you mean [on_wake]?
- on_page: [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:1668]
- - lambda: ESP_LOGW("display.disp1", "NEXTION PAGE CHANGED");
- on_setup:
- then:
- - lambda: |-
- id(disp1).goto_page("boot");
- id(disp1).set_component_text_printf("boot.esph_version", "%s", "4.0.2"); // ### esphome-version ###
- id(disp1).show_component("bt_reboot");
- id(timer_reset_all).execute("boot");
- - wait_until: api.connected
- - lambda: |-
- id(disp1).set_component_text_printf("boot.ip_addr", "%s", id(ip_address).state.c_str());
- auto ha_event = new esphome::api::CustomAPIDevice();
- ha_event->fire_homeassistant_event("esphome.nspanel_ha_blueprint",
- {
- {"type", "boot"},
- {"step", "start"}
- });
- - delay: 1s
- - lambda: |-
- // Set dimming values
- id(display_brightness).publish_state(id(display_brightness_global));
- id(display_dim_brightness).publish_state(id(display_dim_brightness_global));
- id(disp1).send_command_printf("brightness=%i", id(display_brightness_global));
- id(disp1).send_command_printf("settings.brightslider.val=%i", id(display_brightness_global));
- id(disp1).send_command_printf("brightness_dim=%i", id(display_dim_brightness_global));
- id(disp1).send_command_printf("settings.dimslider.val=%i", id(display_dim_brightness_global));
- id(nextion_init).publish_state(true);
- auto ha_event = new esphome::api::CustomAPIDevice();
- ha_event->fire_homeassistant_event("esphome.nspanel_ha_blueprint",
- {
- {"type", "boot"},
- {"step", "nextion_init"}
- });
- id(home_relay1_icon) = "\uE3A5";
- id(home_relay1_icon) = "\uE3A8";
- id(timer_reset_all).execute("boot");
- - lambda: |-
- id(disp1).send_command_printf("is_notification=0");
- id(notification_label).publish_state("");
- id(notification_text).publish_state("");
- - switch.turn_off: notification_unread
- - logger.log: Nextion start - Done!
- script: [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:1713]
- 'id' is a required option for [script].
- - [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:1713]
- Unable to find action with the name 'id'.
- id: timer_reset_all [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:1713]
- mode: restart
- parameters:
- page: string
- then:
- - lambda: |-
- ESP_LOGV("script.timer_reset_all", "Reset timers");
- id(timer_page).execute(page.c_str(), int(id(timeout_page).state));
- id(timer_dim).execute(page.c_str(), int(id(timeout_dim).state));
- id(timer_sleep).execute(page.c_str(), int(id(timeout_sleep).state));
- - id: timer_page
- mode: restart
- parameters:
- page: string
- timeout: int
- then:
- - lambda: ESP_LOGV("script.timer_page", "Reset timer: %is", timeout);
- - if:
- condition:
- - lambda: |-
- return (page != "screensaver" and page != "boot" and page != "home" and timeout >= 1);
- then:
- - delay: !lambda |-
- return (timeout *1000);
- - lambda: |-
- ESP_LOGD("script.timer_page", "Timed out on page: %s", id(current_page).state.c_str());
- if (id(current_page).state != "screensaver" and id(current_page).state != "boot" and id(current_page).state != "home" and timeout >= 1)
- {
- ESP_LOGD("script.timer_page", "Fallback to page Home");
- id(disp1).goto_page("home");
- }
- - id: timer_dim
- mode: restart
- parameters:
- page: string
- timeout: int
- then:
- - lambda: |-
- ESP_LOGV("script.timer_dim", "Reset timer: %is", timeout);
- if (id(is_dim_brightness))
- {
- if (page != "screensaver" and page != "boot")
- {
- ESP_LOGD("script.timer_dim", "Waking up on page: %s", page.c_str());
- id(disp1).send_command_printf("wakeup_timer.en=1");
- }
- id(is_dim_brightness) = false;
- }
- - if:
- condition:
- - lambda: !lambda |-
- return (timeout >= 1);
- then:
- - delay: !lambda |-
- return (timeout *1000);
- - lambda: |-
- if (id(current_page).state != "screensaver" and id(current_page).state != "boot" and timeout >= 1)
- {
- ESP_LOGD("script.timer_dim", "Dimming the display to %i%%", id(display_dim_brightness_global));
- id(disp1).send_command_printf("dim=%i", id(display_dim_brightness_global));
- id(is_dim_brightness) = true;
- }
- - id: timer_sleep
- mode: restart
- parameters:
- page: string
- timeout: int
- then:
- - lambda: ESP_LOGV("script.timer_sleep", "Reset timer: %is", timeout);
- - if:
- condition:
- - lambda: !lambda |-
- return (timeout >= 1);
- then:
- - delay: !lambda |-
- return (timeout *1000);
- - lambda: |-
- if (id(current_page).state != "screensaver" and id(current_page).state != "boot" and timeout >= 1)
- {
- ESP_LOGD("script.timer_sleep", "Going to sleep");
- id(disp1).goto_page("screensaver");
- id(is_dim_brightness) = true;
- }
- - id: set_climate
- mode: restart
- parameters:
- current_temp: float
- target_temp: float
- temp_step: int
- total_steps: int
- temp_offset: int
- climate_icon: string
- embedded_climate: bool
- then:
- - if:
- condition:
- - text_sensor.state:
- id: current_page
- state: climate
- then:
- - lambda: |-
- id(addon_climate_set_climate).execute(embedded_climate);
- id(disp1).send_command_printf("climateslider.maxval=%i", total_steps);
- id(disp1).set_component_value("temp_offset", temp_offset);
- id(disp1).set_component_value("temp_step", temp_step);
- id(disp1).set_component_text_printf("current_temp", "%.1f°", current_temp);
- id(disp1).show_component("current_temp");
- id(disp1).show_component("current_icon");
- if (target_temp > -999)
- {
- float slider_val = round(((10*target_temp) - temp_offset) / temp_step);
- id(disp1).set_component_value("climateslider", slider_val);
- id(disp1).set_component_text_printf("target_temp", "%.1f°", target_temp);
- id(disp1).set_component_text_printf("target_icon", "%s", climate_icon.c_str());
- id(disp1).show_component("target_icon");
- id(disp1).show_component("target_temp");
- id(disp1).show_component("climateslider");
- id(disp1).show_component("decrease_temp");
- id(disp1).show_component("increase_temp");
- }
- else
- {
- id(disp1).hide_component("target_icon");
- id(disp1).hide_component("target_temp");
- id(disp1).hide_component("climateslider");
- id(disp1).hide_component("decrease_temp");
- id(disp1).hide_component("increase_temp");
- }
- id(disp1).set_component_value("embedded", (embedded_climate) ? 1 : 0);
- - id: refresh_datetime
- mode: restart
- then:
- - lambda: |-
- std::string time_format_str = id(mui_time_format);
- if (time_format_str.find("%p") != std::string::npos)
- {
- std::string meridiem_text = id(time_provider).now().strftime("%p");
- id(disp1).set_component_text_printf("home.meridiem", "%s", meridiem_text.c_str());
- }
- else { id(disp1).set_component_text_printf("home.meridiem", " "); }
- if (time_format_str.find("%-H") != std::string::npos) { time_format_str = time_format_str.replace(time_format_str.find("%-H"), sizeof("%-H")-1, to_string((int)(id(time_provider).now().hour))); }
- if (time_format_str.find("%-I") != std::string::npos)
- {
- if (id(time_provider).now().hour>12)
- {
- time_format_str = time_format_str.replace(time_format_str.find("%-I"), sizeof("%-I")-1, to_string((int)(id(time_provider).now().hour-12)));
- }
- else if (id(time_provider).now().hour==0)
- {
- time_format_str = time_format_str.replace(time_format_str.find("%-I"), sizeof("%-I")-1, "12");
- }
- else
- {
- time_format_str = time_format_str.replace(time_format_str.find("%-I"), sizeof("%-I")-1, to_string((int)(id(time_provider).now().hour)));
- }
- }
- std::string time_text = id(time_provider).now().strftime(time_format_str);
- id(disp1).set_component_text_printf("home.time", "%s", time_text.c_str());
- - id: refresh_relays
- mode: restart
- then:
- - lambda: |-
- // Chips - Relays
- if (id(relay_1).state) id(disp1).set_component_text_printf("home.icon_top_01", "%s", id(home_relay1_icon).c_str());
- else id(disp1).set_component_text_printf("icon_top_01", "\uFFFF");
- if (id(relay_2).state) id(disp1).set_component_text_printf("home.icon_top_02", "%s", id(home_relay2_icon).c_str());
- else id(disp1).set_component_text_printf("home.icon_top_02", "\uFFFF");
- // Hardware buttons - Fallback mode
- if (id(relay_1).state and id(relay1_local).state) id(disp1).send_command_printf("home.left_bt_pic.val=%i", (id(relay_1).state) ? 1 : 0);
- if (id(relay_2).state and id(relay2_local).state) id(disp1).send_command_printf("home.right_bt_pic.val=%i", (id(relay_2).state) ? 1 : 0);
- - id: refresh_wifi_icon
- mode: restart
- then:
- - if:
- condition:
- - binary_sensor.is_on: nextion_init
- then:
- - if:
- condition:
- wifi.connected:
- then:
- - if:
- condition:
- api.connected:
- then:
- - lambda: id(disp1).send_command_printf("api=1");
- - lambda: id(disp1).set_component_text_printf("home.wifi_icon", "%s", "\uE5A8");
- - lambda: id(disp1).set_component_font_color("home.wifi_icon", 33808);
- else:
- - lambda: id(disp1).send_command_printf("api=0");
- - lambda: id(disp1).set_component_text_printf("home.wifi_icon", "%s", "\uF256");
- - lambda: id(disp1).set_component_font_color("home.wifi_icon", 63488);
- else:
- - lambda: id(disp1).send_command_printf("api=0");
- - lambda: id(disp1).set_component_text_printf("home.wifi_icon", "%s", "\uE5A9");
- - lambda: id(disp1).set_component_font_color("home.wifi_icon", 63488);
- - id: update_page_home
- mode: restart
- then:
- - if:
- condition:
- - text_sensor.state:
- id: current_page
- state: home
- then:
- - script.execute: refresh_relays
- - script.execute: refresh_wifi_icon
- - lambda: |-
- id(disp1).send_command_printf("is_notification=%i", (id(notification_text).state.empty() and id(notification_label).state.empty()) ? 0 : 1);
- id(set_component_color).execute("home.bt_notific", id(notification_unread).state ? id(home_notify_icon_color_unread) : id(home_notify_icon_color_normal), {});
- - script.execute: refresh_datetime
- - script.execute: addon_climate_update_page_home
- - id: service_call_alarm_control_panel
- mode: restart
- parameters:
- entity: string
- key: string
- code_format: string
- pin: string
- then:
- - lambda: |-
- std::string service = "";
- if (key=="home") service = "alarm_control_panel.alarm_arm_home";
- else if (key=="away") service = "alarm_control_panel.alarm_arm_away";
- else if (key=="night") service = "alarm_control_panel.alarm_arm_night";
- else if (key=="vacation") service = "alarm_control_panel.alarm_arm_vacation";
- else if (key=="bypass") service = "alarm_control_panel.alarm_arm_custom_bypass";
- else if (key=="disarm") service = "alarm_control_panel.alarm_disarm";
- if (service != "" and not service.empty())
- {
- HomeassistantServiceResponse resp;
- HomeassistantServiceMap resp_kv;
- resp.service = service.c_str();
- resp_kv.key = "entity_id";
- resp_kv.value = entity.c_str();
- resp.data.push_back(resp_kv);
- if (pin != "" and not pin.empty())
- {
- resp_kv.key = "code";
- resp_kv.value = pin.c_str();
- resp.data.push_back(resp_kv);
- }
- id(api_server).send_homeassistant_service_call(resp);
- }
- - id: service_call_climate
- mode: restart
- parameters:
- entity: string
- key: string
- value: string
- embedded: bool
- then:
- - lambda: |-
- if (embedded)
- id(addon_climate_service_call).execute(key.c_str(), value.c_str());
- else if (key == "set_temperature")
- id(ha_call_service).execute("climate.set_temperature", "temperature", to_string(stof(value) / 10), entity.c_str());
- else if (key == "hvac_mode")
- id(ha_call_service).execute("climate.set_hvac_mode", key.c_str(), value.c_str(), entity.c_str());
- - id: ha_call_service
- mode: restart
- parameters:
- service: string
- key: string
- value: string
- entity: string
- then:
- - lambda: |-
- if (service != "" and not service.empty())
- {
- auto ha_event = new esphome::api::CustomAPIDevice();
- ha_event->fire_homeassistant_event("esphome.nspanel_ha_blueprint",
- {
- {"type", "service_call"},
- {"service", service},
- {"entity", entity},
- {"key", key},
- {"value", value}
- });
- }
- - id: ha_button
- mode: parallel
- parameters:
- page: string
- component: string
- command: string
- then:
- - lambda: |-
- id(timer_reset_all).execute(page.c_str());
- auto ha_event = new esphome::api::CustomAPIDevice();
- ha_event->fire_homeassistant_event("esphome.nspanel_ha_blueprint",
- {
- {"type", "button_click"},
- {"page", page},
- {"component", component},
- {"command", command}
- });
- - id: update_alarm_icon
- mode: restart
- parameters:
- component: string
- state: string
- then:
- - lambda: |-
- std::string alarm_icon = "\uEECC"; //mdi:shield-alert-outline
- int alarm_color = 65535;
- if (state == "disarmed")
- {
- alarm_icon = "\uE99B"; //mdi:shield-off-outline
- alarm_color = 65535;
- }
- else if (state == "armed_home")
- {
- alarm_icon = "\uECCA"; //mdi:shield-home-outline
- alarm_color = 19818;
- }
- else if (state == "armed_away")
- {
- alarm_icon = "\uECCB"; //mdi:shield-lock-outline
- alarm_color = 19818;
- }
- else if (state == "armed_night")
- {
- alarm_icon = "\uF828"; //mdi:shield-moon-outline
- alarm_color = 19818;
- }
- else if (state == "armed_vacation")
- {
- alarm_icon = "\uECC6"; //mdi:shield-airplane-outline
- alarm_color = 19818;
- }
- else if (state == "armed_custom_bypass")
- {
- alarm_icon = "\uE77F"; //mdi:shield-half-full
- alarm_color = 19818;
- }
- else if (state == "pending" or state == "arming")
- {
- alarm_icon = "\uE498"; //mdi:shield-outline
- alarm_color = 65024;
- }
- else if (state == "disarming")
- {
- alarm_icon = "\uE99B"; //mdi:shield-off-outline
- alarm_color = 65024;
- }
- else if (state == "triggered")
- {
- alarm_icon = "\uEECC"; //mdi:shield-alert-outline
- alarm_color = 63488;
- }
- id(disp1).set_component_text_printf(component.c_str(), alarm_icon.c_str());
- id(disp1).set_component_font_color(component.c_str(), alarm_color);
- - id: update_climate_icon
- mode: restart
- parameters:
- component: string
- action: int
- mode: int
- then:
- - lambda: |-
- switch (action) // CLIMATE_ACTION_OFF = 0, CLIMATE_ACTION_COOLING = 2, CLIMATE_ACTION_HEATING = 3, CLIMATE_ACTION_IDLE = 4, CLIMATE_ACTION_DRYING = 5, CLIMATE_ACTION_FAN = 6
- {
- case 0: //CLIMATE_ACTION_OFF
- switch (mode) // CLIMATE_MODE_OFF = 0, CLIMATE_MODE_HEAT_COOL = 1, CLIMATE_MODE_COOL = 2, CLIMATE_MODE_HEAT = 3, CLIMATE_MODE_FAN_ONLY = 4, CLIMATE_MODE_DRY = 5, CLIMATE_MODE_AUTO = 6
- {
- case 0: //CLIMATE_MODE_OFF
- id(disp1).set_component_text_printf(component.c_str(), "%s", "\uFFFF"); // (E424) Don't show icon when off
- id(disp1).set_component_font_color(component.c_str(), 35921); // grey (off)
- break;
- case 1: //CLIMATE_MODE_HEAT_COOL
- id(disp1).set_component_text_printf(component.c_str(), "%s", "\uE069"); // mdi:autorenew
- id(disp1).set_component_font_color(component.c_str(), 35921); // grey (off)
- break;
- case 2: //CLIMATE_MODE_COOL
- id(disp1).set_component_text_printf(component.c_str(), "%s", "\uE716"); // mdi:snowflake
- id(disp1).set_component_font_color(component.c_str(), 35921); // grey (off)
- break;
- case 3: //CLIMATE_MODE_HEAT
- id(disp1).set_component_text_printf(component.c_str(), "%s", "\uE237"); // mdi:fire
- id(disp1).set_component_font_color(component.c_str(), 35921); // grey (off)
- break;
- case 4: //CLIMATE_MODE_FAN_ONLY
- id(disp1).set_component_text_printf(component.c_str(), "%s", "\uE20F"); // mdi:fan
- id(disp1).set_component_font_color(component.c_str(), 35921); // grey (off)
- break;
- case 5: //CLIMATE_MODE_DRY
- id(disp1).set_component_text_printf(component.c_str(), "%s", "\uE58D"); // mdi:water-percent
- id(disp1).set_component_font_color(component.c_str(), 35921); // grey (off)
- break;
- case 6: //CLIMATE_MODE_AUTO
- id(disp1).set_component_text_printf(component.c_str(), "%s", "\uEE8D"); // mdi:calendar-sync
- id(disp1).set_component_font_color(component.c_str(), 35921); // grey (off)
- break;
- }
- break;
- case 2: //CLIMATE_ACTION_COOLING
- id(disp1).set_component_text_printf(component.c_str(), "%s", "\uE716"); // mdi:snowflake
- id(disp1).set_component_font_color(component.c_str(), 1055); // blue
- break;
- case 3: //CLIMATE_ACTION_HEATING
- id(disp1).set_component_text_printf(component.c_str(), "%s", "\uE237"); // mdi:fire
- id(disp1).set_component_font_color(component.c_str(), 64164); // deep-orange
- break;
- case 4: //CLIMATE_ACTION_IDLE
- id(disp1).set_component_text_printf(component.c_str(), "%s", "\uE50E"); // mdi:thermometer
- id(disp1).set_component_font_color(component.c_str(), 35921); // grey (off)
- break;
- case 5: //CLIMATE_ACTION_DRYING
- id(disp1).set_component_text_printf(component.c_str(), "%s", "\uE58D"); // mdi:water-percent
- id(disp1).set_component_font_color(component.c_str(), 64704); // orange
- break;
- case 6: //CLIMATE_ACTION_FAN
- id(disp1).set_component_text_printf(component.c_str(), "%s", "\uE20F"); // mdi:fan
- id(disp1).set_component_font_color(component.c_str(), 1530); // cyan
- break;
- }
- - id: set_component_color
- mode: queued
- parameters:
- component: string
- foreground: int[]
- background: int[]
- then:
- - lambda: |-
- int fg565 = -1;
- int bg565 = -1;
- // Foreground
- if (foreground.size() == 3) fg565 = ((foreground[0] & 0b11111000) << 8) | ((foreground[1] & 0b11111100) << 3) | (foreground[2] >> 3);
- else if (foreground.size() == 1) fg565 = foreground[0];
- if (fg565 >= 0) id(disp1).set_component_font_color(component.c_str(), fg565);
- // Background
- if (background.size() == 3) bg565 = ((background[0] & 0b11111000) << 8) | ((background[1] & 0b11111100) << 3) | (background[2] >> 3);
- else if (background.size() == 1) bg565 = background[0];
- if (bg565 >= 0) id(disp1).set_component_background_color(component.c_str(), bg565);
- - id: display_wrapped_text
- mode: queued
- parameters:
- component: string
- text: string
- line_length_limit: int
- then:
- - lambda: |-
- int startPos = 0;
- int endPos = 0;
- std::string wrappedText = "";
- while (startPos < text.length()) {
- while (text[startPos] == ' ' and startPos < text.length()) { startPos++; }
- int endPos = startPos + line_length_limit;
- if (endPos >= text.length()) endPos = text.length();
- else
- {
- while (endPos > startPos && text[endPos] != ' ') { endPos--; }
- if (endPos == startPos) endPos = startPos + line_length_limit; // Handle case of long word
- }
- wrappedText += text.substr(startPos, endPos-startPos);
- if (endPos < text.length())
- {
- while (text[endPos] == ' ') { endPos--; }
- if (endPos >= startPos) wrappedText += "\\r";
- }
- startPos = endPos + 1; // Skip the space
- while (text[startPos] == ' ' and startPos < text.length()) { startPos++; }
- }
- id(disp1).set_component_text_printf(component.c_str(), "%s", wrappedText.c_str());
- - id: display_embedded_temp
- mode: restart
- then:
- - if:
- condition:
- - or:
- - lambda: return id(embedded_indoor_temp);
- - not:
- - api.connected:
- - not:
- - wifi.connected:
- then:
- - lambda: |-
- if (id(temp_unit_fahrenheit)) id(disp1).set_component_text_printf("home.current_temp", "%.0f°F", ((id(temp_nspanel).state * 9.0 / 5.0) + 32.0)); // °F = (°C × 9/5) + 32
- else id(disp1).set_component_text_printf("home.current_temp", "%.1f°C", id(temp_nspanel).state);
- - id: check_versions
- mode: restart
- then:
- - wait_until:
- condition:
- - lambda: |-
- auto compareVersions = [](const char* version1, const char* version2) -> bool
- {
- int major1 = 0, minor1 = 0;
- int major2 = 0, minor2 = 0;
- sscanf(version1, "%d.%d", &major1, &minor1);
- sscanf(version2, "%d.%d", &major2, &minor2);
- return (major1 == major2) && (minor1 == minor2);
- };
- return (compareVersions("4.0.2", id(version_tft).c_str()) and compareVersions("4.0.2", id(version_blueprint).c_str()));
- timeout: 60s
- - lambda: |-
- auto compareVersions = [](const char* version1, const char* version2) -> bool
- {
- int major1 = 0, minor1 = 0;
- int major2 = 0, minor2 = 0;
- sscanf(version1, "%d.%d", &major1, &minor1);
- sscanf(version2, "%d.%d", &major2, &minor2);
- return (major1 == major2) && (minor1 == minor2);
- };
- ESP_LOGD("script.check_versions", "ESPHome version: 4.0.2");
- ESP_LOGD("script.check_versions", "TFT version: %s", id(version_tft).c_str());
- if (not compareVersions("4.0.2", id(version_tft).c_str())) ESP_LOGE("script.check_versions", "TFT version mismatch!");
- ESP_LOGD("script.check_versions", "Blueprint version: %s", id(version_blueprint).c_str());
- if (not compareVersions("4.0.2", id(version_blueprint).c_str())) ESP_LOGE("script.check_versions", "Blueprint version mismatch!");
- auto ha_event = new esphome::api::CustomAPIDevice();
- ha_event->fire_homeassistant_event("esphome.nspanel_ha_blueprint",
- {
- {"type", "version"},
- {"tft", id(version_tft).c_str()},
- {"esphome", "4.0.2"},
- {"blueprint", id(version_blueprint).c_str()}
- });
- - id: update_page_screensaver
- mode: restart
- then:
- - if:
- condition:
- text_sensor.state:
- id: current_page
- state: screensaver
- then:
- - lambda: |-
- int wakeup_page_id = 0;
- if (id(wakeup_page_name).state == "buttonpage01") wakeup_page_id = 12;
- else if (id(wakeup_page_name).state == "buttonpage02") wakeup_page_id = 13;
- else if (id(wakeup_page_name).state == "buttonpage03") wakeup_page_id = 14;
- else if (id(wakeup_page_name).state == "buttonpage04") wakeup_page_id = 15;
- else if (id(wakeup_page_name).state == "entitypage01") wakeup_page_id = 18;
- else if (id(wakeup_page_name).state == "entitypage02") wakeup_page_id = 19;
- else if (id(wakeup_page_name).state == "entitypage03") wakeup_page_id = 20;
- else if (id(wakeup_page_name).state == "entitypage04") wakeup_page_id = 21;
- else if (id(wakeup_page_name).state == "qrcode") wakeup_page_id = 17;
- else if (id(wakeup_page_name).state == "alarm") wakeup_page_id = 23;
- id(disp1).set_component_value("orign", wakeup_page_id);
- - id: addon_climate_service_call
- mode: restart
- parameters:
- key: string
- value: string
- then:
- - lambda: ESP_LOGV("script.addon_climate_service_call", "Check for addon_climate");
- - id: addon_climate_update_page_home
- mode: restart
- then:
- - lambda: ESP_LOGV("script.addon_climate_update_page_home", "Check for addon_climate");
- - id: addon_climate_set_climate
- mode: restart
- parameters:
- embedded_climate: bool
- then:
- - lambda: |-
- ESP_LOGV("script.addon_climate_set_climate", "Check for addon_climate");
- ESP_LOGV("script.addon_climate_set_climate", "embedded_climate: %i", (embedded_climate) ? 1 : 0);
- - id: addon_climate_update_page_climate
- mode: restart
- then:
- - lambda: ESP_LOGV("script.addon_climate_update_page_climate", "Check for addon_climate");
- - id: addon_climate_set_climate_friendly_name
- mode: restart
- parameters:
- friendly_name: string
- then:
- - lambda: |-
- ESP_LOGV("script.addon_climate_set_climate_friendly_name", "Check for addon_climate");
- ESP_LOGV("script.addon_climate_set_climate_friendly_name", "friendly_name: %s", friendly_name.c_str());
Add Comment
Please, Sign In to add comment