Guest User

esphome nspanel

a guest
Sep 29th, 2023
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 66.07 KB | Source Code | 0 0
  1. INFO Reading configuration /config/esphome/nspanel.yaml...
  2. INFO Updating https://github.com/Blackymas/NSPanel_HA_Blueprint@main
  3. INFO Detected timezone 'Europe/Warsaw'
  4. WARNING GPIO4 is a Strapping PIN and should be avoided.
  5. Attaching external pullup/down resistors to strapping pins can cause unexpected failures.
  6. See https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins
  7. Failed config
  8.  
  9. esphome: None
  10.   name: nspanel1
  11.  
  12.   [min_version] is an invalid option for [esphome]. Please check the indentation.
  13.   min_version: 2023.5.0 None
  14.   build_path: .esphome/build/nspanel1
  15. api: [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:130]
  16.   id: api_server
  17.   reboot_timeout: 0s
  18.   services: [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:136]
  19.     - service: upload_tft
  20.       then:
  21.         - logger.log: Service: upload_tft
  22.         - binary_sensor.template.publish:
  23.             id: nextion_init
  24.             state: False
  25.         - lambda: id(disp1)->upload_tft();
  26.     - service: upload_tft_url
  27.       variables:
  28.         url: string
  29.       then:
  30.         - logger.log: Service: upload_tft_url
  31.         - binary_sensor.template.publish:
  32.             id: nextion_init
  33.             state: False
  34.         - lambda: id(disp1)->set_tft_url(url.c_str());
  35.         - lambda: id(disp1)->upload_tft();
  36.     - service: send_command_printf
  37.       variables:
  38.         cmd: string
  39.       then:
  40.         - lambda: id(disp1).send_command_printf("%s", cmd.c_str());
  41.     - service: send_command_text_printf
  42.       variables:
  43.         component: string
  44.         message: string
  45.       then:
  46.         - lambda: id(disp1).set_component_text_printf(component.c_str(), "%s", message.c_str());
  47.     - service: send_command_value
  48.       variables:
  49.         component: string
  50.         message: int
  51.       then:
  52.         - lambda: id(disp1).set_component_value(component.c_str(), message);
  53.     - service: send_command_hide
  54.       variables:
  55.         component: string
  56.       then:
  57.         - lambda: id(disp1).hide_component(component.c_str());
  58.     - service: send_command_show
  59.       variables:
  60.         component: string
  61.       then:
  62.         - lambda: id(disp1).show_component(component.c_str());
  63.     - service: send_command_show_all
  64.       then:
  65.         - lambda: id(disp1).show_component("255");
  66.     - service: set_component_color
  67.       variables:
  68.         component: string
  69.         foreground: int[]
  70.         background: int[]
  71.       then:
  72.         - lambda: id(set_component_color).execute(component, foreground, background);
  73.     - service: notification_show
  74.       variables:
  75.         label: string
  76.         text: string
  77.       then:
  78.         - lambda: |-
  79.             ESP_LOGV("service.notification_show", "Starting");
  80.            
  81.             id(disp1).send_command_printf("is_notification=1");
  82.             id(disp1).goto_page("notification");
  83.             id(disp1).set_component_text_printf("notification.notifi_label", "%s", label.c_str());
  84.            
  85.             id(display_wrapped_text).execute("notification.notifi_text01", text.c_str(), id(display_mode) == 2 ? 23 : 32);
  86.            
  87.             id(notification_label).publish_state(label.c_str());
  88.             id(notification_text).publish_state(text.c_str());
  89.             id(timer_reset_all).execute(id(current_page).state.c_str());
  90.         - switch.turn_on: notification_unread
  91.         - if:
  92.             condition:
  93.               - switch.is_on: notification_sound
  94.             then:
  95.               - rtttl.play: two short:d=4,o=5,b=100:16e6,16e6
  96.     - service: notification_clear
  97.       then:
  98.         - logger.log: Service: notification_clear
  99.         - lambda: |-
  100.             id(disp1).send_command_printf("is_notification=0");
  101.             id(notification_label).publish_state("");
  102.             id(notification_text).publish_state("");
  103.         - switch.turn_off: notification_unread
  104.     - service: open_entity_settings_page
  105.       variables:
  106.         page: string
  107.         page_label: string
  108.         page_icon: string
  109.         page_icon_color: int[]
  110.         entity: string
  111.         back_page: string
  112.       then:
  113.         - lambda: |-
  114.             id(entity_id) = entity;
  115.             std::string cmd_page = std::string("page ") + page.c_str();
  116.             id(disp1).send_command_printf(cmd_page.c_str());
  117.             id(disp1).set_component_text_printf("page_label", "%s", page_label.c_str());
  118.             id(disp1).set_component_text_printf("back_page", "%s", back_page.c_str());
  119.             if (page == "climate")
  120.               {
  121.                 if (entity == "embedded_climate") id(addon_climate_set_climate_friendly_name).execute(page_label.c_str());
  122.                 id(disp1).set_component_value("embedded", (entity == "embedded_climate") ? 1 : 0);
  123.               }
  124.             else
  125.               {
  126.                 if ((page_icon.c_str() != std::string()) and (page_icon.c_str() != ""))
  127.                   id(disp1).set_component_text_printf("icon_state", "%s", page_icon.c_str());
  128.                 id(set_component_color).execute("icon_state", page_icon_color, {});
  129.               }
  130.     - service: play_rtttl
  131.       variables:
  132.         song_str: string
  133.       then:
  134.         - rtttl.play:
  135.             rtttl: !lambda |-
  136.               return song_str;
  137.     - service: qrcode
  138.       variables:
  139.         title: string
  140.         qrcode: string
  141.         show: bool
  142.       then:
  143.         - lambda: |-
  144.             id(disp1).set_component_text_printf("qrcode.qrcode_label", "%s", title.c_str());
  145.             id(disp1).set_component_text_printf("qrcode.qrcode_value", "%s", qrcode.c_str());
  146.             if (show) id(disp1).goto_page("qrcode");
  147.     - [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:293]
  148.       service: set_climate
  149.       variables:
  150.         current_temp: float
  151.         target_temp: float
  152.         temp_step: int
  153.         total_steps: int
  154.         temp_offset: int
  155.         climate_icon: string
  156.         embedded_climate: bool
  157.         entity: string
  158.       then: [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:304]
  159.         - lambda: if (id(current_page).state == "climate") id(entity_id) = entity;
  160.         - [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:307]
  161.           script.execute: [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:308]
  162.             id: set_climate
  163.            
  164.             [current_temp] is an invalid option for [script.execute].
  165.             current_temp: !lambda |-
  166.               return current_temp; [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:309]
  167.            
  168.             [target_temp] is an invalid option for [script.execute].
  169.             target_temp: !lambda |-
  170.               return target_temp; [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:310]
  171.            
  172.             [temp_step] is an invalid option for [script.execute].
  173.             temp_step: !lambda |-
  174.               return temp_step; [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:311]
  175.            
  176.             [total_steps] is an invalid option for [script.execute].
  177.             total_steps: !lambda |-
  178.               return total_steps; [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:312]
  179.            
  180.             [temp_offset] is an invalid option for [script.execute].
  181.             temp_offset: !lambda |-
  182.               return temp_offset; [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:313]
  183.            
  184.             [climate_icon] is an invalid option for [script.execute].
  185.             climate_icon: !lambda |-
  186.               return climate_icon; [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:314]
  187.            
  188.             [embedded_climate] is an invalid option for [script.execute].
  189.             embedded_climate: !lambda |-
  190.               return embedded_climate; [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:315]
  191.     - service: set_button
  192.       variables:
  193.         btn_id: string
  194.         btn_pic: int
  195.         btn_bg: int[]
  196.         btn_icon_font: int[]
  197.         btn_txt_font: int[]
  198.         btn_bri_font: int[]
  199.         btn_icon: string
  200.         btn_label: string
  201.         btn_bri_txt: string
  202.       then:
  203.         - lambda: |-
  204.             std::string btnicon = btn_id.c_str() + std::string("icon");
  205.             std::string btntext = btn_id.c_str() + std::string("text");
  206.             std::string btnbri = btn_id.c_str() + std::string("bri");
  207.             id(disp1).send_command_printf("%spic.pic=%i", btn_id.c_str(), btn_pic);
  208.             id(set_component_color).execute(btnicon.c_str(), btn_icon_font, btn_bg);
  209.             id(set_component_color).execute(btntext.c_str(), btn_txt_font, btn_bg);
  210.             id(set_component_color).execute(btnbri.c_str(), btn_bri_font, btn_bg);
  211.             id(disp1).set_component_text_printf(btnicon.c_str(), "%s", btn_icon.c_str());
  212.             id(display_wrapped_text).execute(btntext.c_str(), btn_label.c_str(), 10);
  213.             if (strcmp(btn_bri_txt.c_str(), "0") != 0)
  214.               id(disp1).set_component_text_printf(btnbri.c_str(), "%s", btn_bri_txt.c_str());
  215.             else
  216.               id(disp1).set_component_text_printf(btnbri.c_str(), " ");
  217.     - service: wake_up
  218.       variables:
  219.         reset_timer: bool
  220.       then:
  221.         - lambda: |-
  222.             if (id(current_page).state == "screensaver") id(disp1).goto_page(id(wakeup_page_name).state.c_str());
  223.             if (reset_timer)
  224.               id(timer_reset_all).execute(id(wakeup_page_name).state.c_str());
  225.             else
  226.               {
  227.                 id(timer_sleep).execute(id(wakeup_page_name).state.c_str(), int(id(timeout_sleep).state));
  228.                 id(timer_dim).execute(id(wakeup_page_name).state.c_str(), int(id(timeout_dim).state));
  229.               }
  230.     - service: set_entity
  231.       variables:
  232.         ent_id: string
  233.         ent_icon: string
  234.         ent_label: string
  235.         ent_value: string
  236.         ent_value_xcen: string
  237.       then:
  238.         - lambda: |-
  239.             std::string enticon = ent_id.c_str() + std::string("_pic");
  240.             std::string entlabel = ent_id.c_str() + std::string("_label");
  241.             std::string entxcen = ent_id.c_str() + std::string(".xcen=") + ent_value_xcen.c_str();
  242.             id(disp1).set_component_text_printf(enticon.c_str(), "%s", ent_icon.c_str());
  243.             if (strcmp(ent_icon.c_str(), "0") != 0) id(disp1).set_component_text_printf(enticon.c_str(), "%s", ent_icon.c_str());
  244.             id(disp1).set_component_text_printf(entlabel.c_str(), "%s", ent_label.c_str());
  245.             id(disp1).set_component_text_printf(ent_id.c_str(), "%s", ent_value.c_str());
  246.             if (strcmp(ent_value_xcen.c_str(), "0") != 0) id(disp1).send_command_printf("%s", entxcen.c_str());
  247.     - service: global_settings
  248.       variables:
  249.         blueprint_version: string
  250.         relay1_local_control: bool
  251.         relay1_icon: string
  252.         relay1_icon_color: int
  253.         relay1_fallback: bool
  254.         relay2_local_control: bool
  255.         relay2_icon: string
  256.         relay2_icon_color: int
  257.         relay2_fallback: bool
  258.         date_color: int
  259.         time_format: string
  260.         time_color: int
  261.         embedded_climate: bool
  262.         embedded_indoor_temperature: bool
  263.         temperature_unit_is_fahrenheit: bool
  264.         mui_please_confirm: string
  265.       then:
  266.         - lambda: |-
  267.             // Blueprint version
  268.             id(version_blueprint) = blueprint_version;
  269.             id(check_versions).execute();
  270.            
  271.             // Relays
  272.             id(relay1_local).publish_state(relay1_local_control);
  273.             id(relay2_local).publish_state(relay2_local_control);
  274.             id(home_relay1_icon) = relay1_icon.c_str();
  275.             id(home_relay2_icon) = relay2_icon.c_str();
  276.             id(home_relay1_icon_color) = relay1_icon_color;
  277.             id(home_relay2_icon_color) = relay2_icon_color;
  278.             id(relay_1_fallback) = relay1_fallback;
  279.             id(relay_2_fallback) = relay2_fallback;
  280.            
  281.             // Localization
  282.             id(mui_time_format) = time_format;
  283.            
  284.             // Date/Time colors
  285.             id(home_date_color) = date_color;
  286.             id(home_time_color) = time_color;
  287.            
  288.             // Embedded thermostat
  289.             id(is_embedded_thermostat) = embedded_climate;
  290.            
  291.             // Indoor temperature
  292.             id(embedded_indoor_temp) = embedded_indoor_temperature;
  293.             id(temp_unit_fahrenheit) = temperature_unit_is_fahrenheit;
  294.             id(display_embedded_temp).execute();
  295.            
  296.             // Confirm page
  297.             id(display_wrapped_text).execute("confirm.title", mui_please_confirm.c_str(), 15);
  298.            
  299.             // Refresh colors of global components
  300.             id(disp1).set_component_font_color("home.date", id(home_date_color));
  301.             id(disp1).set_component_font_color("home.time", id(home_time_color));
  302.             id(disp1).set_component_font_color("home.icon_top_01", id(home_relay1_icon_color));
  303.             id(disp1).set_component_font_color("home.icon_top_02", id(home_relay2_icon_color));
  304.            
  305.             // Update home page
  306.             id(update_page_home).execute();
  307.         - if:
  308.             condition:
  309.               - text_sensor.state:
  310.                   id: current_page
  311.                   state: boot
  312.             then:
  313.               - lambda: |-
  314.                   id(disp1).set_component_text_printf("boot.bluep_version", "%s", blueprint_version.c_str());
  315.               - wait_until:
  316.                   condition:
  317.                     - not:
  318.                         - text_sensor.state:
  319.                             id: current_page
  320.                             state: boot
  321.                   timeout: 2s
  322.               - if:
  323.                   condition:
  324.                     - text_sensor.state:
  325.                         id: current_page
  326.                         state: boot
  327.                   then:
  328.                     - if:
  329.                         condition:
  330.                           switch.is_on: notification_sound
  331.                         then:
  332.                           - rtttl.play:
  333.                               rtttl: two short:d=4,o=5,b=100:16e6,16e6
  334.                     - lambda: |-
  335.                         ESP_LOGD("service.global_settings", "Jump to wake-up page: %s", id(wakeup_page_name).state.c_str());
  336.                         id(disp1).goto_page(id(wakeup_page_name).state.c_str());
  337.                         id(timer_reset_all).execute(id(wakeup_page_name).state.c_str());
  338.     - service: page_home
  339.       variables:
  340.         notification_icon: string
  341.         notification_icon_color_normal: int[]
  342.         notification_icon_color_unread: int[]
  343.         qrcode: bool
  344.         qrcode_icon: string
  345.         qrcode_icon_color: int[]
  346.         entities_pages: bool
  347.         entities_pages_icon: string
  348.         entities_pages_icon_color: int[]
  349.         alarm_state: string
  350.       then:
  351.         - lambda: |-
  352.             // Notification button
  353.             id(disp1).send_command_printf("is_notification=%i", (id(notification_text).state.empty() and id(notification_label).state.empty()) ? 0 : 1);
  354.             id(disp1).set_component_text_printf("home.bt_notific", "%s", notification_icon.c_str());
  355.             id(set_component_color).execute("home.bt_notific", id(notification_unread).state ? notification_icon_color_unread : notification_icon_color_normal, {});
  356.             id(home_notify_icon_color_normal) = notification_icon_color_normal;
  357.             id(home_notify_icon_color_unread) = notification_icon_color_unread;
  358.            
  359.             // QRCode button
  360.             id(disp1).send_command_printf("is_qrcode=%i", (qrcode) ? 1 : 0);
  361.             id(disp1).set_component_text_printf("home.bt_qrcode", "%s", qrcode_icon.c_str());
  362.             id(set_component_color).execute("home.bt_qrcode", qrcode_icon_color, {});
  363.            
  364.             // Entities pages button
  365.             id(disp1).send_command_printf("is_entities=%i", (entities_pages) ? 1 : 0);
  366.             id(disp1).set_component_text_printf("home.bt_entities", "%s", entities_pages_icon.c_str());
  367.             id(set_component_color).execute("home.bt_entities", entities_pages_icon_color, {});
  368.            
  369.             // Alarm button
  370.             id(disp1).send_command_printf("is_alarm=%i", (alarm_state=="" or alarm_state.empty()) ? 0 : 1);
  371.             id(update_alarm_icon).execute("home.bt_alarm", alarm_state.c_str());
  372.     - service: page_settings
  373.       variables:
  374.         reboot: string
  375.         brightness: string
  376.         bright: string
  377.         dim: string
  378.       then:
  379.         - lambda: |-
  380.             if (not reboot.empty()) id(disp1).set_component_text_printf("settings.lbl_reboot", " %s", reboot.c_str());
  381.             id(disp1).set_component_text_printf("settings.lbl_brightness", " %s", brightness.c_str());
  382.             id(display_wrapped_text).execute("settings.lbl_bright", bright.c_str(), id(display_mode) == 2 ? 25 : 10);
  383.             id(display_wrapped_text).execute("settings.lbl_dim", dim.c_str(), id(display_mode) == 2 ? 25 : 10);
  384.     - service: alarm_settings
  385.       variables:
  386.         page_title: string
  387.         state: string
  388.         supported_features: int
  389.         code_format: string
  390.         code_arm_required: bool
  391.         entity: string
  392.         mui_alarm: string[]
  393.       then:
  394.         - lambda: |-
  395.             // set alarm icon on home page
  396.             id(disp1).send_command_printf("is_alarm=%i", (state=="" or state.empty()) ? 0 : 1);
  397.             id(update_alarm_icon).execute("home.bt_alarm", state.c_str());
  398.            
  399.             // Is page Alarm visible?
  400.             if (id(current_page).state=="alarm")
  401.               { // Update alarm page
  402.                   id(entity_id) = entity;
  403.            
  404.                   // Alarm page - Header
  405.                   id(update_alarm_icon).execute("icon_state", state.c_str());
  406.                   id(disp1).set_component_text_printf("page_label", "%s", page_title.c_str());
  407.                   id(disp1).set_component_text_printf("code_format", "%s", code_format.c_str());
  408.                   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");
  409.            
  410.                   // Alarm page - Button's icons
  411.                   id(disp1).set_component_text_printf("bt_home_icon", "\uE689"); //mdi:shield-home
  412.                   id(disp1).set_component_text_printf("bt_away_icon", "\uE99C"); //mdi:shield-lock
  413.                   id(disp1).set_component_text_printf("bt_night_icon", "\uF827"); //mdi:shield-moon
  414.                   id(disp1).set_component_text_printf("bt_vacat_icon", "\uE6BA"); //mdi:shield-airplane
  415.                   id(disp1).set_component_text_printf("bt_bypass_icon", "\uE77F"); //mdi:shield-half-full
  416.                   id(disp1).set_component_text_printf("bt_disarm_icon", "\uE99D"); //mdi:shield-off
  417.            
  418.                   // Alarm page - Button's text
  419.                   id(display_wrapped_text).execute("bt_home_text", mui_alarm[0].c_str(), 10);
  420.                   id(display_wrapped_text).execute("bt_away_text", mui_alarm[1].c_str(), 10);
  421.                   id(display_wrapped_text).execute("bt_night_text", mui_alarm[2].c_str(), 10);
  422.                   id(display_wrapped_text).execute("bt_vacat_text", mui_alarm[3].c_str(), 10);
  423.                   id(display_wrapped_text).execute("bt_bypass_text", mui_alarm[4].c_str(), 10);
  424.                   id(display_wrapped_text).execute("bt_disarm_text", mui_alarm[5].c_str(), 10);
  425.            
  426.                   // Alarm page - Buttons
  427.                   if (supported_features & 1) // Alarm - Button - Home
  428.                     {
  429.                       id(disp1).send_command_printf("bt_home_pic.pic=%i", (state=="armed_home") ? 43 : 42);
  430.                       id(disp1).set_component_background_color("bt_home_text", (state=="armed_home") ? 19818 : 52857);
  431.                       id(disp1).set_component_background_color("bt_home_icon", (state=="armed_home") ? 19818 : 52857);
  432.                       id(disp1).set_component_font_color("bt_home_text", (state=="armed_home") ? 65535 : 0);
  433.                       id(disp1).set_component_font_color("bt_home_icon", (state=="armed_home") ? 65535 : 0);
  434.                       if (state=="armed_home") id(disp1).hide_component("bt_home"); else id(disp1).show_component("bt_home");
  435.                     }
  436.                   if (supported_features & 2) // Alarm - Button - Away
  437.                     {
  438.                       id(disp1).send_command_printf("bt_away_pic.pic=%i", (state=="armed_away") ? 43 : 42);
  439.                       id(disp1).set_component_background_color("bt_away_text", (state=="armed_away") ? 19818 : 52857);
  440.                       id(disp1).set_component_background_color("bt_away_icon", (state=="armed_away") ? 19818 : 52857);
  441.                       id(disp1).set_component_font_color("bt_away_text", (state=="armed_away") ? 65535 : 0);
  442.                       id(disp1).set_component_font_color("bt_away_icon", (state=="armed_away") ? 65535 : 0);
  443.                       if (state=="armed_away") id(disp1).hide_component("bt_away"); else id(disp1).show_component("bt_away");
  444.                     }
  445.                   if (supported_features & 4) // Alarm - Button - Night
  446.                     {
  447.                       id(disp1).send_command_printf("bt_night_pic.pic=%i", (state=="armed_night") ? 43 : 42);
  448.                       id(disp1).set_component_background_color("bt_night_text", (state=="armed_night") ? 19818 : 52857);
  449.                       id(disp1).set_component_background_color("bt_night_icon", (state=="armed_night") ? 19818 : 52857);
  450.                       id(disp1).set_component_font_color("bt_night_text", (state=="armed_night") ? 65535 : 0);
  451.                       id(disp1).set_component_font_color("bt_night_icon", (state=="armed_night") ? 65535 : 0);
  452.                       if (state=="armed_night") id(disp1).hide_component("bt_night"); else id(disp1).show_component("bt_night");
  453.                     }
  454.                   if (supported_features & 32) // Alarm - Button - Vacation
  455.                     {
  456.                       id(disp1).send_command_printf("bt_vacat_pic.pic=%i", (state=="armed_vacation") ? 43 : 42);
  457.                       id(disp1).set_component_background_color("bt_vacat_text", (state=="armed_vacation") ? 19818 : 52857);
  458.                       id(disp1).set_component_background_color("bt_vacat_icon", (state=="armed_vacation") ? 19818 : 52857);
  459.                       id(disp1).set_component_font_color("bt_vacat_text", (state=="armed_vacation") ? 65535 : 0);
  460.                       id(disp1).set_component_font_color("bt_vacat_icon", (state=="armed_vacation") ? 65535 : 0);
  461.                       if (state=="armed_vacation") id(disp1).hide_component("bt_vacat"); else id(disp1).show_component("bt_vacat");
  462.                     }
  463.                   if (supported_features & 16) // Alarm - Button - Custom bypass
  464.                     {
  465.                       id(disp1).send_command_printf("bt_bypass_pic.pic=%i", (state=="armed_bypass") ? 43 : 42);
  466.                       id(disp1).set_component_background_color("bt_bypass_text", (state=="armed_bypass") ? 19818 : 52857);
  467.                       id(disp1).set_component_background_color("bt_bypass_icon", (state=="armed_bypass") ? 19818 : 52857);
  468.                       id(disp1).set_component_font_color("bt_bypass_text", (state=="armed_bypass") ? 65535 : 0);
  469.                       id(disp1).set_component_font_color("bt_bypass_icon", (state=="armed_bypass") ? 65535 : 0);
  470.                       if (state=="armed_bypass") id(disp1).hide_component("bt_bypass"); else id(disp1).show_component("bt_bypass");
  471.                     }
  472.                   if ( true ) // Alarm - Button - Disarm
  473.                     {
  474.                       id(disp1).send_command_printf("bt_disarm_pic.pic=%i", (state=="disarmed") ? 43 : 42);
  475.                       id(disp1).set_component_background_color("bt_disarm_text", (state=="disarmed") ? 19818 : 52857);
  476.                       id(disp1).set_component_background_color("bt_disarm_icon", (state=="disarmed") ? 19818 : 52857);
  477.                       id(disp1).set_component_font_color("bt_disarm_text", (state=="disarmed") ? 65535 : 0);
  478.                       id(disp1).set_component_font_color("bt_disarm_icon", (state=="disarmed") ? 65535 : 0);
  479.                       if (state=="disarmed") id(disp1).hide_component("bt_disarm"); else id(disp1).show_component("bt_disarm");
  480.                     }
  481.               }
  482.     - service: media_player
  483.       variables:
  484.         entity: string
  485.         state: string
  486.         is_volume_muted: bool
  487.         friendly_name: string
  488.         volume_level: int
  489.         media_title: string
  490.         media_artist: string
  491.         media_duration: float
  492.         media_position: float
  493.         media_position_delta: float
  494.         supported_features: int
  495.       then:
  496.         - lambda: |-
  497.             if (id(current_page).state == "media_player")
  498.               {
  499.                 id(entity_id) = entity;
  500.                 id(disp1).set_component_text_printf("page_label", "%s", friendly_name.c_str());
  501.                 id(display_wrapped_text).execute("track", media_title.c_str(), id(display_mode) == 2 ? 16 : 27);
  502.                 id(display_wrapped_text).execute("artist", media_artist.c_str(), id(display_mode) == 2 ? 26 : 40);
  503.            
  504.                 // on/off button
  505.                 if (supported_features & 128 and state == "off") //TURN_ON
  506.                   {
  507.                     id(set_component_color).execute("bt_on_off", { 65535 }, {} );
  508.                     id(disp1).show_component("bt_on_off");
  509.                   }
  510.                 else if (supported_features & 256 and state != "off") //TURN_OFF
  511.                   {
  512.                     id(set_component_color).execute("bt_on_off", { 10597 }, {} );
  513.                     id(disp1).show_component("bt_on_off");
  514.                   }
  515.                 else id(disp1).hide_component("bt_on_off");
  516.            
  517.                 // play/pause button
  518.                 if ((supported_features & 512 or supported_features & 16384) and state != "playing" and state != "off") //PLAY_MEDIA+PLAY
  519.                   {
  520.                     id(disp1).set_component_text_printf("bt_play_pause", "%s", "\uE409"); // mdi:play
  521.                     id(disp1).show_component("bt_play_pause");
  522.                   }
  523.                 else if (supported_features & 1 and state == "playing" ) //PAUSE
  524.                   {
  525.                     id(disp1).set_component_text_printf("bt_play_pause", "%s", "\uE3E3"); // mdi:pause
  526.                     id(disp1).show_component("bt_play_pause");
  527.                   }
  528.                 else id(disp1).hide_component("bt_play_pause");
  529.            
  530.                 // bt_prev button - PREVIOUS_TRACK
  531.                 if (supported_features & 16 and state != "off") id(disp1).show_component("bt_prev"); else id(disp1).hide_component("bt_prev");
  532.                 // bt_next button - NEXT_TRACK
  533.                 if (supported_features & 32 and state != "off") id(disp1).show_component("bt_next"); else id(disp1).hide_component("bt_next");
  534.            
  535.                 // Stop button - STOP
  536.                 //if (supported_features & 4096 and (state == "playing" or state == "paused")) id(disp1).show_component("bt_stop"); else id(disp1).hide_component("bt_stop");
  537.            
  538.                 // mute/unmute button - VOLUME_MUTE
  539.                 id(disp1).set_component_value("is_muted", (is_volume_muted) ? 1 : 0);
  540.                 if (supported_features & 8 and is_volume_muted) // unmute
  541.                   {
  542.                     id(disp1).set_component_text_printf("bt_mute", "%s", "\uEE07"); // mdi:volume-variant-off
  543.                     id(disp1).show_component("bt_mute");
  544.                   }
  545.                 else if (supported_features & 8) // mute
  546.                   {
  547.                     id(disp1).set_component_text_printf("bt_mute", "%s", "\uE57E"); // mdi:volume-low
  548.                     id(disp1).show_component("bt_mute");
  549.                   }
  550.                 else id(disp1).hide_component("bt_mute");
  551.            
  552.                 // VOLUME_SET
  553.                 if (supported_features & 4)
  554.                   {
  555.                     if (volume_level != id(last_volume_level))
  556.                       {
  557.                         id(last_volume_level) = volume_level;
  558.                         id(disp1).set_component_text_printf("vol_text", "%i%%", volume_level);
  559.                         id(disp1).set_component_value("vol_slider", volume_level);
  560.                       }
  561.                     id(disp1).show_component("vol_slider");
  562.                     id(disp1).show_component("bt_vol_down");
  563.                     id(disp1).show_component("bt_vol_up");
  564.                     id(disp1).show_component("vol_text");
  565.                   }
  566.                 else
  567.                   {
  568.                     id(disp1).hide_component("vol_slider");
  569.                     id(disp1).hide_component("bt_vol_down");
  570.                     id(disp1).hide_component("bt_vol_up");
  571.                     id(disp1).hide_component("vol_text");
  572.                   }
  573.            
  574.                 if (media_duration > 0)
  575.                   {
  576.                     if (media_duration != id(last_media_duration) or media_position != id(last_media_position))
  577.                       {
  578.                         id(last_media_duration) = media_duration;
  579.                         id(last_media_position) = media_position;
  580.                         id(disp1).set_component_value("prg_current", int(round(min(media_position + media_position_delta, media_duration))));
  581.                       }
  582.                     id(disp1).set_component_value("prg_total", int(round(media_duration)));
  583.                     id(disp1).send_command_printf("prg_timer.en=%i", (state == "playing") ? 1 : 0);
  584.                     id(disp1).show_component("time_current");
  585.                     id(disp1).show_component("time_total");
  586.                     id(disp1).show_component("time_progress");
  587.                   }
  588.                 else
  589.                   {
  590.                     id(disp1).send_command_printf("prg_timer.en=0");
  591.                     id(disp1).hide_component("time_current");
  592.                     id(disp1).hide_component("time_total");
  593.                     id(disp1).hide_component("time_progress");
  594.                   }
  595.               }
  596. binary_sensor.gpio: [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:881]
  597.   name: nspanel1 Left Button
  598.   platform: gpio
  599.   id: left_button
  600.   pin:
  601.     number: 14
  602.     inverted: True
  603.   on_multi_click: [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:888]
  604.     - [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:888]
  605.       timing:
  606.         - ON for at least 0.8s
  607.       then: [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:891]
  608.         - logger.log: Left button - Long click
  609.         - [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:892]
  610.           script.execute: [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:893]
  611.             id: ha_button
  612.            
  613.             [page] is an invalid option for [script.execute].
  614.             page: !lambda |-
  615.               return id(current_page).state; [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:894]
  616.            
  617.             [component] is an invalid option for [script.execute].
  618.             component: hw_bt_left [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:895]
  619.            
  620.             [command] is an invalid option for [script.execute].
  621.             command: long_click [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:896]
  622.     - timing:
  623.         - ON for at most 0.8s
  624.       then:
  625.         - logger.log: Left button - Short click
  626.         - if:
  627.             condition:
  628.               or:
  629.                 - switch.is_on: relay1_local
  630.                 - and:
  631.                     - lambda: !lambda |-
  632.                         return id(relay_1_fallback);
  633.                     - or:
  634.                         - not:
  635.                             - api.connected:
  636.                         - not:
  637.                             - wifi.connected:
  638.             then:
  639.               - switch.toggle: relay_1
  640.         - script.execute:
  641.             id: ha_button
  642.             page: !lambda |-
  643.               return id(current_page).state;
  644.             component: hw_bt_left
  645.             command: short_click
  646. binary_sensor.gpio: [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:921]
  647.   name: nspanel1 Right Button
  648.   platform: gpio
  649.   id: right_button
  650.   pin:
  651.     number: 27
  652.     inverted: True
  653.   on_multi_click: [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:928]
  654.     - [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:928]
  655.       timing:
  656.         - ON for at least 0.8s
  657.       then: [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:930]
  658.         - logger.log: Right button - Long click
  659.         - [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:931]
  660.           script.execute: [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:932]
  661.             id: ha_button
  662.            
  663.             [page] is an invalid option for [script.execute].
  664.             page: !lambda |-
  665.               return id(current_page).state; [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:933]
  666.            
  667.             [component] is an invalid option for [script.execute].
  668.             component: hw_bt_right [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:934]
  669.            
  670.             [command] is an invalid option for [script.execute].
  671.             command: long_click [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:935]
  672.     - timing:
  673.         - ON for at most 0.8s
  674.       then:
  675.         - logger.log: Right button - Short click
  676.         - if:
  677.             condition:
  678.               or:
  679.                 - switch.is_on: relay2_local
  680.                 - and:
  681.                     - lambda: !lambda |-
  682.                         return id(relay_2_fallback);
  683.                     - or:
  684.                         - not:
  685.                             - api.connected:
  686.                         - not:
  687.                             - wifi.connected:
  688.             then:
  689.               - switch.toggle: relay_2
  690.         - script.execute:
  691.             id: ha_button
  692.             page: !lambda |-
  693.               return id(current_page).state;
  694.             component: hw_bt_right
  695.             command: short_click
  696. binary_sensor.template: [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:977]
  697.   name: nspanel1 Nextion display
  698.   id: nextion_init
  699.   platform: template
  700.   device_class: connectivity
  701.  
  702.   [publish_initial_state] is an invalid option for [binary_sensor.template]. Please check the indentation.
  703.   publish_initial_state: True [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:981]
  704.   entity_category: diagnostic
  705.   icon: mdi:tablet-dashboard
  706. switch.template: [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:1434]
  707.   name: nspanel1 Notification unread
  708.   platform: template
  709.   id: notification_unread
  710.   entity_category: config
  711.   optimistic: True
  712.  
  713.   [restore_mode] is an invalid option for [switch.template]. Did you mean [restore_state]?
  714.   restore_mode: ALWAYS_OFF [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:1439]
  715.   on_turn_on:
  716.     - lambda: |-
  717.         id(set_component_color).execute("home.bt_notific", id(home_notify_icon_color_unread), {});
  718.   on_turn_off:
  719.     - lambda: |-
  720.         id(set_component_color).execute("home.bt_notific", id(home_notify_icon_color_normal), {});
  721. switch.template: [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:1446]
  722.   name: nspanel1 Notification sound
  723.   platform: template
  724.   id: notification_sound
  725.   entity_category: config
  726.   optimistic: True
  727.  
  728.   [restore_mode] is an invalid option for [switch.template]. Did you mean [restore_state]?
  729.   restore_mode: RESTORE_DEFAULT_OFF [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:1451]
  730. switch.template: [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:1496]
  731.   name: nspanel1 Relay 1 Local
  732.   platform: template
  733.   id: relay1_local
  734.   entity_category: config
  735.   optimistic: True
  736.  
  737.   [restore_mode] is an invalid option for [switch.template]. Did you mean [restore_state]?
  738.   restore_mode: RESTORE_DEFAULT_OFF [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:1501]
  739.   internal: True
  740.   on_turn_on:
  741.     - logger.log: Relay 1 Local turned On!
  742.   on_turn_off:
  743.     - logger.log: Relay 1 Local turned Off!
  744. switch.template: [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:1507]
  745.   name: nspanel1 Relay 2 Local
  746.   platform: template
  747.   id: relay2_local
  748.   entity_category: config
  749.   optimistic: True
  750.  
  751.   [restore_mode] is an invalid option for [switch.template]. Did you mean [restore_state]?
  752.   restore_mode: RESTORE_DEFAULT_OFF [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:1512]
  753.   internal: True
  754.   on_turn_on:
  755.     - logger.log: Relay 2 Local turned On!
  756.   on_turn_off:
  757.     - logger.log: Relay 2 Local turned Off!
  758. display.nextion: [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:1663]
  759.   id: disp1
  760.   platform: nextion
  761.   uart_id: tf_uart
  762.   tft_url: http://HOME-ASSISTANT-IP:8123/local/nspanel.tft
  763.  
  764.   [on_page] is an invalid option for [display.nextion]. Did you mean [on_wake]?
  765.   on_page: [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:1668]
  766.     - lambda: ESP_LOGW("display.disp1", "NEXTION PAGE CHANGED");
  767.   on_setup:
  768.     then:
  769.       - lambda: |-
  770.           id(disp1).goto_page("boot");
  771.           id(disp1).set_component_text_printf("boot.esph_version", "%s", "4.0.2"); // ### esphome-version ###
  772.           id(disp1).show_component("bt_reboot");
  773.           id(timer_reset_all).execute("boot");
  774.       - wait_until: api.connected
  775.       - lambda: |-
  776.           id(disp1).set_component_text_printf("boot.ip_addr", "%s", id(ip_address).state.c_str());
  777.           auto ha_event = new esphome::api::CustomAPIDevice();
  778.           ha_event->fire_homeassistant_event("esphome.nspanel_ha_blueprint",
  779.             {
  780.               {"type", "boot"},
  781.               {"step", "start"}
  782.             });
  783.       - delay: 1s
  784.       - lambda: |-
  785.           // Set dimming values
  786.           id(display_brightness).publish_state(id(display_brightness_global));
  787.           id(display_dim_brightness).publish_state(id(display_dim_brightness_global));
  788.           id(disp1).send_command_printf("brightness=%i", id(display_brightness_global));
  789.           id(disp1).send_command_printf("settings.brightslider.val=%i", id(display_brightness_global));
  790.           id(disp1).send_command_printf("brightness_dim=%i", id(display_dim_brightness_global));
  791.           id(disp1).send_command_printf("settings.dimslider.val=%i", id(display_dim_brightness_global));
  792.           id(nextion_init).publish_state(true);
  793.           auto ha_event = new esphome::api::CustomAPIDevice();
  794.           ha_event->fire_homeassistant_event("esphome.nspanel_ha_blueprint",
  795.             {
  796.               {"type", "boot"},
  797.               {"step", "nextion_init"}
  798.             });
  799.           id(home_relay1_icon) = "\uE3A5";
  800.           id(home_relay1_icon) = "\uE3A8";
  801.           id(timer_reset_all).execute("boot");
  802.       - lambda: |-
  803.           id(disp1).send_command_printf("is_notification=0");
  804.           id(notification_label).publish_state("");
  805.           id(notification_text).publish_state("");
  806.       - switch.turn_off: notification_unread
  807.       - logger.log: Nextion start - Done!
  808. script: [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:1713]
  809.  
  810.   'id' is a required option for [script].
  811.   - [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:1713]
  812.    
  813.     Unable to find action with the name 'id'.
  814.     id: timer_reset_all [source /config/esphome/.esphome/packages/566b10a3/nspanel_esphome.yaml:1713]
  815.     mode: restart
  816.     parameters:
  817.       page: string
  818.     then:
  819.       - lambda: |-
  820.           ESP_LOGV("script.timer_reset_all", "Reset timers");
  821.           id(timer_page).execute(page.c_str(), int(id(timeout_page).state));
  822.           id(timer_dim).execute(page.c_str(), int(id(timeout_dim).state));
  823.           id(timer_sleep).execute(page.c_str(), int(id(timeout_sleep).state));
  824.   - id: timer_page
  825.     mode: restart
  826.     parameters:
  827.       page: string
  828.       timeout: int
  829.     then:
  830.       - lambda: ESP_LOGV("script.timer_page", "Reset timer: %is", timeout);
  831.       - if:
  832.           condition:
  833.             - lambda: |-
  834.                 return (page != "screensaver" and page != "boot" and page != "home" and timeout >= 1);
  835.           then:
  836.             - delay: !lambda |-
  837.                 return (timeout *1000);
  838.             - lambda: |-
  839.                 ESP_LOGD("script.timer_page", "Timed out on page: %s", id(current_page).state.c_str());
  840.                 if (id(current_page).state != "screensaver" and id(current_page).state != "boot" and id(current_page).state != "home" and timeout >= 1)
  841.                   {
  842.                     ESP_LOGD("script.timer_page", "Fallback to page Home");
  843.                     id(disp1).goto_page("home");
  844.                   }
  845.   - id: timer_dim
  846.     mode: restart
  847.     parameters:
  848.       page: string
  849.       timeout: int
  850.     then:
  851.       - lambda: |-
  852.           ESP_LOGV("script.timer_dim", "Reset timer: %is", timeout);
  853.           if (id(is_dim_brightness))
  854.             {
  855.               if (page != "screensaver" and page != "boot")
  856.                 {
  857.                   ESP_LOGD("script.timer_dim", "Waking up on page: %s", page.c_str());
  858.                   id(disp1).send_command_printf("wakeup_timer.en=1");
  859.                 }
  860.               id(is_dim_brightness) = false;
  861.             }
  862.       - if:
  863.           condition:
  864.             - lambda: !lambda |-
  865.                 return (timeout >= 1);
  866.           then:
  867.             - delay: !lambda |-
  868.                 return (timeout *1000);
  869.             - lambda: |-
  870.                 if (id(current_page).state != "screensaver" and id(current_page).state != "boot" and timeout >= 1)
  871.                   {
  872.                     ESP_LOGD("script.timer_dim", "Dimming the display to %i%%", id(display_dim_brightness_global));
  873.                     id(disp1).send_command_printf("dim=%i", id(display_dim_brightness_global));
  874.                     id(is_dim_brightness) = true;
  875.                   }
  876.   - id: timer_sleep
  877.     mode: restart
  878.     parameters:
  879.       page: string
  880.       timeout: int
  881.     then:
  882.       - lambda: ESP_LOGV("script.timer_sleep", "Reset timer: %is", timeout);
  883.       - if:
  884.           condition:
  885.             - lambda: !lambda |-
  886.                 return (timeout >= 1);
  887.           then:
  888.             - delay: !lambda |-
  889.                 return (timeout *1000);
  890.             - lambda: |-
  891.                 if (id(current_page).state != "screensaver" and id(current_page).state != "boot" and timeout >= 1)
  892.                   {
  893.                     ESP_LOGD("script.timer_sleep", "Going to sleep");
  894.                     id(disp1).goto_page("screensaver");
  895.                     id(is_dim_brightness) = true;
  896.                   }
  897.   - id: set_climate
  898.     mode: restart
  899.     parameters:
  900.       current_temp: float
  901.       target_temp: float
  902.       temp_step: int
  903.       total_steps: int
  904.       temp_offset: int
  905.       climate_icon: string
  906.       embedded_climate: bool
  907.     then:
  908.       - if:
  909.           condition:
  910.             - text_sensor.state:
  911.                 id: current_page
  912.                 state: climate
  913.           then:
  914.             - lambda: |-
  915.                 id(addon_climate_set_climate).execute(embedded_climate);
  916.                 id(disp1).send_command_printf("climateslider.maxval=%i", total_steps);
  917.                 id(disp1).set_component_value("temp_offset", temp_offset);
  918.                 id(disp1).set_component_value("temp_step", temp_step);
  919.                 id(disp1).set_component_text_printf("current_temp", "%.1f°", current_temp);
  920.                 id(disp1).show_component("current_temp");
  921.                 id(disp1).show_component("current_icon");
  922.                 if (target_temp > -999)
  923.                   {
  924.                     float slider_val = round(((10*target_temp) - temp_offset) / temp_step);
  925.                     id(disp1).set_component_value("climateslider", slider_val);
  926.                     id(disp1).set_component_text_printf("target_temp", "%.1f°", target_temp);
  927.                     id(disp1).set_component_text_printf("target_icon", "%s", climate_icon.c_str());
  928.                     id(disp1).show_component("target_icon");
  929.                     id(disp1).show_component("target_temp");
  930.                     id(disp1).show_component("climateslider");
  931.                     id(disp1).show_component("decrease_temp");
  932.                     id(disp1).show_component("increase_temp");
  933.                   }
  934.                 else
  935.                   {
  936.                     id(disp1).hide_component("target_icon");
  937.                     id(disp1).hide_component("target_temp");
  938.                     id(disp1).hide_component("climateslider");
  939.                     id(disp1).hide_component("decrease_temp");
  940.                     id(disp1).hide_component("increase_temp");
  941.                   }
  942.                 id(disp1).set_component_value("embedded", (embedded_climate) ? 1 : 0);
  943.   - id: refresh_datetime
  944.     mode: restart
  945.     then:
  946.       - lambda: |-
  947.           std::string time_format_str = id(mui_time_format);
  948.           if (time_format_str.find("%p") != std::string::npos)
  949.             {
  950.               std::string meridiem_text = id(time_provider).now().strftime("%p");
  951.               id(disp1).set_component_text_printf("home.meridiem", "%s", meridiem_text.c_str());
  952.             }
  953.           else { id(disp1).set_component_text_printf("home.meridiem", " "); }
  954.           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))); }
  955.           if (time_format_str.find("%-I") != std::string::npos)
  956.             {
  957.               if (id(time_provider).now().hour>12)
  958.                 {
  959.                   time_format_str = time_format_str.replace(time_format_str.find("%-I"), sizeof("%-I")-1, to_string((int)(id(time_provider).now().hour-12)));
  960.                 }
  961.               else if (id(time_provider).now().hour==0)
  962.                 {
  963.                   time_format_str = time_format_str.replace(time_format_str.find("%-I"), sizeof("%-I")-1, "12");
  964.                 }
  965.               else
  966.                 {
  967.                   time_format_str = time_format_str.replace(time_format_str.find("%-I"), sizeof("%-I")-1, to_string((int)(id(time_provider).now().hour)));
  968.                 }
  969.             }
  970.           std::string time_text = id(time_provider).now().strftime(time_format_str);
  971.           id(disp1).set_component_text_printf("home.time", "%s", time_text.c_str());
  972.   - id: refresh_relays
  973.     mode: restart
  974.     then:
  975.       - lambda: |-
  976.           // Chips - Relays
  977.           if (id(relay_1).state) id(disp1).set_component_text_printf("home.icon_top_01", "%s", id(home_relay1_icon).c_str());
  978.             else id(disp1).set_component_text_printf("icon_top_01", "\uFFFF");
  979.           if (id(relay_2).state) id(disp1).set_component_text_printf("home.icon_top_02", "%s", id(home_relay2_icon).c_str());
  980.             else id(disp1).set_component_text_printf("home.icon_top_02", "\uFFFF");
  981.           // Hardware buttons - Fallback mode
  982.           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);
  983.           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);
  984.   - id: refresh_wifi_icon
  985.     mode: restart
  986.     then:
  987.       - if:
  988.           condition:
  989.             - binary_sensor.is_on: nextion_init
  990.           then:
  991.             - if:
  992.                 condition:
  993.                   wifi.connected:
  994.                 then:
  995.                   - if:
  996.                       condition:
  997.                         api.connected:
  998.                       then:
  999.                         - lambda: id(disp1).send_command_printf("api=1");
  1000.                         - lambda: id(disp1).set_component_text_printf("home.wifi_icon", "%s", "\uE5A8");
  1001.                         - lambda: id(disp1).set_component_font_color("home.wifi_icon", 33808);
  1002.                       else:
  1003.                         - lambda: id(disp1).send_command_printf("api=0");
  1004.                         - lambda: id(disp1).set_component_text_printf("home.wifi_icon", "%s", "\uF256");
  1005.                         - lambda: id(disp1).set_component_font_color("home.wifi_icon", 63488);
  1006.                 else:
  1007.                   - lambda: id(disp1).send_command_printf("api=0");
  1008.                   - lambda: id(disp1).set_component_text_printf("home.wifi_icon", "%s", "\uE5A9");
  1009.                   - lambda: id(disp1).set_component_font_color("home.wifi_icon", 63488);
  1010.   - id: update_page_home
  1011.     mode: restart
  1012.     then:
  1013.       - if:
  1014.           condition:
  1015.             - text_sensor.state:
  1016.                 id: current_page
  1017.                 state: home
  1018.           then:
  1019.             - script.execute: refresh_relays
  1020.             - script.execute: refresh_wifi_icon
  1021.             - lambda: |-
  1022.                 id(disp1).send_command_printf("is_notification=%i", (id(notification_text).state.empty() and id(notification_label).state.empty()) ? 0 : 1);
  1023.                 id(set_component_color).execute("home.bt_notific", id(notification_unread).state ? id(home_notify_icon_color_unread) : id(home_notify_icon_color_normal), {});
  1024.             - script.execute: refresh_datetime
  1025.             - script.execute: addon_climate_update_page_home
  1026.   - id: service_call_alarm_control_panel
  1027.     mode: restart
  1028.     parameters:
  1029.       entity: string
  1030.       key: string
  1031.       code_format: string
  1032.       pin: string
  1033.     then:
  1034.       - lambda: |-
  1035.           std::string service = "";
  1036.           if (key=="home") service = "alarm_control_panel.alarm_arm_home";
  1037.           else if (key=="away") service = "alarm_control_panel.alarm_arm_away";
  1038.           else if (key=="night") service = "alarm_control_panel.alarm_arm_night";
  1039.           else if (key=="vacation") service = "alarm_control_panel.alarm_arm_vacation";
  1040.           else if (key=="bypass") service = "alarm_control_panel.alarm_arm_custom_bypass";
  1041.           else if (key=="disarm") service = "alarm_control_panel.alarm_disarm";
  1042.           if (service != "" and not service.empty())
  1043.             {
  1044.               HomeassistantServiceResponse resp;
  1045.               HomeassistantServiceMap resp_kv;
  1046.               resp.service = service.c_str();
  1047.               resp_kv.key = "entity_id";
  1048.               resp_kv.value = entity.c_str();
  1049.               resp.data.push_back(resp_kv);
  1050.               if (pin != "" and not pin.empty())
  1051.                 {
  1052.                   resp_kv.key = "code";
  1053.                   resp_kv.value = pin.c_str();
  1054.                   resp.data.push_back(resp_kv);
  1055.                 }
  1056.               id(api_server).send_homeassistant_service_call(resp);
  1057.             }
  1058.   - id: service_call_climate
  1059.     mode: restart
  1060.     parameters:
  1061.       entity: string
  1062.       key: string
  1063.       value: string
  1064.       embedded: bool
  1065.     then:
  1066.       - lambda: |-
  1067.           if (embedded)
  1068.             id(addon_climate_service_call).execute(key.c_str(), value.c_str());
  1069.           else if (key == "set_temperature")
  1070.             id(ha_call_service).execute("climate.set_temperature", "temperature", to_string(stof(value) / 10), entity.c_str());
  1071.           else if (key == "hvac_mode")
  1072.             id(ha_call_service).execute("climate.set_hvac_mode", key.c_str(), value.c_str(), entity.c_str());
  1073.   - id: ha_call_service
  1074.     mode: restart
  1075.     parameters:
  1076.       service: string
  1077.       key: string
  1078.       value: string
  1079.       entity: string
  1080.     then:
  1081.       - lambda: |-
  1082.           if (service != "" and not service.empty())
  1083.             {
  1084.               auto ha_event = new esphome::api::CustomAPIDevice();
  1085.               ha_event->fire_homeassistant_event("esphome.nspanel_ha_blueprint",
  1086.                 {
  1087.                   {"type", "service_call"},
  1088.                   {"service", service},
  1089.                   {"entity", entity},
  1090.                   {"key", key},
  1091.                   {"value", value}
  1092.                 });
  1093.             }
  1094.   - id: ha_button
  1095.     mode: parallel
  1096.     parameters:
  1097.       page: string
  1098.       component: string
  1099.       command: string
  1100.     then:
  1101.       - lambda: |-
  1102.           id(timer_reset_all).execute(page.c_str());
  1103.           auto ha_event = new esphome::api::CustomAPIDevice();
  1104.           ha_event->fire_homeassistant_event("esphome.nspanel_ha_blueprint",
  1105.             {
  1106.               {"type", "button_click"},
  1107.               {"page", page},
  1108.               {"component", component},
  1109.               {"command", command}
  1110.             });
  1111.   - id: update_alarm_icon
  1112.     mode: restart
  1113.     parameters:
  1114.       component: string
  1115.       state: string
  1116.     then:
  1117.       - lambda: |-
  1118.           std::string alarm_icon = "\uEECC"; //mdi:shield-alert-outline
  1119.           int alarm_color = 65535;
  1120.           if (state == "disarmed")
  1121.             {
  1122.               alarm_icon = "\uE99B"; //mdi:shield-off-outline
  1123.               alarm_color = 65535;
  1124.             }
  1125.           else if (state == "armed_home")
  1126.             {
  1127.               alarm_icon = "\uECCA"; //mdi:shield-home-outline
  1128.               alarm_color = 19818;
  1129.             }
  1130.           else if (state == "armed_away")
  1131.             {
  1132.               alarm_icon = "\uECCB"; //mdi:shield-lock-outline
  1133.               alarm_color = 19818;
  1134.             }
  1135.           else if (state == "armed_night")
  1136.             {
  1137.               alarm_icon = "\uF828"; //mdi:shield-moon-outline
  1138.               alarm_color = 19818;
  1139.             }
  1140.           else if (state == "armed_vacation")
  1141.             {
  1142.               alarm_icon = "\uECC6"; //mdi:shield-airplane-outline
  1143.               alarm_color = 19818;
  1144.             }
  1145.           else if (state == "armed_custom_bypass")
  1146.             {
  1147.               alarm_icon = "\uE77F"; //mdi:shield-half-full
  1148.               alarm_color = 19818;
  1149.             }
  1150.           else if (state == "pending" or state == "arming")
  1151.             {
  1152.               alarm_icon = "\uE498"; //mdi:shield-outline
  1153.               alarm_color = 65024;
  1154.             }
  1155.           else if (state == "disarming")
  1156.             {
  1157.               alarm_icon = "\uE99B"; //mdi:shield-off-outline
  1158.               alarm_color = 65024;
  1159.             }
  1160.           else if (state == "triggered")
  1161.             {
  1162.               alarm_icon = "\uEECC"; //mdi:shield-alert-outline
  1163.               alarm_color = 63488;
  1164.             }
  1165.           id(disp1).set_component_text_printf(component.c_str(), alarm_icon.c_str());
  1166.           id(disp1).set_component_font_color(component.c_str(), alarm_color);
  1167.   - id: update_climate_icon
  1168.     mode: restart
  1169.     parameters:
  1170.       component: string
  1171.       action: int
  1172.       mode: int
  1173.     then:
  1174.       - lambda: |-
  1175.           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
  1176.             {
  1177.               case 0: //CLIMATE_ACTION_OFF
  1178.                 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
  1179.                   {
  1180.                     case 0: //CLIMATE_MODE_OFF
  1181.                       id(disp1).set_component_text_printf(component.c_str(), "%s", "\uFFFF"); // (E424) Don't show icon when off
  1182.                       id(disp1).set_component_font_color(component.c_str(), 35921); // grey (off)
  1183.                       break;
  1184.                     case 1: //CLIMATE_MODE_HEAT_COOL
  1185.                       id(disp1).set_component_text_printf(component.c_str(), "%s", "\uE069"); // mdi:autorenew
  1186.                       id(disp1).set_component_font_color(component.c_str(), 35921); // grey (off)
  1187.                       break;
  1188.                     case 2: //CLIMATE_MODE_COOL
  1189.                       id(disp1).set_component_text_printf(component.c_str(), "%s", "\uE716"); // mdi:snowflake
  1190.                       id(disp1).set_component_font_color(component.c_str(), 35921); // grey (off)
  1191.                       break;
  1192.                     case 3: //CLIMATE_MODE_HEAT
  1193.                       id(disp1).set_component_text_printf(component.c_str(), "%s", "\uE237"); // mdi:fire
  1194.                       id(disp1).set_component_font_color(component.c_str(), 35921); // grey (off)
  1195.                       break;
  1196.                     case 4: //CLIMATE_MODE_FAN_ONLY
  1197.                       id(disp1).set_component_text_printf(component.c_str(), "%s", "\uE20F"); // mdi:fan
  1198.                       id(disp1).set_component_font_color(component.c_str(), 35921); // grey (off)
  1199.                       break;
  1200.                     case 5: //CLIMATE_MODE_DRY
  1201.                       id(disp1).set_component_text_printf(component.c_str(), "%s", "\uE58D"); // mdi:water-percent
  1202.                       id(disp1).set_component_font_color(component.c_str(), 35921); // grey (off)
  1203.                       break;
  1204.                     case 6: //CLIMATE_MODE_AUTO
  1205.                       id(disp1).set_component_text_printf(component.c_str(), "%s", "\uEE8D"); // mdi:calendar-sync
  1206.                       id(disp1).set_component_font_color(component.c_str(), 35921); // grey (off)
  1207.                       break;
  1208.                   }
  1209.                   break;
  1210.               case 2: //CLIMATE_ACTION_COOLING
  1211.                 id(disp1).set_component_text_printf(component.c_str(), "%s", "\uE716"); // mdi:snowflake
  1212.                 id(disp1).set_component_font_color(component.c_str(), 1055); // blue
  1213.                 break;
  1214.               case 3: //CLIMATE_ACTION_HEATING
  1215.                 id(disp1).set_component_text_printf(component.c_str(), "%s", "\uE237"); // mdi:fire
  1216.                 id(disp1).set_component_font_color(component.c_str(), 64164); // deep-orange
  1217.                 break;
  1218.               case 4: //CLIMATE_ACTION_IDLE
  1219.                 id(disp1).set_component_text_printf(component.c_str(), "%s", "\uE50E"); // mdi:thermometer
  1220.                 id(disp1).set_component_font_color(component.c_str(), 35921); // grey (off)
  1221.                 break;
  1222.               case 5: //CLIMATE_ACTION_DRYING
  1223.                 id(disp1).set_component_text_printf(component.c_str(), "%s", "\uE58D"); // mdi:water-percent
  1224.                 id(disp1).set_component_font_color(component.c_str(), 64704); // orange
  1225.                 break;
  1226.               case 6: //CLIMATE_ACTION_FAN
  1227.                 id(disp1).set_component_text_printf(component.c_str(), "%s", "\uE20F"); // mdi:fan
  1228.                 id(disp1).set_component_font_color(component.c_str(), 1530); // cyan
  1229.                 break;
  1230.             }
  1231.   - id: set_component_color
  1232.     mode: queued
  1233.     parameters:
  1234.       component: string
  1235.       foreground: int[]
  1236.       background: int[]
  1237.     then:
  1238.       - lambda: |-
  1239.           int fg565 = -1;
  1240.           int bg565 = -1;
  1241.          
  1242.           // Foreground
  1243.           if (foreground.size() == 3) fg565 = ((foreground[0] & 0b11111000) << 8) | ((foreground[1] & 0b11111100) << 3) | (foreground[2] >> 3);
  1244.           else if (foreground.size() == 1) fg565 = foreground[0];
  1245.           if (fg565 >= 0) id(disp1).set_component_font_color(component.c_str(), fg565);
  1246.          
  1247.           // Background
  1248.           if (background.size() == 3) bg565 = ((background[0] & 0b11111000) << 8) | ((background[1] & 0b11111100) << 3) | (background[2] >> 3);
  1249.           else if (background.size() == 1) bg565 = background[0];
  1250.           if (bg565 >= 0) id(disp1).set_component_background_color(component.c_str(), bg565);
  1251.   - id: display_wrapped_text
  1252.     mode: queued
  1253.     parameters:
  1254.       component: string
  1255.       text: string
  1256.       line_length_limit: int
  1257.     then:
  1258.       - lambda: |-
  1259.           int startPos = 0;
  1260.           int endPos = 0;
  1261.           std::string wrappedText = "";
  1262.           while (startPos < text.length()) {
  1263.             while (text[startPos] == ' ' and startPos < text.length()) { startPos++; }
  1264.             int endPos = startPos + line_length_limit;
  1265.             if (endPos >= text.length()) endPos = text.length();
  1266.             else
  1267.               {
  1268.                 while (endPos > startPos && text[endPos] != ' ') { endPos--; }
  1269.                 if (endPos == startPos) endPos = startPos + line_length_limit; // Handle case of long word
  1270.               }
  1271.             wrappedText += text.substr(startPos, endPos-startPos);
  1272.             if (endPos < text.length())
  1273.               {
  1274.                 while (text[endPos] == ' ') { endPos--; }
  1275.                 if (endPos >= startPos) wrappedText += "\\r";
  1276.               }
  1277.             startPos = endPos + 1; // Skip the space
  1278.             while (text[startPos] == ' ' and startPos < text.length()) { startPos++; }
  1279.           }
  1280.           id(disp1).set_component_text_printf(component.c_str(), "%s", wrappedText.c_str());
  1281.   - id: display_embedded_temp
  1282.     mode: restart
  1283.     then:
  1284.       - if:
  1285.           condition:
  1286.             - or:
  1287.                 - lambda: return id(embedded_indoor_temp);
  1288.                 - not:
  1289.                     - api.connected:
  1290.                 - not:
  1291.                     - wifi.connected:
  1292.           then:
  1293.             - lambda: |-
  1294.                 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
  1295.                 else id(disp1).set_component_text_printf("home.current_temp", "%.1f°C", id(temp_nspanel).state);
  1296.   - id: check_versions
  1297.     mode: restart
  1298.     then:
  1299.       - wait_until:
  1300.           condition:
  1301.             - lambda: |-
  1302.                 auto compareVersions = [](const char* version1, const char* version2) -> bool
  1303.                   {
  1304.                     int major1 = 0, minor1 = 0;
  1305.                     int major2 = 0, minor2 = 0;
  1306.                
  1307.                     sscanf(version1, "%d.%d", &major1, &minor1);
  1308.                     sscanf(version2, "%d.%d", &major2, &minor2);
  1309.                
  1310.                     return (major1 == major2) && (minor1 == minor2);
  1311.                   };
  1312.                 return (compareVersions("4.0.2", id(version_tft).c_str()) and compareVersions("4.0.2", id(version_blueprint).c_str()));
  1313.           timeout: 60s
  1314.       - lambda: |-
  1315.           auto compareVersions = [](const char* version1, const char* version2) -> bool
  1316.             {
  1317.                 int major1 = 0, minor1 = 0;
  1318.                 int major2 = 0, minor2 = 0;
  1319.          
  1320.                 sscanf(version1, "%d.%d", &major1, &minor1);
  1321.                 sscanf(version2, "%d.%d", &major2, &minor2);
  1322.          
  1323.                 return (major1 == major2) && (minor1 == minor2);
  1324.             };
  1325.           ESP_LOGD("script.check_versions", "ESPHome version: 4.0.2");
  1326.          ESP_LOGD("script.check_versions", "TFT version: %s", id(version_tft).c_str());
  1327.           if (not compareVersions("4.0.2", id(version_tft).c_str())) ESP_LOGE("script.check_versions", "TFT version mismatch!");
  1328.           ESP_LOGD("script.check_versions", "Blueprint version: %s", id(version_blueprint).c_str());
  1329.           if (not compareVersions("4.0.2", id(version_blueprint).c_str())) ESP_LOGE("script.check_versions", "Blueprint version mismatch!");
  1330.           auto ha_event = new esphome::api::CustomAPIDevice();
  1331.           ha_event->fire_homeassistant_event("esphome.nspanel_ha_blueprint",
  1332.             {
  1333.               {"type", "version"},
  1334.               {"tft", id(version_tft).c_str()},
  1335.               {"esphome", "4.0.2"},
  1336.               {"blueprint", id(version_blueprint).c_str()}
  1337.             });
  1338.   - id: update_page_screensaver
  1339.     mode: restart
  1340.     then:
  1341.       - if:
  1342.           condition:
  1343.             text_sensor.state:
  1344.               id: current_page
  1345.               state: screensaver
  1346.           then:
  1347.             - lambda: |-
  1348.                 int wakeup_page_id = 0;
  1349.                 if (id(wakeup_page_name).state == "buttonpage01") wakeup_page_id = 12;
  1350.                 else if (id(wakeup_page_name).state == "buttonpage02") wakeup_page_id = 13;
  1351.                 else if (id(wakeup_page_name).state == "buttonpage03") wakeup_page_id = 14;
  1352.                 else if (id(wakeup_page_name).state == "buttonpage04") wakeup_page_id = 15;
  1353.                 else if (id(wakeup_page_name).state == "entitypage01") wakeup_page_id = 18;
  1354.                 else if (id(wakeup_page_name).state == "entitypage02") wakeup_page_id = 19;
  1355.                 else if (id(wakeup_page_name).state == "entitypage03") wakeup_page_id = 20;
  1356.                 else if (id(wakeup_page_name).state == "entitypage04") wakeup_page_id = 21;
  1357.                 else if (id(wakeup_page_name).state == "qrcode") wakeup_page_id = 17;
  1358.                 else if (id(wakeup_page_name).state == "alarm") wakeup_page_id = 23;
  1359.                 id(disp1).set_component_value("orign", wakeup_page_id);
  1360.   - id: addon_climate_service_call
  1361.     mode: restart
  1362.     parameters:
  1363.       key: string
  1364.       value: string
  1365.     then:
  1366.       - lambda: ESP_LOGV("script.addon_climate_service_call", "Check for addon_climate");
  1367.   - id: addon_climate_update_page_home
  1368.     mode: restart
  1369.     then:
  1370.       - lambda: ESP_LOGV("script.addon_climate_update_page_home", "Check for addon_climate");
  1371.   - id: addon_climate_set_climate
  1372.     mode: restart
  1373.     parameters:
  1374.       embedded_climate: bool
  1375.     then:
  1376.       - lambda: |-
  1377.           ESP_LOGV("script.addon_climate_set_climate", "Check for addon_climate");
  1378.           ESP_LOGV("script.addon_climate_set_climate", "embedded_climate: %i", (embedded_climate) ? 1 : 0);
  1379.   - id: addon_climate_update_page_climate
  1380.     mode: restart
  1381.     then:
  1382.       - lambda: ESP_LOGV("script.addon_climate_update_page_climate", "Check for addon_climate");
  1383.   - id: addon_climate_set_climate_friendly_name
  1384.     mode: restart
  1385.     parameters:
  1386.       friendly_name: string
  1387.     then:
  1388.       - lambda: |-
  1389.           ESP_LOGV("script.addon_climate_set_climate_friendly_name", "Check for addon_climate");
  1390.           ESP_LOGV("script.addon_climate_set_climate_friendly_name", "friendly_name: %s", friendly_name.c_str());
  1391.  
Add Comment
Please, Sign In to add comment