diff --git a/common/nspanel_terminal/panel.yaml b/common/nspanel_terminal/panel.yaml new file mode 100644 index 0000000..61eefea --- /dev/null +++ b/common/nspanel_terminal/panel.yaml @@ -0,0 +1,1074 @@ +--- +# Sonoff NSPanel (EU) with the nspanel-terminal TFT: ESPHome draws the UI with LVGL. +# Shared part: display, touch, fonts, home page (clock, weather, temperatures), light detail, status/boot page, +# notifications, OTA progress, buzzer, screen power and the NTC sensor. +# The device file adds its grid pages (grid_page.yaml), tiles (*_tile.yaml), buttons and relays: +# substitutions: +# brightness: "80" +# dim_brightness: "20" # backlight after 15 s idle (sleep_dim.yaml lowers it at night) +# packages: +# panel: !include +# file: common/nspanel_terminal/panel.yaml +# vars: +# temperature_entity: sensor.zigbee_office_r_temperature # "dnu" on the home page +# first_page: page_office # tap on the home page +# last_page: page_gate # left arrow of the status page +defaults: + ntc_reference_temperature: 25°C + temperature_name: Temperature + +esphome: + includes: + - common/nspanel_terminal/weather.h + - common/nspanel_terminal/ha.h + - common/nspanel_terminal/light.h + - common/nspanel_terminal/thermostat.h + on_boot: + - priority: -100 + then: + - lvgl.page.show: page_status + +esp32: + variant: esp32 + toolchain: esp-idf + framework: + type: esp-idf + advanced: + flash_chip: generic + minimum_chip_revision: 3.0 + sram1_as_iram: true + sdkconfig_options: + # NSPanel PSRAM on non-default pins + CONFIG_D0WD_PSRAM_CLK_IO: "5" + CONFIG_D0WD_PSRAM_CS_IO: "18" + +psram: + mode: quad + speed: 40MHz + ignore_not_found: false + +external_components: + # fork with the fixes of ptaru/nspanel-terminal#1 (TFT upload, faster redraws); upstream once merged + - source: github://randybb/nspanel-terminal@upload-and-redraw-fixes + components: [nspanel_terminal] + +wifi: + power_save_mode: none + +# Flashing shows on the status page. The OTA blocks the main loop, so each step renders the screen itself +ota: + - id: !extend ota_esphome + on_begin: + - lvgl.page.show: page_status + - lambda: |- + lv_obj_set_hidden(id(status_ota), false); + lv_obj_set_style_text_color(id(status_ota), lv_color_hex(0xFFB300), LV_PART_MAIN); + lv_label_set_text(id(status_ota), "Flashovanie: začína..."); + lv_refr_now(nullptr); + on_progress: + - lambda: |- + lv_label_set_text_fmt(id(status_ota), "Flashovanie: %.0f %%", x); + lv_refr_now(nullptr); + on_end: + - lambda: |- + lv_obj_set_style_text_color(id(status_ota), lv_color_hex(0x4DD966), LV_PART_MAIN); + lv_label_set_text(id(status_ota), "Flashovanie: hotovo, reštartujem"); + lv_refr_now(nullptr); + on_error: + - lambda: |- + lv_obj_set_style_text_color(id(status_ota), lv_color_hex(0xFF453A), LV_PART_MAIN); + lv_label_set_text_fmt(id(status_ota), "Flashovanie: chyba %u", x); + lv_refr_now(nullptr); + +api: + # status page until Home Assistant connects (log viewers don't subscribe to states) + on_client_connected: + - delay: 2s + - if: + condition: + api.connected: + state_subscription_only: true + then: + - lvgl.page.show: page_home + on_client_disconnected: + - if: + condition: + not: + api.connected: + state_subscription_only: true + then: + - lvgl.page.show: page_status + actions: + # same signatures as on the lovelace panels, so the HA automations keep working + - action: notify + variables: + heading: string + message: string + song: string + then: + - script.execute: + id: notify_show + heading: !lambda return heading; + message: !lambda return message; + timeout_ms: 10000 + - if: + condition: + lambda: return !song.empty(); + then: + - rtttl.play: + rtttl: !lambda 'return song;' + # buttons and icon were never implemented on the lovelace panels either + - action: notify_fullscreen + variables: + title: string + description: string + button1: string + button2: string + timeout: int + icon: string + then: + - script.execute: + id: notify_show + heading: !lambda return title; + message: !lambda return description; + timeout_ms: !lambda return timeout; + - rtttl.play: "scale_up:d=32,o=5,b=100:c,c#,d#,e,f#,g#,a#,b" + - action: show_info + then: + - script.execute: info_popup + # https://github.com/granadaxronos/120-SONG_NOKIA_RTTTL_RINGTONE_PLAYER_FOR_ARDUINO_UNO/blob/master/RTTTL_PLAYER/songs.h + - action: play_rtttl + variables: + song: string + then: + - rtttl.play: + rtttl: !lambda 'return song;' + + - action: set_brightness + variables: + percent: int + then: + - lambda: 'id(panel).request_brightness(percent);' + # url empty = tft_url from secrets (terminal), rollback: http://ha.local/local/tft/lui.tft + - action: upload_tft + variables: + url: string + then: + - lambda: |- + if (!url.empty()) id(panel).set_tft_url(url); + id(panel).request_tft_upload(); + +uart: + id: display_uart + tx_pin: 16 + rx_pin: 17 + baud_rate: 115200 + rx_buffer_size: 4096 + +display: + - platform: nspanel_terminal + id: panel + uart_id: display_uart + width: 454 + height: 320 + update_interval: never + auto_clear_enabled: false + tft_url: !secret tft_url_terminal + brightness: ${brightness} + +touchscreen: + - platform: nspanel_terminal + id: panel_touch + display: panel + panel_id: panel + calibration: + x_min: 0 + x_max: 453 + y_min: 0 + y_max: 319 + on_touch: + - if: + condition: + lambda: return id(dimmed); + then: + - globals.set: + id: dimmed + value: "false" + - lambda: 'id(panel).request_brightness(${brightness});' + +globals: + - id: dimmed + type: bool + initial_value: "false" + # light shown on page_light and the index of the page to return to + - id: cur_light + type: std::string + - id: back_page + type: size_t + # brightness the on_idle dim goes to (sleep_dim.yaml lowers it at night) + - id: idle_brightness + type: int + initial_value: ${dim_brightness} + +font: + - file: "gfonts://Inter@500" + id: font_clock + size: 112 + bpp: 4 + glyphs: "0123456789:" + - file: "gfonts://Inter@500" + id: font_big + size: 44 + bpp: 4 + glyphs: "0123456789.,-" + - file: "gfonts://Inter" + id: font_m + size: 22 + bpp: 4 + glyphsets: [GF_Latin_Core] + - file: "gfonts://Inter" + id: font_s + size: 17 + bpp: 4 + glyphsets: [GF_Latin_Core] + + - file: + type: web + url: https://github.com/Templarian/MaterialDesign-Webfont/raw/v7.4.47/fonts/materialdesignicons-webfont.ttf + id: icon_s + size: 30 + bpp: 4 + glyphs: + - "\U000F0594" + - "\U000F0599" + - "\U000F0595" + - "\U000F0590" + - "\U000F0591" + - "\U000F0597" + - "\U000F0596" + - "\U000F0598" + - "\U000F067F" + - "\U000F0592" + - "\U000F0593" + - "\U000F067E" + - "\U000F059D" + - "\U000F059E" + - "\U000F05D6" + - "\U000F0141" + - "\U000F0142" + - "\U000F0374" + - "\U000F0415" + - "\U000F0438" + - "\U000F0238" + - "\U000F0140" + - "\U000F1066" + - "\U000F059C" + - "\U000F024A" + - "\U000F1510" + - "\U000F1253" + - "\U000F1108" + - "\U000F1987" + - "\U000F091D" + - "\U000F0299" + - "\U000F116A" + - "\U000F1169" + - "\U000F17F7" + - "\U000F17F8" + - "\U000F06A9" + - "\U000F00DF" + - "\U000F05A8" + - "\U000F03D8" + - "\U000F0425" + - "\U000F0379" + - "\U000F04B9" + - "\U000F0502" + - "\U000F0769" + - "\U000F1051" + - "\U000F1793" + - "\U000F18DE" + - "\U000F181C" + - "\U000F04DE" + - "\U000F06B5" + - "\U000F07F4" + - "\U000F0C6E" + - "\U000F0DDC" + - file: + type: web + url: https://github.com/Templarian/MaterialDesign-Webfont/raw/v7.4.47/fonts/materialdesignicons-webfont.ttf + id: icon_l + size: 52 + bpp: 4 + glyphs: + - "\U000F0594" + - "\U000F0599" + - "\U000F0595" + - "\U000F0590" + - "\U000F0591" + - "\U000F0597" + - "\U000F0596" + - "\U000F0598" + - "\U000F067F" + - "\U000F0592" + - "\U000F0593" + - "\U000F067E" + - "\U000F059D" + - "\U000F059E" + - "\U000F05D6" + - "\U000F0299" + - "\U000F116A" + - "\U000F1169" + - "\U000F17F7" + - "\U000F17F8" + - "\U000F06A9" + +script: + # counts as activity: wakes the dimmed screen and restarts the idle timeout back to the home page + - id: wake_screen + then: + - lambda: |- + lv_display_trigger_activity(nullptr); + if (id(dimmed)) { + id(dimmed) = false; + id(panel).request_brightness(${brightness}); + } + # like the info popup of the other panels: device info is on the status page + # notification over every page (top layer); closes on tap or after the timeout + - id: notify_show + mode: restart + parameters: + heading: string + message: string + timeout_ms: int + then: + - lambda: |- + lv_label_set_text(id(notify_heading), heading.c_str()); + lv_label_set_text(id(notify_message), message.c_str()); + lv_obj_set_hidden(id(notify_popup), false); + - script.execute: wake_screen + - delay: !lambda 'return timeout_ms > 0 ? timeout_ms : 10000;' + - lvgl.widget.hide: notify_popup + - id: info_popup + then: + - lvgl.page.show: page_status + - script.execute: wake_screen + # same as the status screens of the other LVGL devices (mcu-lvgl.yaml) + - id: update_status + then: + - lambda: |- + // ok green, waiting orange, details gray + static const uint32_t OK = 0x4DD966, WAIT = 0xFFB300; + auto set = [](lv_obj_t *label, const std::string &text, uint32_t color) { + lv_label_set_text(label, text.c_str()); + lv_obj_set_style_text_color(label, lv_color_hex(color), LV_PART_MAIN); + }; + + auto *wifi = wifi::global_wifi_component; + const bool wifi_ok = wifi->is_connected(); + // diagnostics for slow connects after a cold start: seconds to connect, AP association + static uint32_t connected_s = 0; + if (wifi_ok && !connected_s) + connected_s = std::max(1, millis() / 1000); + if (wifi_ok) { + set(id(status_wifi), str_sprintf("WiFi: pripojené za %u s (%d dBm)", connected_s, wifi->wifi_rssi()), OK); + } else { + auto bssid = wifi->wifi_bssid(); + bool associated = std::any_of(bssid.begin(), bssid.end(), [](uint8_t b) { return b != 0; }); + set(id(status_wifi), + str_sprintf("WiFi: pripájam... %s, %us", associated ? "AP ok, čakám na IP" : "bez AP", millis() / 1000), + WAIT); + } + + // IPv6 first (skip link-local), then IPv4 + std::string ips; + char buf[network::IP_ADDRESS_BUFFER_SIZE]; + for (bool v6 : {true, false}) { + for (auto &ip : wifi->get_ip_addresses()) { + if (!ip.is_set() || ip.is_ip6() != v6) + continue; + ip.str_to(buf); + if (v6 && strncmp(buf, "fe80", 4) == 0) + continue; + if (!ips.empty()) + ips += "\n"; + ips += buf; + } + } + lv_label_set_text(id(status_ips), ips.c_str()); + lv_obj_set_hidden(id(status_ips), ips.empty()); + + const bool api_ok = api::global_api_server->is_connected(true); + set(id(status_ha), api_ok ? "Home Assistant: pripojený" : "Home Assistant: čakám...", api_ok ? OK : WAIT); + + const uint32_t up = millis() / 1000; + static char build[Application::BUILD_TIME_STR_SIZE] = ""; + if (!build[0]) + App.get_build_time_string(build); + lv_label_set_text(id(status_footer), + str_sprintf("ESPHome %s · beží %ud %02u:%02u:%02u\n%s", ESPHOME_VERSION, up / 86400, + (up / 3600) % 24, (up / 60) % 60, up % 60, build).c_str()); + - id: open_light + parameters: + entity: string + name: string + dim: bool + kmin: int + hs: bool + is_on: bool + bri: float + ct: float + hue: string + then: + - lambda: |- + id(cur_light) = entity; + id(back_page) = id(lvgl_main)->get_current_page(); + lv_label_set_text(id(detail_title), name.c_str()); + lv_obj_set_state(id(detail_power), LV_STATE_CHECKED, is_on); + lv_obj_set_hidden(id(detail_bri_row), !dim); + // colour lights get hue only: brightness plus either colour temperature or hue + lv_obj_set_hidden(id(detail_ct_row), !kmin || hs); + lv_obj_set_hidden(id(detail_hue_row), !hs); + lv_slider_set_value(id(detail_bri), brightness_pct(bri), LV_ANIM_OFF); + if (kmin) { + lv_slider_set_range(id(detail_ct), kmin, 6500); + lv_slider_set_value(id(detail_ct), std::isnan(ct) ? kmin : ct, LV_ANIM_OFF); + } + lv_slider_set_value(id(detail_hue), std::max(0, parse_hue(hue)), LV_ANIM_OFF); + - lvgl.page.show: page_light + - id: update_forecast + then: + - lambda: |- + static const char *const DAYS[] = {"ne", "po", "ut", "st", "št", "pi", "so"}; + lv_obj_t *const DAY[] = {id(forecast_day_0), id(forecast_day_1), id(forecast_day_2)}; + lv_obj_t *const ICON[] = {id(forecast_icon_0), id(forecast_icon_1), id(forecast_icon_2)}; + lv_obj_t *const HIGH[] = {id(today_high), id(forecast_high_0), id(forecast_high_1), id(forecast_high_2)}; + lv_obj_t *const LOW[] = {id(today_low), id(forecast_low_0), id(forecast_low_1), id(forecast_low_2)}; + auto now = id(ha_time).now(); + ForecastDay days[4]; + // index 0 is today + int n = now.is_valid() ? parse_forecast(id(forecast).state, 0, days, 4) : 0; + for (int i = 0; i < 4; i++) { + if (i < n) { + lv_label_set_text_fmt(HIGH[i], "%.1f°C", days[i].high); + lv_label_set_text_fmt(LOW[i], "%.1f°C", days[i].low); + } else { + lv_label_set_text(HIGH[i], ""); + lv_label_set_text(LOW[i], ""); + } + if (i == 0) continue; + lv_label_set_text(DAY[i - 1], i < n ? DAYS[(now.day_of_week + i - 1) % 7] : ""); + lv_label_set_text(ICON[i - 1], i < n ? weather_icon(days[i].condition) : ""); + } + - id: update_clock + then: + - lambda: |- + static const char *const DAYS[] = {"nedeľa", "pondelok", "utorok", "streda", "štvrtok", "piatok", "sobota"}; + static const char *const MONTHS[] = {"januára", "februára", "marca", "apríla", "mája", "júna", + "júla", "augusta", "septembra", "októbra", "novembra", "decembra"}; + auto now = id(ha_time).now(); + if (!now.is_valid()) return; + lv_label_set_text(id(clock_label), now.strftime("%H:%M").c_str()); + lv_label_set_text_fmt(id(date_label), "%s, %u. %s", DAYS[now.day_of_week - 1], now.day_of_month, + MONTHS[now.month - 1]); + +time: + - id: !extend ha_time + on_time_sync: + - script.execute: update_clock + - script.execute: update_forecast + on_time: + - seconds: 0 + then: + - script.execute: update_clock + +image: + - platform: file + file: assets/images/made-for-esphome-white-on-black.svg + id: esphome_logo + resize: 300x88 + type: RGB565 + transparency: alpha_channel + +interval: + - interval: 1s + then: + - if: + condition: + lvgl.page.is_showing: page_status + then: + - script.execute: update_status + +lvgl: + id: lvgl_main + displays: panel + # 1/8 screen draw buffer in internal RAM; a full-screen PSRAM buffer renders much slower + buffer_size: 12.5% + touchscreens: + - touchscreen_id: panel_touch + color_depth: 16 + bg_color: 0x000000 + text_color: 0xFFFFFF + text_font: font_m + gradients: + - id: ct_grad + direction: HOR + stops: + - {color: 0xFF9A3C, position: 0%} + - {color: 0xFFE4C4, position: 50%} + - {color: 0xCFDCFF, position: 100%} + - id: hue_grad + direction: HOR + stops: + - {color: 0xFF0000, position: 0%} + - {color: 0xFFFF00, position: 17%} + - {color: 0x00FF00, position: 33%} + - {color: 0x00FFFF, position: 50%} + - {color: 0x0000FF, position: 67%} + - {color: 0xFF00FF, position: 83%} + - {color: 0xFF0000, position: 100%} + style_definitions: + - id: tile_style + bg_color: 0x1C1C1E + bg_opa: COVER + radius: 14 + border_width: 0 + shadow_width: 0 + pad_all: 14 + text_color: 0xFFFFFF + text_font: font_m + - id: page_style + bg_color: 0x000000 + bg_opa: COVER + text_font: font_m + text_color: 0xFFFFFF + border_width: 0 + pad_all: 16 + pad_row: 12 + pad_column: 12 + on_idle: + timeout: 15s + then: + # without Home Assistant the status page stays + - if: + condition: + api.connected: + state_subscription_only: true + then: + - lvgl.page.show: page_home + - globals.set: + id: dimmed + value: "true" + - lambda: 'id(panel).request_brightness(id(idle_brightness));' + top_layer: + widgets: + - obj: + id: notify_popup + hidden: true + width: 100% + height: 100% + bg_color: 0x000000 + bg_opa: 70% + border_width: 0 + radius: 0 + pad_all: 24 + on_click: + - script.stop: notify_show + - lvgl.widget.hide: notify_popup + widgets: + - obj: + clickable: false + width: 100% + height: 100% + styles: tile_style + pad_all: 20 + layout: + type: FLEX + flex_flow: COLUMN + pad_row: 12 + widgets: + - label: + id: notify_heading + text: "" + text_color: 0xF5B342 + width: 100% + long_mode: WRAP + - label: + id: notify_message + text: "" + width: 100% + long_mode: WRAP + # Pages, not a tileview: a tile switch made LVGL render the whole screen three times. No animation, + # every frame of one would be a full-screen redraw over UART (~290 kB). + pages: + - id: page_home + styles: page_style + on_click: + - lvgl.page.show: ${first_page} + widgets: + - label: + id: clock_label + text: "--:--" + text_font: font_clock + align: TOP_LEFT + x: 4 + y: -10 + - label: + id: date_label + text: "" + text_color: 0xB4B4BA + align: TOP_LEFT + x: 10 + y: 118 + - label: + id: nameday_label + text: "" + text_font: font_s + text_color: 0x8E8E93 + align: TOP_LEFT + x: 10 + y: 148 + - obj: + clickable: false + align: TOP_RIGHT + width: SIZE_CONTENT + height: SIZE_CONTENT + bg_opa: TRANSP + border_width: 0 + pad_all: 0 + layout: + type: FLEX + flex_flow: COLUMN + pad_row: 10 + widgets: + - <<: !include {file: forecast_day.yaml, vars: {i: 0}} + - <<: !include {file: forecast_day.yaml, vars: {i: 1}} + - <<: !include {file: forecast_day.yaml, vars: {i: 2}} + - obj: + clickable: false + align: BOTTOM_LEFT + x: 8 + y: -22 + width: SIZE_CONTENT + height: SIZE_CONTENT + bg_opa: TRANSP + border_width: 0 + pad_all: 0 + text_color: 0xFFFFFF + layout: + type: FLEX + pad_column: 2 + flex_flow: ROW + flex_align_cross: START + widgets: + - label: + id: in_temp_label + text: "-" + text_font: font_big + text_color: 0xFFFFFF + - label: + text: "°C" + y: 6 + text_color: 0xB4B4BA + - label: + text: "dnu" + text_font: font_s + text_color: 0x8E8E93 + align: BOTTOM_LEFT + x: 10 + - obj: + clickable: false + align: BOTTOM_LEFT + x: 158 + y: -22 + width: SIZE_CONTENT + height: SIZE_CONTENT + bg_opa: TRANSP + border_width: 0 + pad_all: 0 + text_color: 0xFFFFFF + layout: + type: FLEX + pad_column: 2 + flex_flow: ROW + flex_align_cross: START + widgets: + - label: + id: out_temp_label + text: "-" + text_font: font_big + text_color: 0xFFFFFF + - label: + text: "°C" + y: 6 + text_color: 0xB4B4BA + - label: + text: "von" + text_font: font_s + text_color: 0x8E8E93 + align: BOTTOM_LEFT + x: 160 + - obj: + clickable: false + align: BOTTOM_RIGHT + # same bottom offset as the temperatures; the boxes are equally tall, so the centres line up + y: -22 + width: SIZE_CONTENT + height: SIZE_CONTENT + bg_opa: TRANSP + border_width: 0 + pad_all: 0 + layout: + type: FLEX + flex_flow: ROW + flex_align_cross: CENTER + pad_column: 10 + widgets: + - label: + id: weather_icon_label + text: "" + text_font: icon_l + text_color: 0xFFFFFF + - obj: + clickable: false + width: SIZE_CONTENT + height: SIZE_CONTENT + bg_opa: TRANSP + border_width: 0 + pad_all: 0 + layout: + type: FLEX + flex_flow: COLUMN + pad_row: 0 + widgets: + - label: + id: today_high + text: "" + text_color: 0xFFFFFF + - label: + id: today_low + text: "" + text_color: 0x8E8E93 + # Status: boot screen until Home Assistant connects, then the last (diagnostic) page + - id: page_status + styles: page_style + on_load: + - script.execute: update_status + widgets: + - <<: !include + file: page_arrow.yaml + vars: {icon: "\U000F0141", align: TOP_LEFT, x: -16, to: "${last_page}", hidden: false} + - image: + src: esphome_logo + align: TOP_MID + - label: + align: TOP_MID + y: 96 + text: !lambda return App.get_name(); + - obj: + clickable: false + align: TOP_LEFT + x: 8 + y: 136 + width: 100% + height: SIZE_CONTENT + bg_opa: TRANSP + border_width: 0 + pad_all: 0 + layout: + type: FLEX + flex_flow: COLUMN + pad_row: 6 + widgets: + - label: + id: status_wifi + text_font: font_s + text: "" + - label: + id: status_ips + text_font: font_s + text_color: 0x8E8E93 + pad_left: 20 + text: "" + - label: + id: status_ha + text_font: font_s + text: "" + # shown only while flashing (ota: above) + - label: + id: status_ota + text_font: font_s + text: "" + hidden: true + - label: + id: status_footer + text_font: font_s + text_color: 0x8E8E93 + text: "" + # Light detail, opened by a long press on a light button (script open_light) + - id: page_light + styles: page_style + layout: + type: FLEX + flex_flow: COLUMN + pad_row: 26 + widgets: + - obj: + clickable: false + width: 100% + height: 44 + bg_opa: TRANSP + border_width: 0 + pad_all: 0 + widgets: + - obj: + align: LEFT_MID + x: -16 + width: 72 + height: 52 + bg_opa: TRANSP + border_width: 0 + pad_all: 0 + on_click: + - lambda: 'id(lvgl_main)->show_page(id(back_page), LV_SCREEN_LOAD_ANIM_NONE, 0);' + widgets: + - label: + text: "\U000F0141" + text_font: icon_s + text_color: 0xB4B4BA + align: CENTER + - label: + id: detail_title + text: "" + align: CENTER + - button: + id: detail_power + align: RIGHT_MID + width: 64 + height: 44 + styles: tile_style + pad_all: 0 + checked: + bg_color: 0xF5B342 + text_color: 0x000000 + on_click: + - homeassistant.action: + action: light.toggle + data: + entity_id: !lambda return id(cur_light); + widgets: + - label: + text: "\U000F0425" + text_font: icon_s + align: CENTER + - obj: + id: detail_bri_row + clickable: false + width: 100% + height: SIZE_CONTENT + bg_opa: TRANSP + border_width: 0 + pad_all: 0 + layout: + type: FLEX + flex_flow: ROW + flex_align_cross: CENTER + pad_column: 14 + widgets: + - label: + text: "\U000F00DF" + text_font: icon_s + text_color: 0xB4B4BA + - slider: + id: detail_bri + flex_grow: 1 + height: 44 + min_value: 1 + max_value: 100 + radius: 22 + bg_color: 0x2C2C2E + indicator: + bg_color: 0xF5B342 + radius: 22 + knob: + bg_color: 0xFFFFFF + pad_all: 2 + on_release: + - homeassistant.action: + action: light.turn_on + data: + entity_id: !lambda return id(cur_light); + brightness_pct: !lambda return (int) x; + - obj: + id: detail_ct_row + clickable: false + width: 100% + height: SIZE_CONTENT + bg_opa: TRANSP + border_width: 0 + pad_all: 0 + layout: + type: FLEX + flex_flow: ROW + flex_align_cross: CENTER + pad_column: 14 + widgets: + - label: + text: "\U000F05A8" + text_font: icon_s + text_color: 0xB4B4BA + - slider: + id: detail_ct + flex_grow: 1 + height: 44 + min_value: 1700 + max_value: 6500 + radius: 22 + bg_grad: ct_grad + bg_opa: COVER + indicator: + bg_opa: TRANSP + radius: 22 + knob: + bg_color: 0xFFFFFF + pad_all: 2 + on_release: + - homeassistant.action: + action: light.turn_on + data: + entity_id: !lambda return id(cur_light); + color_temp_kelvin: !lambda return (int) x; + - obj: + id: detail_hue_row + clickable: false + width: 100% + height: SIZE_CONTENT + bg_opa: TRANSP + border_width: 0 + pad_all: 0 + layout: + type: FLEX + flex_flow: ROW + flex_align_cross: CENTER + pad_column: 14 + widgets: + - label: + text: "\U000F03D8" + text_font: icon_s + text_color: 0xB4B4BA + - slider: + id: detail_hue + flex_grow: 1 + height: 44 + min_value: 0 + max_value: 360 + radius: 22 + bg_grad: hue_grad + bg_opa: COVER + indicator: + bg_opa: TRANSP + radius: 22 + knob: + bg_color: 0xFFFFFF + pad_all: 2 + on_release: + - homeassistant.action: + action: light.turn_on + data: + entity_id: !lambda return id(cur_light); + data_template: + hs_color: "{{ [hue | int, 100] }}" + variables: + hue: !lambda return (int) x; + +text_sensor: + - platform: homeassistant + id: forecast + entity_id: sensor.weather_forecast_daily + attribute: forecast + internal: true + on_value: + - script.execute: update_forecast + - platform: homeassistant + id: nameday + entity_id: sensor.nameday_sk + internal: true + on_value: + - lvgl.label.update: + id: nameday_label + text: !lambda return x; + - platform: homeassistant + id: weather + entity_id: weather.outside + internal: true + on_value: + - lambda: |- + lv_label_set_text(id(weather_icon_label), weather_icon(x)); + +button: + # as on the other panels: put button._info on a dashboard, HA presses it + - platform: template + name: Info + id: info_button + entity_category: diagnostic + on_press: + - script.execute: info_popup + +output: + - platform: ledc + id: buzzer_out + pin: + number: 21 + +switch: + # better not toggled from HA: the display must be set up again afterwards + - platform: gpio + name: Screen Power + id: screen_power + entity_category: config + pin: + number: 4 + inverted: true + restore_mode: ALWAYS_ON + +rtttl: + id: buzzer + output: buzzer_out + +sensor: + - platform: adc + id: ntc_source + pin: 38 + update_interval: 5min + attenuation: 12db + + - platform: resistance + id: resistance_sensor + sensor: ntc_source + configuration: DOWNSTREAM + resistor: 11.2kOhm + + - platform: ntc + id: temperature + name: ${temperature_name} + sensor: resistance_sensor + calibration: + b_constant: 3950 + reference_temperature: ${ntc_reference_temperature} + reference_resistance: 10kOhm + + - platform: homeassistant + id: inside_temperature + entity_id: ${temperature_entity} + internal: true + on_value: + - lvgl.label.update: + id: in_temp_label + text: !lambda 'return std::isnan(x) ? std::string("--") : str_sprintf("%.1f", x);' + + - platform: homeassistant + id: outside_temperature + entity_id: sensor.zigbee_outside_temperature + internal: true + on_value: + - lvgl.label.update: + id: out_temp_label + text: !lambda 'return std::isnan(x) ? std::string("--") : str_sprintf("%.1f", x);' diff --git a/common/nspanel_terminal/sleep_dim.yaml b/common/nspanel_terminal/sleep_dim.yaml index a2db4bc..f75c961 100644 --- a/common/nspanel_terminal/sleep_dim.yaml +++ b/common/nspanel_terminal/sleep_dim.yaml @@ -1,17 +1,11 @@ --- # nspanel-terminal version of common/nspanel_sleep_dim.yaml: the idle (dimmed) brightness drops to 0 at night -# (sun below -6°), unless the room light is on. Uses the dimmed global, the panel display and ${dim_brightness}. +# (sun below -6°), unless the room light is on. Sets the idle_brightness global of panel.yaml (${dim_brightness} or 0). # packages: # sleep_dim: !include # file: common/nspanel_terminal/sleep_dim.yaml # vars: # sleep_override_entity: light.bedroom_lights -globals: - # brightness the on_idle dim goes to - - id: idle_brightness - type: int - initial_value: ${dim_brightness} - script: - id: apply_sleep_dim then: diff --git a/common/nspanel_terminal/thermostat.yaml b/common/nspanel_terminal/thermostat.yaml index 92e1465..fe153ff 100644 --- a/common/nspanel_terminal/thermostat.yaml +++ b/common/nspanel_terminal/thermostat.yaml @@ -1,76 +1,303 @@ -# Home Assistant state and target sending for the thermostat page (page_5). -# Package vars: entity (climate entity with heat/off and the Better Thermostat presets), boiler (switch enabling heating) +# Package: thermostat page (arc with target temperature, -/+, heat/off, boiler switch, presets) and its HA state. +# vars: id (prefix of its ids, unique per thermostat page), page, title, prev, next (page ids for the arrows), +# entity (climate with heat/off and presets), +# boiler (switch that lets the boiler fire, the same in every room) +defaults: + boiler: switch.heating_enabled + +globals: + # preset_modes of the thermostat, in dropdown order + - id: ${id}_preset_list + type: std::vector + +lvgl: + pages: + - id: ${page} + styles: page_style + widgets: + - label: + text: "${title}" + text_font: font_s + text_color: 0xB4B4BA + width: 100% + text_align: CENTER + - <<: !include + file: page_arrow.yaml + vars: {icon: "\U000F0141", align: TOP_LEFT, x: -16, to: "${prev}", hidden: false} + - <<: !include + file: page_arrow.yaml + vars: {icon: "\U000F0142", align: TOP_RIGHT, x: 16, to: "${next}", hidden: false} + # target temperature in half degrees, 10..30 °C + - arc: + id: ${id}_arc + disabled: + arc_color: 0x161618 + align: BOTTOM_LEFT + y: -20 + width: 220 + height: 220 + min_value: 20 + max_value: 60 + arc_width: 16 + arc_color: 0x2C2C2E + indicator: + arc_width: 16 + arc_color: 0x8E8E93 + knob: + bg_color: 0xFFFFFF + pad_all: 2 + on_value: + - lambda: 'lv_label_set_text_fmt(id(${id}_target_label), "%.1f", x / 2.0f);' + on_release: + - script.execute: ${id}_send_target + widgets: + - obj: + clickable: false + align: CENTER + y: -8 + width: SIZE_CONTENT + height: SIZE_CONTENT + bg_opa: TRANSP + border_width: 0 + pad_all: 0 + text_color: 0xFFFFFF + layout: + type: FLEX + flex_flow: ROW + flex_align_cross: START + pad_column: 2 + widgets: + - label: + id: ${id}_target_label + text: "-" + text_font: font_big + text_color: 0xFFFFFF + - label: + text: "°C" + y: 6 + text_color: 0xB4B4BA + - label: + id: ${id}_current_label + text: "" + text_font: font_s + text_color: 0xB4B4BA + align: CENTER + y: 34 + - label: + id: ${id}_action_label + text: "" + text_font: font_s + text_color: 0x8E8E93 + align: CENTER + y: -50 + - button: + id: ${id}_minus + align: BOTTOM_LEFT + x: 46 + width: 56 + height: 44 + styles: tile_style + disabled: + bg_color: 0x161618 + text_color: 0x48484A + pad_all: 0 + on_click: + - lambda: |- + lv_arc_set_value(id(${id}_arc), lv_arc_get_value(id(${id}_arc)) - 1); + lv_label_set_text_fmt(id(${id}_target_label), "%.1f", lv_arc_get_value(id(${id}_arc)) / 2.0f); + - script.execute: ${id}_send_target + widgets: + - label: + text: "\U000F0374" + text_font: icon_s + align: CENTER + - button: + id: ${id}_plus + align: BOTTOM_LEFT + x: 118 + width: 56 + height: 44 + styles: tile_style + disabled: + bg_color: 0x161618 + text_color: 0x48484A + pad_all: 0 + on_click: + - lambda: |- + lv_arc_set_value(id(${id}_arc), lv_arc_get_value(id(${id}_arc)) + 1); + lv_label_set_text_fmt(id(${id}_target_label), "%.1f", lv_arc_get_value(id(${id}_arc)) / 2.0f); + - script.execute: ${id}_send_target + widgets: + - label: + text: "\U000F0415" + text_font: icon_s + align: CENTER + - button: + id: ${id}_power + align: TOP_RIGHT + x: -90 + y: 36 + width: 82 + height: 44 + styles: tile_style + disabled: + bg_color: 0x161618 + text_color: 0x48484A + pad_all: 0 + checked: + bg_color: 0xF5B342 + text_color: 0x000000 + on_click: + - homeassistant.action: + action: climate.set_hvac_mode + data: + entity_id: ${entity} + hvac_mode: !lambda 'return id(${id}_mode).state == "heat" ? "off" : "heat";' + widgets: + - label: + text: "\U000F0438" + text_font: icon_s + align: LEFT_MID + x: 6 + - label: + text: "Izba" + text_font: font_s + align: RIGHT_MID + x: -8 + # the boiler only fires with this switch on + - button: + id: ${id}_boiler_button + align: TOP_RIGHT + x: 0 + y: 36 + width: 82 + height: 44 + styles: tile_style + disabled: + bg_color: 0x161618 + text_color: 0x48484A + pad_all: 0 + checked: + bg_color: 0xF5B342 + text_color: 0x000000 + on_click: + - homeassistant.action: + action: switch.toggle + data: + entity_id: ${boiler} + widgets: + - label: + text: "\U000F0238" + text_font: icon_s + align: LEFT_MID + x: 6 + - label: + text: "Kotol" + text_font: font_s + align: RIGHT_MID + x: -8 + # options come from the preset_modes attribute (thermostat.yaml) + - dropdown: + id: ${id}_preset_dropdown + disabled: + text_color: 0x48484A + align: TOP_RIGHT + y: 92 + width: 172 + options: ["-"] + styles: tile_style + pad_all: 10 + symbol: "\U000F0140" + indicator: + text_font: icon_s + dropdown_list: + bg_color: 0x2C2C2E + text_color: 0xFFFFFF + text_font: font_m + border_width: 0 + radius: 14 + selected: + checked: + bg_color: 0xF5B342 + text_color: 0x000000 + on_value: + - homeassistant.action: + action: climate.set_preset_mode + data: + entity_id: ${entity} + preset_mode: !lambda 'return x < id(${id}_preset_list).size() ? id(${id}_preset_list)[x] : std::string();' + sensor: - platform: homeassistant - id: thermo_target + id: ${id}_target entity_id: ${entity} attribute: temperature internal: true on_value: - lambda: |- if (std::isnan(x)) return; - lv_arc_set_value(id(thermo_arc), std::lround(x * 2)); - lv_label_set_text_fmt(id(thermo_target_label), "%.1f", x); + lv_arc_set_value(id(${id}_arc), std::lround(x * 2)); + lv_label_set_text_fmt(id(${id}_target_label), "%.1f", x); - platform: homeassistant - id: thermo_current + id: ${id}_current entity_id: ${entity} attribute: current_temperature internal: true on_value: - - lambda: 'lv_label_set_text_fmt(id(thermo_current_label), "teraz %.1f°C", x);' + - lambda: 'lv_label_set_text_fmt(id(${id}_current_label), "teraz %.1f°C", x);' text_sensor: # text, not binary: a binary sensor drops "unavailable" - platform: homeassistant - id: heating_enabled + id: ${id}_boiler entity_id: ${boiler} internal: true on_value: - lambda: |- - lv_obj_set_state(id(heating_enabled_button), LV_STATE_CHECKED, x == "on"); - lv_obj_set_state(id(heating_enabled_button), LV_STATE_DISABLED, ha_unavailable(x)); + lv_obj_set_state(id(${id}_boiler_button), LV_STATE_CHECKED, x == "on"); + lv_obj_set_state(id(${id}_boiler_button), LV_STATE_DISABLED, ha_unavailable(x)); - platform: homeassistant - id: thermo_mode + id: ${id}_mode entity_id: ${entity} internal: true on_value: - lambda: |- - lv_obj_set_state(id(thermo_power), LV_STATE_CHECKED, x == "heat"); + lv_obj_set_state(id(${id}_power), LV_STATE_CHECKED, x == "heat"); // thermostat unavailable: grey out its controls - for (lv_obj_t *o : {(lv_obj_t *) id(thermo_power), (lv_obj_t *) id(thermo_arc), id(thermo_minus), id(thermo_plus), - id(thermo_preset_dropdown)->obj}) + for (lv_obj_t *o : {(lv_obj_t *) id(${id}_power), (lv_obj_t *) id(${id}_arc), id(${id}_minus), id(${id}_plus), + id(${id}_preset_dropdown)->obj}) lv_obj_set_state(o, LV_STATE_DISABLED, ha_unavailable(x)); - - script.execute: thermo_update_action + - script.execute: ${id}_update_action - platform: homeassistant - id: thermo_action + id: ${id}_action entity_id: ${entity} attribute: hvac_action internal: true on_value: - - script.execute: thermo_update_action + - script.execute: ${id}_update_action - platform: homeassistant - id: thermo_presets + id: ${id}_presets entity_id: ${entity} attribute: preset_modes internal: true on_value: - lambda: |- - id(preset_list) = parse_list(x); + id(${id}_preset_list) = parse_list(x); std::string options; - for (auto &p : id(preset_list)) options += (options.empty() ? "" : "\n") + preset_name(p); - lv_dropdown_set_options(id(thermo_preset_dropdown)->obj, options.c_str()); - - script.execute: thermo_select_preset + for (auto &p : id(${id}_preset_list)) options += (options.empty() ? "" : "\n") + preset_name(p); + lv_dropdown_set_options(id(${id}_preset_dropdown)->obj, options.c_str()); + - script.execute: ${id}_select_preset - platform: homeassistant - id: thermo_preset + id: ${id}_preset entity_id: ${entity} attribute: preset_mode internal: true on_value: - - script.execute: thermo_select_preset + - script.execute: ${id}_select_preset script: # Arc and -/+ change the target locally; send once the user stops for a moment - - id: thermo_send_target + - id: ${id}_send_target mode: restart then: - delay: 800ms @@ -78,17 +305,24 @@ script: action: climate.set_temperature data: entity_id: ${entity} - temperature: !lambda return lv_arc_get_value(id(thermo_arc)) / 2.0f; - - id: thermo_update_action + temperature: !lambda return lv_arc_get_value(id(${id}_arc)) / 2.0f; + # back to what HA has, in case it did not take the change (e.g. actions not allowed for this device) + - delay: 5s + - lambda: |- + float target = id(${id}_target).state; + if (std::isnan(target)) return; + lv_arc_set_value(id(${id}_arc), std::lround(target * 2)); + lv_label_set_text_fmt(id(${id}_target_label), "%.1f", target); + - id: ${id}_update_action then: - lambda: |- - bool off = id(thermo_mode).state == "off"; - bool heating = id(thermo_action).state == "heating"; - lv_label_set_text(id(thermo_action_label), off ? "vypnuté" : heating ? "kúri" : "nekúri"); - lv_obj_set_style_arc_color(id(thermo_arc), lv_color_hex(heating ? 0xF5B342 : 0x8E8E93), LV_PART_INDICATOR); - - id: thermo_select_preset + bool off = id(${id}_mode).state == "off"; + bool heating = id(${id}_action).state == "heating"; + lv_label_set_text(id(${id}_action_label), off ? "vypnuté" : heating ? "kúri" : "nekúri"); + lv_obj_set_style_arc_color(id(${id}_arc), lv_color_hex(heating ? 0xF5B342 : 0x8E8E93), LV_PART_INDICATOR); + - id: ${id}_select_preset then: - lambda: |- - auto &list = id(preset_list); - auto it = std::find(list.begin(), list.end(), id(thermo_preset).state); - if (it != list.end()) lv_dropdown_set_selected(id(thermo_preset_dropdown)->obj, it - list.begin()); + auto &list = id(${id}_preset_list); + auto it = std::find(list.begin(), list.end(), id(${id}_preset).state); + if (it != list.end()) lv_dropdown_set_selected(id(${id}_preset_dropdown)->obj, it - list.begin()); diff --git a/mcu-nspanel-bedroom.yaml b/mcu-nspanel-bedroom.yaml index a8396b8..6b92790 100644 --- a/mcu-nspanel-bedroom.yaml +++ b/mcu-nspanel-bedroom.yaml @@ -18,7 +18,10 @@ substitutions: name: Bedroom NSPanel name_short: Bedroom area: Bedroom - comment: NSPanel + comment: NSPanel (nspanel-terminal) + brightness: "80" + # backlight after 15 s idle + dim_brightness: "20" esphome: name: mcu-${device} @@ -29,51 +32,34 @@ esphome: packages: common: !include common/common.yaml ipv6_only: !include common/ipv6_only.yaml - nspanel: !include - file: common/nspanel.yaml + panel: !include + file: common/nspanel_terminal/panel.yaml vars: temperature_entity: sensor.zigbee_bedroom_temperature + first_page: page_bedroom + last_page: page_thermostat sleep_dim: !include - file: common/nspanel_sleep_dim.yaml + file: common/nspanel_terminal/sleep_dim.yaml vars: sleep_override_entity: light.bedroom_lights + # Grid page tiles: each package adds its tile to the page and fills it in this order + # Spálňa + s_tv: !include {file: common/nspanel_terminal/switch_tile.yaml, vars: {page: page_bedroom, id: s_tv, name: "TV", entity: switch.mcu_socket_01_relay, icon: "\U000F07F4", domain: switch}} + s_raid: !include {file: common/nspanel_terminal/switch_tile.yaml, vars: {page: page_bedroom, id: s_raid, name: "Raid", entity: switch.mcu_socket_02_relay, icon: "\U000F0C6E", domain: switch}} + s_socket_3: !include {file: common/nspanel_terminal/switch_tile.yaml, vars: {page: page_bedroom, id: s_socket_3, name: "", entity: switch.mcu_socket_03_relay, icon: "\U000F1108", domain: switch}} + l_bedroom: !include {file: common/nspanel_terminal/light_tile.yaml, vars: {page: page_bedroom, id: l_bedroom, name: "Svetlo", entity: light.mcu_nspanel_bedroom_light, icon: "\U000F091D", dim: false, kmin: 0, hs: false}} + l_lamp_right: !include {file: common/nspanel_terminal/light_tile.yaml, vars: {page: page_bedroom, id: l_lamp_right, name: "Nočná lampa J", entity: light.mcu_bedroom_lamp_right_light, icon: "\U000F06B5", dim: true, kmin: 1701, hs: true}} + l_lamp_left: !include {file: common/nspanel_terminal/light_tile.yaml, vars: {page: page_bedroom, id: l_lamp_left, name: "Nočná lampa R", entity: light.mcu_bedroom_lamp_left_light, icon: "\U000F06B5", dim: true, kmin: 1701, hs: true}} + # Kúrenie + thermo: !include {file: common/nspanel_terminal/thermostat.yaml, vars: {id: thermo, page: page_thermostat, title: "Kúrenie - Spálňa", prev: page_bedroom, next: page_status, entity: climate.bt_trv_bedroom}} -nspanel_lovelace: - cards: - - type: cardGrid - title: Spálňa - entities: - - name: TV - entity_id: switch.mcu_socket_01_relay - icon: television-classic - - name: Raid - entity_id: switch.mcu_socket_02_relay - icon: emoticon-dead - - name: "" - entity_id: switch.mcu_socket_03_relay - icon: power-socket-fr - - name: Svetlo - entity_id: light.mcu_nspanel_bedroom_light - icon: wall-sconce-flat - - name: Nočná lampa J - entity_id: light.mcu_bedroom_lamp_right_light - icon: lamp - - name: Nočná lampa R - entity_id: light.mcu_bedroom_lamp_left_light - icon: lamp - - - type: cardThermo - title: Kúrenie - thermo_entity_id: climate.bt_trv_bedroom - - - type: cardEntities - title: Info - entities: - - name: Zariadenie - entity_id: button.bedroom_nspanel_info - icon: information-outline +# the grid pages; home, status and light detail come from panel.yaml, thermostat pages from thermostat.yaml +lvgl: + pages: + - <<: !include {file: common/nspanel_terminal/grid_page.yaml, vars: {id: page_bedroom, title: "Spálňa", prev: page_home, next: page_thermostat, skip: false}} binary_sensor: + # both buttons show the Spálňa page, where the change is visible - platform: gpio name: Left Button pin: @@ -81,7 +67,8 @@ binary_sensor: inverted: true on_click: - light.toggle: light_1 - - lambda: 'id(nspanel_id).render_default_page();' + - lvgl.page.show: page_bedroom + - script.execute: wake_screen - platform: gpio name: Right Button @@ -95,7 +82,8 @@ binary_sensor: action: light.toggle data: entity_id: light.bedroom_lamps - - lambda: 'id(nspanel_id).render_default_page();' + - lvgl.page.show: page_bedroom + - script.execute: wake_screen light: - platform: binary diff --git a/mcu-nspanel-dev.yaml b/mcu-nspanel-dev.yaml index 80da065..d4c8750 100644 --- a/mcu-nspanel-dev.yaml +++ b/mcu-nspanel-dev.yaml @@ -19,7 +19,7 @@ substitutions: area: DEV comment: NSPanel (nspanel-terminal) brightness: "80" - # backlight after 30 s idle, tune to taste + # backlight after 15 s idle, tune to taste dim_brightness: "20" esphome: @@ -27,1262 +27,72 @@ esphome: friendly_name: ${name} area: ${area} comment: ${comment} - includes: - - common/nspanel_terminal/weather.h - - common/nspanel_terminal/ha.h - - common/nspanel_terminal/light.h - - common/nspanel_terminal/thermostat.h - on_boot: - - priority: -100 - then: - - lvgl.page.show: page_7 - -esp32: - variant: esp32 - toolchain: esp-idf - framework: - type: esp-idf - advanced: - flash_chip: generic - minimum_chip_revision: 3.0 - sram1_as_iram: true - sdkconfig_options: - # NSPanel PSRAM on non-default pins - CONFIG_D0WD_PSRAM_CLK_IO: "5" - CONFIG_D0WD_PSRAM_CS_IO: "18" - -psram: - mode: quad - speed: 40MHz - ignore_not_found: false - -external_components: - # fork with the fixes of ptaru/nspanel-terminal#1 (TFT upload, faster redraws); upstream once merged - - source: github://randybb/nspanel-terminal@upload-and-redraw-fixes - components: [nspanel_terminal] packages: common: !include common/common.yaml ipv6_only: !include common/ipv6_only.yaml + panel: !include + file: common/nspanel_terminal/panel.yaml + vars: + temperature_entity: sensor.zigbee_office_r_temperature + first_page: page_kitchen + last_page: page_gate sleep_dim: !include file: common/nspanel_terminal/sleep_dim.yaml vars: sleep_override_entity: light.mcu_nspanel_office_r_light # Grid page tiles: each package adds its tile to the page and fills it in this order - # page_1 Kuchyňa / Obývačka - l_kitchen: !include {file: common/nspanel_terminal/light_tile.yaml, vars: {page: page_1, id: l_kitchen, name: "Kuchyňa", entity: light.kitchen, icon: "\U000F0769", dim: true, kmin: 2700, hs: false}} - l_dining: !include {file: common/nspanel_terminal/light_tile.yaml, vars: {page: page_1, id: l_dining, name: "Stôl", entity: light.dining_table, icon: "\U000F1793", dim: true, kmin: 2700, hs: false}} - l_living: !include {file: common/nspanel_terminal/light_tile.yaml, vars: {page: page_1, id: l_living, name: "Gauč", entity: light.living_room, icon: "\U000F04B9", dim: true, kmin: 2700, hs: false}} - l_tv: !include {file: common/nspanel_terminal/light_tile.yaml, vars: {page: page_1, id: l_tv, name: "TV", entity: light.mcu_tv_light_light, icon: "\U000F0502", dim: false, kmin: 0, hs: false}} - l_dining_amb: !include {file: common/nspanel_terminal/light_tile.yaml, vars: {page: page_1, id: l_dining_amb, name: "(Stôl)", entity: light.dining_table_ambilight, icon: "\U000F1051", dim: true, kmin: 1700, hs: true}} - l_living_amb: !include {file: common/nspanel_terminal/light_tile.yaml, vars: {page: page_1, id: l_living_amb, name: "(Gauč)", entity: light.living_room_ambilight, icon: "\U000F1051", dim: true, kmin: 1700, hs: true}} - # page_2 Romanko - l_office: !include {file: common/nspanel_terminal/light_tile.yaml, vars: {page: page_2, id: l_office, name: "Svetlo", entity: light.mcu_nspanel_office_r_light, icon: "\U000F0769", dim: false, kmin: 0, hs: false}} - l_strip: !include {file: common/nspanel_terminal/light_tile.yaml, vars: {page: page_2, id: l_strip, name: "LED pásik", entity: light.office_r_desk_strip, icon: "\U000F1051", dim: true, kmin: 1700, hs: true}} - office_spacer: !include {file: common/nspanel_terminal/spacer_tile.yaml, vars: {page: page_2}} - l_monitor: !include {file: common/nspanel_terminal/light_tile.yaml, vars: {page: page_2, id: l_monitor, name: "Monitor", entity: light.office_r_display_lamp, icon: "\U000F0379", dim: true, kmin: 2700, hs: false}} - l_monitor_amb: !include {file: common/nspanel_terminal/light_tile.yaml, vars: {page: page_2, id: l_monitor_amb, name: "(Monitor)", entity: light.office_r_display_lamp_ambilight, icon: "\U000F1051", dim: true, kmin: 1700, hs: true}} - # page_3 Von (card_outside of the patio panel) - l_patio: !include {file: common/nspanel_terminal/light_tile.yaml, vars: {page: page_3, id: l_patio, name: "Terasa", entity: light.patio_lights, icon: "\U000F1253", dim: true, kmin: 2000, hs: false}} - s_patio_socket: !include {file: common/nspanel_terminal/switch_tile.yaml, vars: {page: page_3, id: s_patio_socket, name: "Terasa", entity: switch.mcu_patio_relay, icon: "\U000F1108", domain: switch}} - s_patio_back: !include {file: common/nspanel_terminal/switch_tile.yaml, vars: {page: page_3, id: s_patio_back, name: "Vzadu", entity: switch.mcu_nspanel_patio_outside_light_back, icon: "\U000F1987", domain: switch}} - s_shed_light: !include {file: common/nspanel_terminal/switch_tile.yaml, vars: {page: page_3, id: s_shed_light, name: "Z. domček", entity: switch.mcu_shed_light, icon: "\U000F091D", domain: switch}} - s_shed_socket: !include {file: common/nspanel_terminal/switch_tile.yaml, vars: {page: page_3, id: s_shed_socket, name: "Z. domček", entity: switch.mcu_shed_socket, icon: "\U000F1108", domain: switch}} - s_garden: !include {file: common/nspanel_terminal/switch_tile.yaml, vars: {page: page_3, id: s_garden, name: "Záhrada", entity: switch.mcu_shed_garden_light, icon: "\U000F1987", domain: switch}} - # page_4 Závlaha, robot -> page_irrigation_auto - v_a1: !include {file: common/nspanel_terminal/switch_tile.yaml, vars: {page: page_4, id: v_a1, name: "A1", entity: switch.mcu_well_irrigation_valve_a1, icon: "\U000F1066", domain: switch}} - v_a2: !include {file: common/nspanel_terminal/switch_tile.yaml, vars: {page: page_4, id: v_a2, name: "A2", entity: switch.mcu_well_irrigation_valve_a2, icon: "\U000F1066", domain: switch}} - v_a3: !include {file: common/nspanel_terminal/switch_tile.yaml, vars: {page: page_4, id: v_a3, name: "A3", entity: switch.mcu_well_irrigation_valve_a3, icon: "\U000F1066", domain: switch}} - v_a4: !include {file: common/nspanel_terminal/switch_tile.yaml, vars: {page: page_4, id: v_a4, name: "A4", entity: switch.mcu_well_irrigation_valve_a4, icon: "\U000F1066", domain: switch}} - v_a5: !include {file: common/nspanel_terminal/switch_tile.yaml, vars: {page: page_4, id: v_a5, name: "A5", entity: switch.mcu_well_irrigation_valve_a5, icon: "\U000F1066", domain: switch}} - irrigation_auto: !include {file: common/nspanel_terminal/nav_tile.yaml, vars: {page: page_4, to: page_irrigation_auto, icon: "\U000F06A9"}} + # Kuchyňa / Obývačka + l_kitchen: !include {file: common/nspanel_terminal/light_tile.yaml, vars: {page: page_kitchen, id: l_kitchen, name: "Kuchyňa", entity: light.kitchen, icon: "\U000F0769", dim: true, kmin: 2700, hs: false}} + l_dining: !include {file: common/nspanel_terminal/light_tile.yaml, vars: {page: page_kitchen, id: l_dining, name: "Stôl", entity: light.dining_table, icon: "\U000F1793", dim: true, kmin: 2700, hs: false}} + l_living: !include {file: common/nspanel_terminal/light_tile.yaml, vars: {page: page_kitchen, id: l_living, name: "Gauč", entity: light.living_room, icon: "\U000F04B9", dim: true, kmin: 2700, hs: false}} + l_tv: !include {file: common/nspanel_terminal/light_tile.yaml, vars: {page: page_kitchen, id: l_tv, name: "TV", entity: light.mcu_tv_light_light, icon: "\U000F0502", dim: false, kmin: 0, hs: false}} + l_dining_amb: !include {file: common/nspanel_terminal/light_tile.yaml, vars: {page: page_kitchen, id: l_dining_amb, name: "(Stôl)", entity: light.dining_table_ambilight, icon: "\U000F1051", dim: true, kmin: 1700, hs: true}} + l_living_amb: !include {file: common/nspanel_terminal/light_tile.yaml, vars: {page: page_kitchen, id: l_living_amb, name: "(Gauč)", entity: light.living_room_ambilight, icon: "\U000F1051", dim: true, kmin: 1700, hs: true}} + # Romanko + l_office: !include {file: common/nspanel_terminal/light_tile.yaml, vars: {page: page_office, id: l_office, name: "Svetlo", entity: light.mcu_nspanel_office_r_light, icon: "\U000F0769", dim: false, kmin: 0, hs: false}} + l_strip: !include {file: common/nspanel_terminal/light_tile.yaml, vars: {page: page_office, id: l_strip, name: "LED pásik", entity: light.office_r_desk_strip, icon: "\U000F1051", dim: true, kmin: 1700, hs: true}} + office_spacer: !include {file: common/nspanel_terminal/spacer_tile.yaml, vars: {page: page_office}} + l_monitor: !include {file: common/nspanel_terminal/light_tile.yaml, vars: {page: page_office, id: l_monitor, name: "Monitor", entity: light.office_r_display_lamp, icon: "\U000F0379", dim: true, kmin: 2700, hs: false}} + l_monitor_amb: !include {file: common/nspanel_terminal/light_tile.yaml, vars: {page: page_office, id: l_monitor_amb, name: "(Monitor)", entity: light.office_r_display_lamp_ambilight, icon: "\U000F1051", dim: true, kmin: 1700, hs: true}} + # Von (card_outside of the patio panel) + l_patio: !include {file: common/nspanel_terminal/light_tile.yaml, vars: {page: page_outside, id: l_patio, name: "Terasa", entity: light.patio_lights, icon: "\U000F1253", dim: true, kmin: 2000, hs: false}} + s_patio_socket: !include {file: common/nspanel_terminal/switch_tile.yaml, vars: {page: page_outside, id: s_patio_socket, name: "Terasa", entity: switch.mcu_patio_relay, icon: "\U000F1108", domain: switch}} + s_patio_back: !include {file: common/nspanel_terminal/switch_tile.yaml, vars: {page: page_outside, id: s_patio_back, name: "Vzadu", entity: switch.mcu_nspanel_patio_outside_light_back, icon: "\U000F1987", domain: switch}} + s_shed_light: !include {file: common/nspanel_terminal/switch_tile.yaml, vars: {page: page_outside, id: s_shed_light, name: "Z. domček", entity: switch.mcu_shed_light, icon: "\U000F091D", domain: switch}} + s_shed_socket: !include {file: common/nspanel_terminal/switch_tile.yaml, vars: {page: page_outside, id: s_shed_socket, name: "Z. domček", entity: switch.mcu_shed_socket, icon: "\U000F1108", domain: switch}} + s_garden: !include {file: common/nspanel_terminal/switch_tile.yaml, vars: {page: page_outside, id: s_garden, name: "Záhrada", entity: switch.mcu_shed_garden_light, icon: "\U000F1987", domain: switch}} + # Závlaha, robot -> page_irrigation_auto + v_a1: !include {file: common/nspanel_terminal/switch_tile.yaml, vars: {page: page_irrigation, id: v_a1, name: "A1", entity: switch.mcu_well_irrigation_valve_a1, icon: "\U000F1066", domain: switch}} + v_a2: !include {file: common/nspanel_terminal/switch_tile.yaml, vars: {page: page_irrigation, id: v_a2, name: "A2", entity: switch.mcu_well_irrigation_valve_a2, icon: "\U000F1066", domain: switch}} + v_a3: !include {file: common/nspanel_terminal/switch_tile.yaml, vars: {page: page_irrigation, id: v_a3, name: "A3", entity: switch.mcu_well_irrigation_valve_a3, icon: "\U000F1066", domain: switch}} + v_a4: !include {file: common/nspanel_terminal/switch_tile.yaml, vars: {page: page_irrigation, id: v_a4, name: "A4", entity: switch.mcu_well_irrigation_valve_a4, icon: "\U000F1066", domain: switch}} + v_a5: !include {file: common/nspanel_terminal/switch_tile.yaml, vars: {page: page_irrigation, id: v_a5, name: "A5", entity: switch.mcu_well_irrigation_valve_a5, icon: "\U000F1066", domain: switch}} + irrigation_auto: !include {file: common/nspanel_terminal/nav_tile.yaml, vars: {page: page_irrigation, to: page_irrigation_auto, icon: "\U000F06A9"}} ir_morning: !include {file: common/nspanel_terminal/switch_tile.yaml, vars: {page: page_irrigation_auto, id: ir_morning, name: "Ráno", entity: automation.irrigation_morning, icon: "\U000F059C", domain: automation}} ir_patio: !include {file: common/nspanel_terminal/switch_tile.yaml, vars: {page: page_irrigation_auto, id: ir_patio, name: "Terasa", entity: automation.irrigation_patio, icon: "\U000F024A", domain: automation}} ir_grass: !include {file: common/nspanel_terminal/switch_tile.yaml, vars: {page: page_irrigation_auto, id: ir_grass, name: "Rast trávy", entity: automation.irrigation_grow_grass, icon: "\U000F1510", domain: automation}} - # page_6 Brána, robot -> page_gate_auto - gate_open: !include {file: common/nspanel_terminal/action_tile.yaml, vars: {page: page_6, id: gate_open, name: "Otvoriť", icon: "\U000F116A", action: button.press, entity: button.mcu_gate_open}} - gate_close: !include {file: common/nspanel_terminal/action_tile.yaml, vars: {page: page_6, id: gate_close, name: "Zatvoriť", icon: "\U000F0299", action: button.press, entity: button.mcu_gate_close}} - gate_spacer: !include {file: common/nspanel_terminal/spacer_tile.yaml, vars: {page: page_6}} - gate: !include {file: common/nspanel_terminal/gate.yaml, vars: {page: page_6, state: select.mcu_gate_state}} - gate_auto: !include {file: common/nspanel_terminal/nav_tile.yaml, vars: {page: page_6, to: page_gate_auto, icon: "\U000F06A9"}} + # Brána, robot -> page_gate_auto + gate_open: !include {file: common/nspanel_terminal/action_tile.yaml, vars: {page: page_gate, id: gate_open, name: "Otvoriť", icon: "\U000F116A", action: button.press, entity: button.mcu_gate_open}} + gate_close: !include {file: common/nspanel_terminal/action_tile.yaml, vars: {page: page_gate, id: gate_close, name: "Zatvoriť", icon: "\U000F0299", action: button.press, entity: button.mcu_gate_close}} + gate_spacer: !include {file: common/nspanel_terminal/spacer_tile.yaml, vars: {page: page_gate}} + gate: !include {file: common/nspanel_terminal/gate.yaml, vars: {page: page_gate, state: select.mcu_gate_state}} + gate_auto: !include {file: common/nspanel_terminal/nav_tile.yaml, vars: {page: page_gate, to: page_gate_auto, icon: "\U000F06A9"}} gate_auto_open: !include {file: common/nspanel_terminal/switch_tile.yaml, vars: {page: page_gate_auto, id: gate_auto_open, name: "Auto-otváranie", entity: switch.mcu_gate_auto_open, icon: "\U000F1169", domain: switch}} gate_auto_close: !include {file: common/nspanel_terminal/switch_tile.yaml, vars: {page: page_gate_auto, id: gate_auto_close, name: "Auto-zatváranie", entity: switch.mcu_gate_auto_close, icon: "\U000F17F7", domain: switch}} - # page_5 Kúrenie - thermostat: !include {file: common/nspanel_terminal/thermostat.yaml, vars: {entity: climate.bt_trv_office_r, boiler: switch.heating_enabled}} - -wifi: - power_save_mode: none - -# Flashing shows on the status page. The OTA blocks the main loop, so each step renders the screen itself -ota: - - id: !extend ota_esphome - on_begin: - - lvgl.page.show: page_7 - - lambda: |- - lv_obj_set_hidden(id(status_ota), false); - lv_obj_set_style_text_color(id(status_ota), lv_color_hex(0xFFB300), LV_PART_MAIN); - lv_label_set_text(id(status_ota), "Flashovanie: začína..."); - lv_refr_now(nullptr); - on_progress: - - lambda: |- - lv_label_set_text_fmt(id(status_ota), "Flashovanie: %.0f %%", x); - lv_refr_now(nullptr); - on_end: - - lambda: |- - lv_obj_set_style_text_color(id(status_ota), lv_color_hex(0x4DD966), LV_PART_MAIN); - lv_label_set_text(id(status_ota), "Flashovanie: hotovo, reštartujem"); - lv_refr_now(nullptr); - on_error: - - lambda: |- - lv_obj_set_style_text_color(id(status_ota), lv_color_hex(0xFF453A), LV_PART_MAIN); - lv_label_set_text_fmt(id(status_ota), "Flashovanie: chyba %u", x); - lv_refr_now(nullptr); - -api: - # status page until Home Assistant connects (log viewers don't subscribe to states) - on_client_connected: - - delay: 2s - - if: - condition: - api.connected: - state_subscription_only: true - then: - - lvgl.page.show: page_0 - on_client_disconnected: - - if: - condition: - not: - api.connected: - state_subscription_only: true - then: - - lvgl.page.show: page_7 - actions: - # same signatures as on the lovelace panels, so the HA automations keep working - - action: notify - variables: - heading: string - message: string - song: string - then: - - script.execute: - id: notify_show - heading: !lambda return heading; - message: !lambda return message; - timeout_ms: 10000 - - if: - condition: - lambda: return !song.empty(); - then: - - rtttl.play: - rtttl: !lambda 'return song;' - # buttons and icon were never implemented on the lovelace panels either - - action: notify_fullscreen - variables: - title: string - description: string - button1: string - button2: string - timeout: int - icon: string - then: - - script.execute: - id: notify_show - heading: !lambda return title; - message: !lambda return description; - timeout_ms: !lambda return timeout; - - rtttl.play: "scale_up:d=32,o=5,b=100:c,c#,d#,e,f#,g#,a#,b" - - action: show_info - then: - - script.execute: info_popup - # https://github.com/granadaxronos/120-SONG_NOKIA_RTTTL_RINGTONE_PLAYER_FOR_ARDUINO_UNO/blob/master/RTTTL_PLAYER/songs.h - - action: play_rtttl - variables: - song: string - then: - - rtttl.play: - rtttl: !lambda 'return song;' - - - action: set_brightness - variables: - percent: int - then: - - lambda: 'id(panel).request_brightness(percent);' - # url empty = tft_url from secrets (terminal), rollback: http://ha.local/local/tft/lui.tft - - action: upload_tft - variables: - url: string - then: - - lambda: |- - if (!url.empty()) id(panel).set_tft_url(url); - id(panel).request_tft_upload(); - -uart: - id: display_uart - tx_pin: 16 - rx_pin: 17 - baud_rate: 115200 - rx_buffer_size: 4096 - -display: - - platform: nspanel_terminal - id: panel - uart_id: display_uart - width: 454 - height: 320 - update_interval: never - auto_clear_enabled: false - tft_url: !secret tft_url_terminal - brightness: ${brightness} - -touchscreen: - - platform: nspanel_terminal - id: panel_touch - display: panel - panel_id: panel - calibration: - x_min: 0 - x_max: 453 - y_min: 0 - y_max: 319 - on_touch: - - if: - condition: - lambda: return id(dimmed); - then: - - globals.set: - id: dimmed - value: "false" - - lambda: 'id(panel).request_brightness(${brightness});' - -globals: - - id: dimmed - type: bool - initial_value: "false" - # light shown on page_light and the index of the page to return to - - id: cur_light - type: std::string - - id: back_page - type: size_t - # preset_modes of the thermostat, in dropdown order - - id: preset_list - type: std::vector - -font: - - file: "gfonts://Inter@500" - id: font_clock - size: 112 - bpp: 4 - glyphs: "0123456789:" - - file: "gfonts://Inter@500" - id: font_big - size: 44 - bpp: 4 - glyphs: "0123456789.,-" - - file: "gfonts://Inter" - id: font_m - size: 22 - bpp: 4 - glyphsets: [GF_Latin_Core] - - file: "gfonts://Inter" - id: font_s - size: 17 - bpp: 4 - glyphsets: [GF_Latin_Core] - - - file: - type: web - url: https://github.com/Templarian/MaterialDesign-Webfont/raw/v7.4.47/fonts/materialdesignicons-webfont.ttf - id: icon_s - size: 30 - bpp: 4 - glyphs: - - "\U000F0594" - - "\U000F0599" - - "\U000F0595" - - "\U000F0590" - - "\U000F0591" - - "\U000F0597" - - "\U000F0596" - - "\U000F0598" - - "\U000F067F" - - "\U000F0592" - - "\U000F0593" - - "\U000F067E" - - "\U000F059D" - - "\U000F059E" - - "\U000F05D6" - - "\U000F0141" - - "\U000F0142" - - "\U000F0374" - - "\U000F0415" - - "\U000F0438" - - "\U000F0238" - - "\U000F0140" - - "\U000F1066" - - "\U000F059C" - - "\U000F024A" - - "\U000F1510" - - "\U000F1253" - - "\U000F1108" - - "\U000F1987" - - "\U000F091D" - - "\U000F0299" - - "\U000F116A" - - "\U000F1169" - - "\U000F17F7" - - "\U000F17F8" - - "\U000F06A9" - - "\U000F00DF" - - "\U000F05A8" - - "\U000F03D8" - - "\U000F0425" - - "\U000F0379" - - "\U000F04B9" - - "\U000F0502" - - "\U000F0769" - - "\U000F1051" - - "\U000F1793" - - file: - type: web - url: https://github.com/Templarian/MaterialDesign-Webfont/raw/v7.4.47/fonts/materialdesignicons-webfont.ttf - id: icon_l - size: 52 - bpp: 4 - glyphs: - - "\U000F0594" - - "\U000F0599" - - "\U000F0595" - - "\U000F0590" - - "\U000F0591" - - "\U000F0597" - - "\U000F0596" - - "\U000F0598" - - "\U000F067F" - - "\U000F0592" - - "\U000F0593" - - "\U000F067E" - - "\U000F059D" - - "\U000F059E" - - "\U000F05D6" - - "\U000F0299" - - "\U000F116A" - - "\U000F1169" - - "\U000F17F7" - - "\U000F17F8" - - "\U000F06A9" - -script: - # counts as activity: wakes the dimmed screen and restarts the idle timeout back to the home page - - id: wake_screen - then: - - lambda: |- - lv_display_trigger_activity(nullptr); - if (id(dimmed)) { - id(dimmed) = false; - id(panel).request_brightness(${brightness}); - } - # like the info popup of the other panels: device info is on the status page - # notification over every page (top layer); closes on tap or after the timeout - - id: notify_show - mode: restart - parameters: - heading: string - message: string - timeout_ms: int - then: - - lambda: |- - lv_label_set_text(id(notify_heading), heading.c_str()); - lv_label_set_text(id(notify_message), message.c_str()); - lv_obj_set_hidden(id(notify_popup), false); - - script.execute: wake_screen - - delay: !lambda 'return timeout_ms > 0 ? timeout_ms : 10000;' - - lvgl.widget.hide: notify_popup - - id: info_popup - then: - - lvgl.page.show: page_7 - - script.execute: wake_screen - # same as the status screens of the other LVGL devices (mcu-lvgl.yaml) - - id: update_status - then: - - lambda: |- - // ok green, waiting orange, details gray - static const uint32_t OK = 0x4DD966, WAIT = 0xFFB300; - auto set = [](lv_obj_t *label, const std::string &text, uint32_t color) { - lv_label_set_text(label, text.c_str()); - lv_obj_set_style_text_color(label, lv_color_hex(color), LV_PART_MAIN); - }; - - auto *wifi = wifi::global_wifi_component; - const bool wifi_ok = wifi->is_connected(); - // diagnostics for slow connects after a cold start: seconds to connect, AP association - static uint32_t connected_s = 0; - if (wifi_ok && !connected_s) - connected_s = std::max(1, millis() / 1000); - if (wifi_ok) { - set(id(status_wifi), str_sprintf("WiFi: pripojené za %u s (%d dBm)", connected_s, wifi->wifi_rssi()), OK); - } else { - auto bssid = wifi->wifi_bssid(); - bool associated = std::any_of(bssid.begin(), bssid.end(), [](uint8_t b) { return b != 0; }); - set(id(status_wifi), - str_sprintf("WiFi: pripájam... %s, %us", associated ? "AP ok, čakám na IP" : "bez AP", millis() / 1000), - WAIT); - } - - // IPv6 first (skip link-local), then IPv4 - std::string ips; - char buf[network::IP_ADDRESS_BUFFER_SIZE]; - for (bool v6 : {true, false}) { - for (auto &ip : wifi->get_ip_addresses()) { - if (!ip.is_set() || ip.is_ip6() != v6) - continue; - ip.str_to(buf); - if (v6 && strncmp(buf, "fe80", 4) == 0) - continue; - if (!ips.empty()) - ips += "\n"; - ips += buf; - } - } - lv_label_set_text(id(status_ips), ips.c_str()); - lv_obj_set_hidden(id(status_ips), ips.empty()); - - const bool api_ok = api::global_api_server->is_connected(true); - set(id(status_ha), api_ok ? "Home Assistant: pripojený" : "Home Assistant: čakám...", api_ok ? OK : WAIT); - - const uint32_t up = millis() / 1000; - static char build[Application::BUILD_TIME_STR_SIZE] = ""; - if (!build[0]) - App.get_build_time_string(build); - lv_label_set_text(id(status_footer), - str_sprintf("ESPHome %s · beží %ud %02u:%02u:%02u\n%s", ESPHOME_VERSION, up / 86400, - (up / 3600) % 24, (up / 60) % 60, up % 60, build).c_str()); - - id: open_light - parameters: - entity: string - name: string - dim: bool - kmin: int - hs: bool - is_on: bool - bri: float - ct: float - hue: string - then: - - lambda: |- - id(cur_light) = entity; - id(back_page) = id(lvgl_main)->get_current_page(); - lv_label_set_text(id(detail_title), name.c_str()); - lv_obj_set_state(id(detail_power), LV_STATE_CHECKED, is_on); - lv_obj_set_hidden(id(detail_bri_row), !dim); - // colour lights get hue only: brightness plus either colour temperature or hue - lv_obj_set_hidden(id(detail_ct_row), !kmin || hs); - lv_obj_set_hidden(id(detail_hue_row), !hs); - lv_slider_set_value(id(detail_bri), brightness_pct(bri), LV_ANIM_OFF); - if (kmin) { - lv_slider_set_range(id(detail_ct), kmin, 6500); - lv_slider_set_value(id(detail_ct), std::isnan(ct) ? kmin : ct, LV_ANIM_OFF); - } - lv_slider_set_value(id(detail_hue), std::max(0, parse_hue(hue)), LV_ANIM_OFF); - - lvgl.page.show: page_light - - id: update_forecast - then: - - lambda: |- - static const char *const DAYS[] = {"ne", "po", "ut", "st", "št", "pi", "so"}; - lv_obj_t *const DAY[] = {id(forecast_day_0), id(forecast_day_1), id(forecast_day_2)}; - lv_obj_t *const ICON[] = {id(forecast_icon_0), id(forecast_icon_1), id(forecast_icon_2)}; - lv_obj_t *const HIGH[] = {id(today_high), id(forecast_high_0), id(forecast_high_1), id(forecast_high_2)}; - lv_obj_t *const LOW[] = {id(today_low), id(forecast_low_0), id(forecast_low_1), id(forecast_low_2)}; - auto now = id(ha_time).now(); - ForecastDay days[4]; - // index 0 is today - int n = now.is_valid() ? parse_forecast(id(forecast).state, 0, days, 4) : 0; - for (int i = 0; i < 4; i++) { - if (i < n) { - lv_label_set_text_fmt(HIGH[i], "%.1f°C", days[i].high); - lv_label_set_text_fmt(LOW[i], "%.1f°C", days[i].low); - } else { - lv_label_set_text(HIGH[i], ""); - lv_label_set_text(LOW[i], ""); - } - if (i == 0) continue; - lv_label_set_text(DAY[i - 1], i < n ? DAYS[(now.day_of_week + i - 1) % 7] : ""); - lv_label_set_text(ICON[i - 1], i < n ? weather_icon(days[i].condition) : ""); - } - - id: update_clock - then: - - lambda: |- - static const char *const DAYS[] = {"nedeľa", "pondelok", "utorok", "streda", "štvrtok", "piatok", "sobota"}; - static const char *const MONTHS[] = {"januára", "februára", "marca", "apríla", "mája", "júna", - "júla", "augusta", "septembra", "októbra", "novembra", "decembra"}; - auto now = id(ha_time).now(); - if (!now.is_valid()) return; - lv_label_set_text(id(clock_label), now.strftime("%H:%M").c_str()); - lv_label_set_text_fmt(id(date_label), "%s, %u. %s", DAYS[now.day_of_week - 1], now.day_of_month, - MONTHS[now.month - 1]); - -time: - - id: !extend ha_time - on_time_sync: - - script.execute: update_clock - - script.execute: update_forecast - on_time: - - seconds: 0 - then: - - script.execute: update_clock - -image: - - platform: file - file: assets/images/made-for-esphome-white-on-black.svg - id: esphome_logo - resize: 300x88 - type: RGB565 - transparency: alpha_channel - -interval: - - interval: 1s - then: - - if: - condition: - lvgl.page.is_showing: page_7 - then: - - script.execute: update_status + # Kúrenie + thermostat: !include {file: common/nspanel_terminal/thermostat.yaml, vars: {id: thermo, page: page_thermostat, title: "Kúrenie - Romanko", prev: page_irrigation, next: page_gate, entity: climate.bt_trv_office_r}} +# the grid pages; home, status and light detail come from panel.yaml, the thermostat page from thermostat.yaml lvgl: - id: lvgl_main - displays: panel - # 1/8 screen draw buffer in internal RAM; a full-screen PSRAM buffer renders much slower - buffer_size: 12.5% - touchscreens: - - touchscreen_id: panel_touch - color_depth: 16 - bg_color: 0x000000 - text_color: 0xFFFFFF - text_font: font_m - gradients: - - id: ct_grad - direction: HOR - stops: - - {color: 0xFF9A3C, position: 0%} - - {color: 0xFFE4C4, position: 50%} - - {color: 0xCFDCFF, position: 100%} - - id: hue_grad - direction: HOR - stops: - - {color: 0xFF0000, position: 0%} - - {color: 0xFFFF00, position: 17%} - - {color: 0x00FF00, position: 33%} - - {color: 0x00FFFF, position: 50%} - - {color: 0x0000FF, position: 67%} - - {color: 0xFF00FF, position: 83%} - - {color: 0xFF0000, position: 100%} - style_definitions: - - id: tile_style - bg_color: 0x1C1C1E - bg_opa: COVER - radius: 14 - border_width: 0 - shadow_width: 0 - pad_all: 14 - text_color: 0xFFFFFF - text_font: font_m - - id: page_style - bg_color: 0x000000 - bg_opa: COVER - text_font: font_m - text_color: 0xFFFFFF - border_width: 0 - pad_all: 16 - pad_row: 12 - pad_column: 12 - on_idle: - timeout: 30s - then: - # without Home Assistant the status page stays - - if: - condition: - api.connected: - state_subscription_only: true - then: - - lvgl.page.show: page_0 - - globals.set: - id: dimmed - value: "true" - - lambda: 'id(panel).request_brightness(id(idle_brightness));' - top_layer: - widgets: - - obj: - id: notify_popup - hidden: true - width: 100% - height: 100% - bg_color: 0x000000 - bg_opa: 70% - border_width: 0 - radius: 0 - pad_all: 24 - on_click: - - script.stop: notify_show - - lvgl.widget.hide: notify_popup - widgets: - - obj: - clickable: false - width: 100% - height: 100% - styles: tile_style - pad_all: 20 - layout: - type: FLEX - flex_flow: COLUMN - pad_row: 12 - widgets: - - label: - id: notify_heading - text: "" - text_color: 0xF5B342 - width: 100% - long_mode: WRAP - - label: - id: notify_message - text: "" - width: 100% - long_mode: WRAP - # Pages, not a tileview: a tile switch made LVGL render the whole screen three times. No animation, - # every frame of one would be a full-screen redraw over UART (~290 kB). pages: - - id: page_0 - styles: page_style - on_click: - - lvgl.page.show: page_1 - widgets: - - label: - id: clock_label - text: "--:--" - text_font: font_clock - align: TOP_LEFT - x: 4 - y: -10 - - label: - id: date_label - text: "" - text_color: 0xB4B4BA - align: TOP_LEFT - x: 10 - y: 118 - - label: - id: nameday_label - text: "" - text_font: font_s - text_color: 0x8E8E93 - align: TOP_LEFT - x: 10 - y: 148 - - obj: - clickable: false - align: TOP_RIGHT - width: SIZE_CONTENT - height: SIZE_CONTENT - bg_opa: TRANSP - border_width: 0 - pad_all: 0 - layout: - type: FLEX - flex_flow: COLUMN - pad_row: 10 - widgets: - - <<: !include {file: common/nspanel_terminal/forecast_day.yaml, vars: {i: 0}} - - <<: !include {file: common/nspanel_terminal/forecast_day.yaml, vars: {i: 1}} - - <<: !include {file: common/nspanel_terminal/forecast_day.yaml, vars: {i: 2}} - - obj: - clickable: false - align: BOTTOM_LEFT - x: 8 - y: -22 - width: SIZE_CONTENT - height: SIZE_CONTENT - bg_opa: TRANSP - border_width: 0 - pad_all: 0 - text_color: 0xFFFFFF - layout: - type: FLEX - pad_column: 2 - flex_flow: ROW - flex_align_cross: START - widgets: - - label: - id: in_temp_label - text: "-" - text_font: font_big - text_color: 0xFFFFFF - - label: - text: "°C" - y: 6 - text_color: 0xB4B4BA - - label: - text: "dnu" - text_font: font_s - text_color: 0x8E8E93 - align: BOTTOM_LEFT - x: 10 - - obj: - clickable: false - align: BOTTOM_LEFT - x: 158 - y: -22 - width: SIZE_CONTENT - height: SIZE_CONTENT - bg_opa: TRANSP - border_width: 0 - pad_all: 0 - text_color: 0xFFFFFF - layout: - type: FLEX - pad_column: 2 - flex_flow: ROW - flex_align_cross: START - widgets: - - label: - id: out_temp_label - text: "-" - text_font: font_big - text_color: 0xFFFFFF - - label: - text: "°C" - y: 6 - text_color: 0xB4B4BA - - label: - text: "von" - text_font: font_s - text_color: 0x8E8E93 - align: BOTTOM_LEFT - x: 160 - - obj: - clickable: false - align: BOTTOM_RIGHT - # same bottom offset as the temperatures; the boxes are equally tall, so the centres line up - y: -22 - width: SIZE_CONTENT - height: SIZE_CONTENT - bg_opa: TRANSP - border_width: 0 - pad_all: 0 - layout: - type: FLEX - flex_flow: ROW - flex_align_cross: CENTER - pad_column: 10 - widgets: - - label: - id: weather_icon_label - text: "" - text_font: icon_l - text_color: 0xFFFFFF - - obj: - clickable: false - width: SIZE_CONTENT - height: SIZE_CONTENT - bg_opa: TRANSP - border_width: 0 - pad_all: 0 - layout: - type: FLEX - flex_flow: COLUMN - pad_row: 0 - widgets: - - label: - id: today_high - text: "" - text_color: 0xFFFFFF - - label: - id: today_low - text: "" - text_color: 0x8E8E93 - - <<: !include {file: common/nspanel_terminal/grid_page.yaml, vars: {id: page_1, title: "Kuchyňa / Obývačka", prev: page_0, next: page_2, skip: false}} - - <<: !include {file: common/nspanel_terminal/grid_page.yaml, vars: {id: page_2, title: "Romanko", prev: page_1, next: page_3, skip: false}} - - <<: !include {file: common/nspanel_terminal/grid_page.yaml, vars: {id: page_3, title: "Von", prev: page_2, next: page_4, skip: false}} - - <<: !include {file: common/nspanel_terminal/grid_page.yaml, vars: {id: page_4, title: "Závlaha", prev: page_3, next: page_5, skip: false}} - - <<: !include {file: common/nspanel_terminal/grid_page.yaml, vars: {id: page_irrigation_auto, title: "Automatizácia závlahy", prev: page_4, next: page_4, skip: true}} - # Thermostat, Office R (Better Thermostat); state and actions in common/nspanel_terminal/thermostat.yaml - - id: page_5 - styles: page_style - widgets: - - label: - text: "Kúrenie Romanko" - text_font: font_s - text_color: 0xB4B4BA - width: 100% - text_align: CENTER - - <<: !include - file: common/nspanel_terminal/page_arrow.yaml - vars: {icon: "\U000F0141", align: TOP_LEFT, x: -16, to: page_4, hidden: false} - - <<: !include - file: common/nspanel_terminal/page_arrow.yaml - vars: {icon: "\U000F0142", align: TOP_RIGHT, x: 16, to: page_6, hidden: false} - # target temperature in half degrees, 10..30 °C - - arc: - id: thermo_arc - disabled: - arc_color: 0x161618 - align: BOTTOM_LEFT - y: -20 - width: 220 - height: 220 - min_value: 20 - max_value: 60 - arc_width: 16 - arc_color: 0x2C2C2E - indicator: - arc_width: 16 - arc_color: 0x8E8E93 - knob: - bg_color: 0xFFFFFF - pad_all: 2 - on_value: - - lambda: 'lv_label_set_text_fmt(id(thermo_target_label), "%.1f", x / 2.0f);' - on_release: - - script.execute: thermo_send_target - widgets: - - obj: - clickable: false - align: CENTER - y: -8 - width: SIZE_CONTENT - height: SIZE_CONTENT - bg_opa: TRANSP - border_width: 0 - pad_all: 0 - text_color: 0xFFFFFF - layout: - type: FLEX - flex_flow: ROW - flex_align_cross: START - pad_column: 2 - widgets: - - label: - id: thermo_target_label - text: "-" - text_font: font_big - text_color: 0xFFFFFF - - label: - text: "°C" - y: 6 - text_color: 0xB4B4BA - - label: - id: thermo_current_label - text: "" - text_font: font_s - text_color: 0xB4B4BA - align: CENTER - y: 34 - - label: - id: thermo_action_label - text: "" - text_font: font_s - text_color: 0x8E8E93 - align: CENTER - y: -50 - - button: - id: thermo_minus - align: BOTTOM_LEFT - x: 46 - width: 56 - height: 44 - styles: tile_style - disabled: - bg_color: 0x161618 - text_color: 0x48484A - pad_all: 0 - on_click: - - lambda: |- - lv_arc_set_value(id(thermo_arc), lv_arc_get_value(id(thermo_arc)) - 1); - lv_label_set_text_fmt(id(thermo_target_label), "%.1f", lv_arc_get_value(id(thermo_arc)) / 2.0f); - - script.execute: thermo_send_target - widgets: - - label: - text: "\U000F0374" - text_font: icon_s - align: CENTER - - button: - id: thermo_plus - align: BOTTOM_LEFT - x: 118 - width: 56 - height: 44 - styles: tile_style - disabled: - bg_color: 0x161618 - text_color: 0x48484A - pad_all: 0 - on_click: - - lambda: |- - lv_arc_set_value(id(thermo_arc), lv_arc_get_value(id(thermo_arc)) + 1); - lv_label_set_text_fmt(id(thermo_target_label), "%.1f", lv_arc_get_value(id(thermo_arc)) / 2.0f); - - script.execute: thermo_send_target - widgets: - - label: - text: "\U000F0415" - text_font: icon_s - align: CENTER - - button: - id: thermo_power - align: TOP_RIGHT - x: -90 - y: 36 - width: 82 - height: 44 - styles: tile_style - disabled: - bg_color: 0x161618 - text_color: 0x48484A - pad_all: 0 - checked: - bg_color: 0xF5B342 - text_color: 0x000000 - on_click: - - homeassistant.action: - action: climate.set_hvac_mode - data: - entity_id: climate.bt_trv_office_r - hvac_mode: !lambda 'return id(thermo_mode).state == "heat" ? "off" : "heat";' - widgets: - - label: - text: "\U000F0438" - text_font: icon_s - align: LEFT_MID - x: 6 - - label: - text: "Izba" - text_font: font_s - align: RIGHT_MID - x: -8 - # the boiler only fires with this switch on - - button: - id: heating_enabled_button - align: TOP_RIGHT - x: 0 - y: 36 - width: 82 - height: 44 - styles: tile_style - disabled: - bg_color: 0x161618 - text_color: 0x48484A - pad_all: 0 - checked: - bg_color: 0xF5B342 - text_color: 0x000000 - on_click: - - homeassistant.action: - action: switch.toggle - data: - entity_id: switch.heating_enabled - widgets: - - label: - text: "\U000F0238" - text_font: icon_s - align: LEFT_MID - x: 6 - - label: - text: "Kotol" - text_font: font_s - align: RIGHT_MID - x: -8 - # options come from the preset_modes attribute (thermostat.yaml) - - dropdown: - id: thermo_preset_dropdown - disabled: - text_color: 0x48484A - align: TOP_RIGHT - y: 92 - width: 172 - options: ["-"] - styles: tile_style - pad_all: 10 - symbol: "\U000F0140" - indicator: - text_font: icon_s - dropdown_list: - bg_color: 0x2C2C2E - text_color: 0xFFFFFF - text_font: font_m - border_width: 0 - radius: 14 - selected: - checked: - bg_color: 0xF5B342 - text_color: 0x000000 - on_value: - - homeassistant.action: - action: climate.set_preset_mode - data: - entity_id: climate.bt_trv_office_r - preset_mode: !lambda 'return x < id(preset_list).size() ? id(preset_list)[x] : std::string();' - - <<: !include {file: common/nspanel_terminal/grid_page.yaml, vars: {id: page_6, title: "Brána", prev: page_5, next: page_7, skip: false}} - - <<: !include {file: common/nspanel_terminal/grid_page.yaml, vars: {id: page_gate_auto, title: "Automatizácia brány", prev: page_6, next: page_6, skip: true}} - # Status: boot screen until Home Assistant connects, then the last (diagnostic) page - - id: page_7 - styles: page_style - on_load: - - script.execute: update_status - widgets: - - <<: !include - file: common/nspanel_terminal/page_arrow.yaml - vars: {icon: "\U000F0141", align: TOP_LEFT, x: -16, to: page_6, hidden: false} - - image: - src: esphome_logo - align: TOP_MID - - label: - align: TOP_MID - y: 96 - text: !lambda return App.get_name(); - - obj: - clickable: false - align: TOP_LEFT - x: 8 - y: 136 - width: 100% - height: SIZE_CONTENT - bg_opa: TRANSP - border_width: 0 - pad_all: 0 - layout: - type: FLEX - flex_flow: COLUMN - pad_row: 6 - widgets: - - label: - id: status_wifi - text_font: font_s - text: "" - - label: - id: status_ips - text_font: font_s - text_color: 0x8E8E93 - pad_left: 20 - text: "" - - label: - id: status_ha - text_font: font_s - text: "" - # shown only while flashing (ota: above) - - label: - id: status_ota - text_font: font_s - text: "" - hidden: true - - label: - id: status_footer - text_font: font_s - text_color: 0x8E8E93 - text: "" - # Light detail, opened by a long press on a light button (script open_light) - - id: page_light - styles: page_style - layout: - type: FLEX - flex_flow: COLUMN - pad_row: 26 - widgets: - - obj: - clickable: false - width: 100% - height: 44 - bg_opa: TRANSP - border_width: 0 - pad_all: 0 - widgets: - - obj: - align: LEFT_MID - x: -16 - width: 72 - height: 52 - bg_opa: TRANSP - border_width: 0 - pad_all: 0 - on_click: - - lambda: 'id(lvgl_main)->show_page(id(back_page), LV_SCREEN_LOAD_ANIM_NONE, 0);' - widgets: - - label: - text: "\U000F0141" - text_font: icon_s - text_color: 0xB4B4BA - align: CENTER - - label: - id: detail_title - text: "" - align: CENTER - - button: - id: detail_power - align: RIGHT_MID - width: 64 - height: 44 - styles: tile_style - pad_all: 0 - checked: - bg_color: 0xF5B342 - text_color: 0x000000 - on_click: - - homeassistant.action: - action: light.toggle - data: - entity_id: !lambda return id(cur_light); - widgets: - - label: - text: "\U000F0425" - text_font: icon_s - align: CENTER - - obj: - id: detail_bri_row - clickable: false - width: 100% - height: SIZE_CONTENT - bg_opa: TRANSP - border_width: 0 - pad_all: 0 - layout: - type: FLEX - flex_flow: ROW - flex_align_cross: CENTER - pad_column: 14 - widgets: - - label: - text: "\U000F00DF" - text_font: icon_s - text_color: 0xB4B4BA - - slider: - id: detail_bri - flex_grow: 1 - height: 44 - min_value: 1 - max_value: 100 - radius: 22 - bg_color: 0x2C2C2E - indicator: - bg_color: 0xF5B342 - radius: 22 - knob: - bg_color: 0xFFFFFF - pad_all: 2 - on_release: - - homeassistant.action: - action: light.turn_on - data: - entity_id: !lambda return id(cur_light); - brightness_pct: !lambda return (int) x; - - obj: - id: detail_ct_row - clickable: false - width: 100% - height: SIZE_CONTENT - bg_opa: TRANSP - border_width: 0 - pad_all: 0 - layout: - type: FLEX - flex_flow: ROW - flex_align_cross: CENTER - pad_column: 14 - widgets: - - label: - text: "\U000F05A8" - text_font: icon_s - text_color: 0xB4B4BA - - slider: - id: detail_ct - flex_grow: 1 - height: 44 - min_value: 1700 - max_value: 6500 - radius: 22 - bg_grad: ct_grad - bg_opa: COVER - indicator: - bg_opa: TRANSP - radius: 22 - knob: - bg_color: 0xFFFFFF - pad_all: 2 - on_release: - - homeassistant.action: - action: light.turn_on - data: - entity_id: !lambda return id(cur_light); - color_temp_kelvin: !lambda return (int) x; - - obj: - id: detail_hue_row - clickable: false - width: 100% - height: SIZE_CONTENT - bg_opa: TRANSP - border_width: 0 - pad_all: 0 - layout: - type: FLEX - flex_flow: ROW - flex_align_cross: CENTER - pad_column: 14 - widgets: - - label: - text: "\U000F03D8" - text_font: icon_s - text_color: 0xB4B4BA - - slider: - id: detail_hue - flex_grow: 1 - height: 44 - min_value: 0 - max_value: 360 - radius: 22 - bg_grad: hue_grad - bg_opa: COVER - indicator: - bg_opa: TRANSP - radius: 22 - knob: - bg_color: 0xFFFFFF - pad_all: 2 - on_release: - - homeassistant.action: - action: light.turn_on - data: - entity_id: !lambda return id(cur_light); - data_template: - hs_color: "{{ [hue | int, 100] }}" - variables: - hue: !lambda return (int) x; - -text_sensor: - - platform: homeassistant - id: forecast - entity_id: sensor.weather_forecast_daily - attribute: forecast - internal: true - on_value: - - script.execute: update_forecast - - platform: homeassistant - id: nameday - entity_id: sensor.nameday_sk - internal: true - on_value: - - lvgl.label.update: - id: nameday_label - text: !lambda return x; - - platform: homeassistant - id: weather - entity_id: weather.outside - internal: true - on_value: - - lambda: |- - lv_label_set_text(id(weather_icon_label), weather_icon(x)); - -button: - # as on the other panels: put button._info on a dashboard, HA presses it - - platform: template - name: Info - id: info_button - entity_category: diagnostic - on_press: - - script.execute: info_popup + - <<: !include {file: common/nspanel_terminal/grid_page.yaml, vars: {id: page_kitchen, title: "Kuchyňa / Obývačka", prev: page_home, next: page_office, skip: false}} + - <<: !include {file: common/nspanel_terminal/grid_page.yaml, vars: {id: page_office, title: "Romanko", prev: page_kitchen, next: page_outside, skip: false}} + - <<: !include {file: common/nspanel_terminal/grid_page.yaml, vars: {id: page_outside, title: "Von", prev: page_office, next: page_irrigation, skip: false}} + - <<: !include {file: common/nspanel_terminal/grid_page.yaml, vars: {id: page_irrigation, title: "Závlaha", prev: page_outside, next: page_thermostat, skip: false}} + - <<: !include {file: common/nspanel_terminal/grid_page.yaml, vars: {id: page_irrigation_auto, title: "Automatizácia závlahy", prev: page_irrigation, next: page_irrigation, skip: true}} + - <<: !include {file: common/nspanel_terminal/grid_page.yaml, vars: {id: page_gate, title: "Brána", prev: page_thermostat, next: page_status, skip: false}} + - <<: !include {file: common/nspanel_terminal/grid_page.yaml, vars: {id: page_gate_auto, title: "Automatizácia brány", prev: page_gate, next: page_gate, skip: true}} binary_sensor: - platform: gpio @@ -1296,7 +106,7 @@ binary_sensor: action: light.toggle data: entity_id: light.mcu_nspanel_office_r_light - - lvgl.page.show: page_2 + - lvgl.page.show: page_office - script.execute: wake_screen - platform: gpio @@ -1311,12 +121,6 @@ binary_sensor: # data: # entity_id: switch.gate_close -output: - - platform: ledc - id: buzzer_out - pin: - number: 21 - switch: - platform: gpio name: Relay 1 @@ -1329,66 +133,3 @@ switch: id: relay_2 pin: number: 19 - - # Turn screen power on/off. Easy way to configure the screen power control, but this should not be used from HA, as all components must be re-initialized afterwards. For lights, names of lights etc. this practically means that the state must change once to happen. - - platform: gpio - name: Screen Power - id: screen_power - entity_category: config - pin: - number: 4 - inverted: true - restore_mode: ALWAYS_ON - -rtttl: - id: buzzer - output: buzzer_out - -sensor: - - platform: adc - id: ntc_source - pin: 38 - update_interval: 5min - attenuation: 12db - - - platform: resistance - id: resistance_sensor - sensor: ntc_source - configuration: DOWNSTREAM - resistor: 11.2kOhm - - - platform: ntc - id: temperature - name: Temperature - sensor: resistance_sensor - calibration: - b_constant: 3950 - reference_temperature: 25°C - reference_resistance: 10kOhm - - - platform: homeassistant - id: inside_temperature - entity_id: sensor.zigbee_office_r_temperature - internal: true - on_value: - - lvgl.label.update: - id: in_temp_label - text: !lambda 'return std::isnan(x) ? std::string("--") : str_sprintf("%.1f", x);' - - - platform: homeassistant - id: outside_temperature - entity_id: sensor.zigbee_outside_temperature - internal: true - on_value: - - lvgl.label.update: - id: out_temp_label - text: !lambda 'return std::isnan(x) ? std::string("--") : str_sprintf("%.1f", x);' - - - platform: template - id: room_temperature_id - -# esp32_ble_tracker: -# scan_parameters: -# duration: 1min - -# bluetooth_proxy: diff --git a/mcu-nspanel-fireplace.yaml b/mcu-nspanel-fireplace.yaml index 79deaac..5a70f6c 100644 --- a/mcu-nspanel-fireplace.yaml +++ b/mcu-nspanel-fireplace.yaml @@ -17,7 +17,10 @@ substitutions: device: nspanel-fireplace name: Fireplace NSPanel area: Living Room & Kitchen - comment: NSPanel + comment: NSPanel (nspanel-terminal) + brightness: "80" + # backlight after 15 s idle + dim_brightness: "20" esphome: name: mcu-${device} @@ -28,109 +31,54 @@ esphome: packages: common: !include common/common.yaml ipv6_only: !include common/ipv6_only.yaml - nspanel: !include - file: common/nspanel.yaml + panel: !include + file: common/nspanel_terminal/panel.yaml vars: temperature_entity: sensor.zigbee_living_room_kitchen_temperature temperature_name: Living Room Temperature + first_page: page_kitchen_living + last_page: page_thermostat_room + # Grid page tiles: each package adds its tile to the page and fills it in this order + # Kuchyňa / Obývačka + l_kitchen: !include {file: common/nspanel_terminal/light_tile.yaml, vars: {page: page_kitchen_living, id: l_kitchen, name: "Kuchyňa", entity: light.kitchen, icon: "\U000F0769", dim: true, kmin: 2700, hs: false}} + l_dining: !include {file: common/nspanel_terminal/light_tile.yaml, vars: {page: page_kitchen_living, id: l_dining, name: "Stôl", entity: light.dining_table, icon: "\U000F0769", dim: true, kmin: 2700, hs: false}} + l_living: !include {file: common/nspanel_terminal/light_tile.yaml, vars: {page: page_kitchen_living, id: l_living, name: "Gauč", entity: light.living_room, icon: "\U000F0769", dim: true, kmin: 2700, hs: false}} + l_tv: !include {file: common/nspanel_terminal/light_tile.yaml, vars: {page: page_kitchen_living, id: l_tv, name: "TV", entity: light.mcu_tv_light_strip, icon: "\U000F1051", dim: true, kmin: 0, hs: false}} + l_dining_amb: !include {file: common/nspanel_terminal/light_tile.yaml, vars: {page: page_kitchen_living, id: l_dining_amb, name: "(Stôl)", entity: light.dining_table_ambilight, icon: "\U000F18DE", dim: true, kmin: 1700, hs: true}} + l_living_amb: !include {file: common/nspanel_terminal/light_tile.yaml, vars: {page: page_kitchen_living, id: l_living_amb, name: "(Gauč)", entity: light.living_room_ambilight, icon: "\U000F18DE", dim: true, kmin: 1700, hs: true}} + # Kuchyňa + l_worktop: !include {file: common/nspanel_terminal/light_tile.yaml, vars: {page: page_kitchen, id: l_worktop, name: "Linka", entity: light.worktop_lights, icon: "\U000F181C", dim: true, kmin: 2000, hs: false}} + l_stove: !include {file: common/nspanel_terminal/light_tile.yaml, vars: {page: page_kitchen, id: l_stove, name: "Sporák", entity: light.mcu_kitchen_stove, icon: "\U000F04DE", dim: true, kmin: 2000, hs: false}} + # Von + l_patio: !include {file: common/nspanel_terminal/light_tile.yaml, vars: {page: page_outside, id: l_patio, name: "Terasa", entity: light.patio_lights, icon: "\U000F1253", dim: true, kmin: 2000, hs: false}} + s_patio_socket: !include {file: common/nspanel_terminal/switch_tile.yaml, vars: {page: page_outside, id: s_patio_socket, name: "Terasa", entity: switch.mcu_patio_relay, icon: "\U000F1108", domain: switch}} + s_patio_back: !include {file: common/nspanel_terminal/switch_tile.yaml, vars: {page: page_outside, id: s_patio_back, name: "Vzadu", entity: switch.mcu_nspanel_patio_outside_light_back, icon: "\U000F1987", domain: switch}} + s_shed_light: !include {file: common/nspanel_terminal/switch_tile.yaml, vars: {page: page_outside, id: s_shed_light, name: "Z. domček", entity: switch.mcu_shed_light, icon: "\U000F091D", domain: switch}} + s_shed_socket: !include {file: common/nspanel_terminal/switch_tile.yaml, vars: {page: page_outside, id: s_shed_socket, name: "Z. domček", entity: switch.mcu_shed_socket, icon: "\U000F1108", domain: switch}} + s_garden: !include {file: common/nspanel_terminal/switch_tile.yaml, vars: {page: page_outside, id: s_garden, name: "Záhrada", entity: switch.mcu_shed_garden_light, icon: "\U000F1987", domain: switch}} + # Brána, robot -> page_gate_auto + gate_open: !include {file: common/nspanel_terminal/action_tile.yaml, vars: {page: page_gate, id: gate_open, name: "Otvoriť", icon: "\U000F116A", action: button.press, entity: button.mcu_gate_open}} + gate_close: !include {file: common/nspanel_terminal/action_tile.yaml, vars: {page: page_gate, id: gate_close, name: "Zatvoriť", icon: "\U000F0299", action: button.press, entity: button.mcu_gate_close}} + gate_spacer: !include {file: common/nspanel_terminal/spacer_tile.yaml, vars: {page: page_gate}} + gate: !include {file: common/nspanel_terminal/gate.yaml, vars: {page: page_gate, state: select.mcu_gate_state}} + gate_auto: !include {file: common/nspanel_terminal/nav_tile.yaml, vars: {page: page_gate, to: page_gate_auto, icon: "\U000F06A9"}} + gate_auto_open: !include {file: common/nspanel_terminal/switch_tile.yaml, vars: {page: page_gate_auto, id: gate_auto_open, name: "Auto-otváranie", entity: switch.mcu_gate_auto_open, icon: "\U000F1169", domain: switch}} + gate_auto_close: !include {file: common/nspanel_terminal/switch_tile.yaml, vars: {page: page_gate_auto, id: gate_auto_close, name: "Auto-zatváranie", entity: switch.mcu_gate_auto_close, icon: "\U000F17F7", domain: switch}} + # Kúrenie + thermo: !include {file: common/nspanel_terminal/thermostat.yaml, vars: {id: thermo, page: page_thermostat, title: "Kúrenie - Obývačka", prev: page_gate, next: page_thermostat_room, entity: climate.bt_trv_living_room_kitchen}} + thermo_room: !include {file: common/nspanel_terminal/thermostat.yaml, vars: {id: thermo_room, page: page_thermostat_room, title: "Kúrenie - Izba", prev: page_thermostat, next: page_status, entity: climate.bt_trv_room}} -nspanel_lovelace: - cards: - - type: cardGrid - title: Kuchyňa / Obývačka - entities: - - name: Kuchyňa / Obývačka - entity_id: light.kitchen - icon: ceiling-light - - name: Stôl - entity_id: light.dining_table - icon: ceiling-light - - name: Gauč - entity_id: light.living_room - icon: ceiling-light - - name: TV - entity_id: light.mcu_tv_light_strip - icon: led-strip-variant - - name: (Stôl) - entity_id: light.dining_table_ambilight - icon: ceiling-light-multiple-outline - - name: (Gauč) - entity_id: light.living_room_ambilight - icon: ceiling-light-multiple-outline - - - type: cardGrid - title: Kuchyňa - entities: - - name: Linka - entity_id: light.worktop_lights - icon: countertop - - name: Sporák - entity_id: light.mcu_kitchen_stove - icon: stove - - - type: cardGrid - title: Von - entities: - - name: Terasa - entity_id: light.patio_lights - icon: lightbulb-group - - name: Terasa - entity_id: switch.mcu_patio_relay - icon: power-socket-fr - - name: Vzadu - entity_id: switch.mcu_nspanel_patio_outside_light_back - icon: light-flood-down - - name: Z. domček - entity_id: switch.mcu_shed_light - icon: wall-sconce-flat - # state_template: '{{ is_state("binary_sensor.shed_status", "off") }}' - - name: Z. domček - entity_id: switch.mcu_shed_socket - icon: power-socket-fr - # state_template: '{{ is_state("binary_sensor.shed_status", "off") }}' - - name: Záhrada - entity_id: switch.mcu_shed_garden_light - icon: light-flood-down - # state_template: '{{ is_state("binary_sensor.shed_status", "off") }}' - - - type: cardGrid - title: Brána - entities: - - name: Otvoriť - entity_id: button.mcu_gate_open - icon: gate-open - - name: Zatvoriť - entity_id: button.mcu_gate_close - icon: gate - - name: Automatizácia - entity_id: navigate.card_gate_automation - - - type: cardThermo - title: Kúrenie - thermo_entity_id: climate.bt_trv_living_room_kitchen - - - type: cardThermo - title: Kúrenie - Izba - thermo_entity_id: climate.bt_trv_room - - - type: cardEntities - title: Automatizácia - id: card_gate_automation - hidden: true - entities: - - name: Auto-otváranie - entity_id: switch.gate_auto_open - - name: Auto-zatváranie - entity_id: switch.gate_auto_close - - - type: cardEntities - title: Info - entities: - - name: Zariadenie - entity_id: button.fireplace_nspanel_info - icon: information-outline +# the grid pages; home, status and light detail come from panel.yaml, thermostat pages from thermostat.yaml +lvgl: + pages: + - <<: !include {file: common/nspanel_terminal/grid_page.yaml, vars: {id: page_kitchen_living, title: "Kuchyňa / Obývačka", prev: page_home, next: page_kitchen, skip: false}} + - <<: !include {file: common/nspanel_terminal/grid_page.yaml, vars: {id: page_kitchen, title: "Kuchyňa", prev: page_kitchen_living, next: page_outside, skip: false}} + - <<: !include {file: common/nspanel_terminal/grid_page.yaml, vars: {id: page_outside, title: "Von", prev: page_kitchen, next: page_gate, skip: false}} + - <<: !include {file: common/nspanel_terminal/grid_page.yaml, vars: {id: page_gate, title: "Brána", prev: page_outside, next: page_thermostat, skip: false}} + - <<: !include {file: common/nspanel_terminal/grid_page.yaml, vars: {id: page_gate_auto, title: "Automatizácia brány", prev: page_gate, next: page_gate, skip: true}} binary_sensor: + # short click: living room / dining table (Kuchyňa / Obývačka page), long click: worktop / stove (Kuchyňa page) - platform: gpio name: Left Button pin: @@ -145,7 +93,8 @@ binary_sensor: action: light.toggle data: entity_id: light.living_room - - lambda: 'id(nspanel_id).render_default_page();' + - lvgl.page.show: page_kitchen_living + - script.execute: wake_screen - min_length: 500ms max_length: 2000ms then: @@ -153,8 +102,8 @@ binary_sensor: action: light.toggle data: entity_id: light.worktop_lights - - lambda: 'id(nspanel_id).render_default_page();' - - lambda: 'id(nspanel_id).render_next_page();' + - lvgl.page.show: page_kitchen + - script.execute: wake_screen - platform: gpio name: Right Button @@ -170,7 +119,8 @@ binary_sensor: action: light.toggle data: entity_id: light.dining_table - - lambda: 'id(nspanel_id).render_default_page();' + - lvgl.page.show: page_kitchen_living + - script.execute: wake_screen - min_length: 500ms max_length: 2000ms then: @@ -178,8 +128,8 @@ binary_sensor: action: light.toggle data: entity_id: light.mcu_kitchen_stove - - lambda: 'id(nspanel_id).render_default_page();' - - lambda: 'id(nspanel_id).render_next_page();' + - lvgl.page.show: page_kitchen + - script.execute: wake_screen switch: - platform: gpio diff --git a/mcu-nspanel-office-j.yaml b/mcu-nspanel-office-j.yaml index 827b2b1..f47ffda 100644 --- a/mcu-nspanel-office-j.yaml +++ b/mcu-nspanel-office-j.yaml @@ -17,7 +17,10 @@ substitutions: device: nspanel-office-j name: Office J NSPanel area: Office J - comment: NSPanel + comment: NSPanel (nspanel-terminal) + brightness: "80" + # backlight after 15 s idle + dim_brightness: "20" esphome: name: mcu-${device} @@ -28,62 +31,41 @@ esphome: packages: common: !include common/common.yaml ipv6_only: !include common/ipv6_only.yaml - nspanel: !include - file: common/nspanel.yaml + panel: !include + file: common/nspanel_terminal/panel.yaml vars: temperature_entity: sensor.zigbee_office_j_temperature ntc_reference_temperature: 22°C + first_page: page_office + last_page: page_thermostat sleep_dim: !include - file: common/nspanel_sleep_dim.yaml + file: common/nspanel_terminal/sleep_dim.yaml vars: sleep_override_entity: light.office_j_lights + # Grid page tiles: each package adds its tile to the page and fills it in this order + # Janko + l_office: !include {file: common/nspanel_terminal/light_tile.yaml, vars: {page: page_office, id: l_office, name: "Svetlo", entity: light.mcu_nspanel_office_j_light, icon: "\U000F091D", dim: false, kmin: 0, hs: false}} + l_bedside: !include {file: common/nspanel_terminal/light_tile.yaml, vars: {page: page_office, id: l_bedside, name: "Nočná lampa", entity: light.bedside_left, icon: "\U000F06B5", dim: true, kmin: 1700, hs: true}} + # Brána, robot -> page_gate_auto + gate_open: !include {file: common/nspanel_terminal/action_tile.yaml, vars: {page: page_gate, id: gate_open, name: "Otvoriť", icon: "\U000F116A", action: button.press, entity: button.mcu_gate_open}} + gate_close: !include {file: common/nspanel_terminal/action_tile.yaml, vars: {page: page_gate, id: gate_close, name: "Zatvoriť", icon: "\U000F0299", action: button.press, entity: button.mcu_gate_close}} + gate_spacer: !include {file: common/nspanel_terminal/spacer_tile.yaml, vars: {page: page_gate}} + gate: !include {file: common/nspanel_terminal/gate.yaml, vars: {page: page_gate, state: select.mcu_gate_state}} + gate_auto: !include {file: common/nspanel_terminal/nav_tile.yaml, vars: {page: page_gate, to: page_gate_auto, icon: "\U000F06A9"}} + gate_auto_open: !include {file: common/nspanel_terminal/switch_tile.yaml, vars: {page: page_gate_auto, id: gate_auto_open, name: "Auto-otváranie", entity: switch.mcu_gate_auto_open, icon: "\U000F1169", domain: switch}} + gate_auto_close: !include {file: common/nspanel_terminal/switch_tile.yaml, vars: {page: page_gate_auto, id: gate_auto_close, name: "Auto-zatváranie", entity: switch.mcu_gate_auto_close, icon: "\U000F17F7", domain: switch}} + # Kúrenie + thermo: !include {file: common/nspanel_terminal/thermostat.yaml, vars: {id: thermo, page: page_thermostat, title: "Kúrenie - Janko", prev: page_gate, next: page_status, entity: climate.bt_trv_office_j}} -nspanel_lovelace: - cards: - - type: cardGrid - title: Janko - entities: - - name: Svetlo - entity_id: light.mcu_nspanel_office_j_light - icon: wall-sconce-flat - - name: Nočná lampa - entity_id: light.bedside_left - icon: lamp - - - type: cardGrid - title: Brána - entities: - - name: Otvoriť - entity_id: button.mcu_gate_open - icon: gate-open - - name: Zatvoriť - entity_id: button.mcu_gate_close - icon: gate - - name: Automatizácia - entity_id: navigate.card_gate_automation - - - type: cardThermo - title: Kúrenie - thermo_entity_id: climate.bt_trv_office_j - - - type: cardEntities - title: Automatizácia - id: card_gate_automation - hidden: true - entities: - - name: Auto-otváranie - entity_id: switch.gate_auto_open - - name: Auto-zatváranie - entity_id: switch.gate_auto_close - - - type: cardEntities - title: Info - entities: - - name: Zariadenie - entity_id: button.office_j_nspanel_info - icon: information-outline +# the grid pages; home, status and light detail come from panel.yaml, thermostat pages from thermostat.yaml +lvgl: + pages: + - <<: !include {file: common/nspanel_terminal/grid_page.yaml, vars: {id: page_office, title: "Janko", prev: page_home, next: page_gate, skip: false}} + - <<: !include {file: common/nspanel_terminal/grid_page.yaml, vars: {id: page_gate, title: "Brána", prev: page_office, next: page_thermostat, skip: false}} + - <<: !include {file: common/nspanel_terminal/grid_page.yaml, vars: {id: page_gate_auto, title: "Automatizácia brány", prev: page_gate, next: page_gate, skip: true}} binary_sensor: + # both buttons show the Janko page, where the change is visible - platform: gpio name: Left Button pin: @@ -91,7 +73,8 @@ binary_sensor: inverted: true on_click: - light.toggle: light_1 - - lambda: 'id(nspanel_id).render_default_page();' + - lvgl.page.show: page_office + - script.execute: wake_screen - platform: gpio name: Right Button @@ -103,7 +86,8 @@ binary_sensor: action: light.toggle data: entity_id: light.bedside_left - - lambda: 'id(nspanel_id).render_default_page();' + - lvgl.page.show: page_office + - script.execute: wake_screen output: - id: relay_1 @@ -121,6 +105,3 @@ light: id: light_1 output: relay_1 restore_mode: RESTORE_DEFAULT_OFF -# # - platform: binary -# # name: Relay 2 -# # output: relay_2 diff --git a/mcu-nspanel-office-r.yaml b/mcu-nspanel-office-r.yaml index 63fe32b..0a4b8b9 100644 --- a/mcu-nspanel-office-r.yaml +++ b/mcu-nspanel-office-r.yaml @@ -17,7 +17,10 @@ substitutions: device: nspanel-office-r name: Office R NSPanel area: Office R - comment: NSPanel + comment: NSPanel (nspanel-terminal) + brightness: "80" + # backlight after 15 s idle + dim_brightness: "20" esphome: name: mcu-${device} @@ -28,11 +31,37 @@ esphome: packages: common: !include common/common.yaml ipv6_only: !include common/ipv6_only.yaml - nspanel: !include - file: common/nspanel.yaml + panel: !include + file: common/nspanel_terminal/panel.yaml vars: temperature_entity: sensor.zigbee_office_r_temperature ntc_reference_temperature: 22°C + first_page: page_office + last_page: page_thermostat + # Grid page tiles: each package adds its tile to the page and fills it in this order + # Romanko + l_office: !include {file: common/nspanel_terminal/light_tile.yaml, vars: {page: page_office, id: l_office, name: "Svetlo", entity: light.mcu_nspanel_office_r_light, icon: "\U000F0769", dim: false, kmin: 0, hs: false}} + l_strip: !include {file: common/nspanel_terminal/light_tile.yaml, vars: {page: page_office, id: l_strip, name: "LED pásik", entity: light.office_r_desk_strip, icon: "\U000F1051", dim: true, kmin: 1700, hs: true}} + office_spacer: !include {file: common/nspanel_terminal/spacer_tile.yaml, vars: {page: page_office}} + l_monitor: !include {file: common/nspanel_terminal/light_tile.yaml, vars: {page: page_office, id: l_monitor, name: "Monitor", entity: light.office_r_display_lamp, icon: "\U000F0379", dim: true, kmin: 2700, hs: false}} + l_monitor_amb: !include {file: common/nspanel_terminal/light_tile.yaml, vars: {page: page_office, id: l_monitor_amb, name: "(Monitor)", entity: light.office_r_display_lamp_ambilight, icon: "\U000F1051", dim: true, kmin: 1700, hs: true}} + # Brána, robot -> page_gate_auto + gate_open: !include {file: common/nspanel_terminal/action_tile.yaml, vars: {page: page_gate, id: gate_open, name: "Otvoriť", icon: "\U000F116A", action: button.press, entity: button.mcu_gate_open}} + gate_close: !include {file: common/nspanel_terminal/action_tile.yaml, vars: {page: page_gate, id: gate_close, name: "Zatvoriť", icon: "\U000F0299", action: button.press, entity: button.mcu_gate_close}} + gate_spacer: !include {file: common/nspanel_terminal/spacer_tile.yaml, vars: {page: page_gate}} + gate: !include {file: common/nspanel_terminal/gate.yaml, vars: {page: page_gate, state: select.mcu_gate_state}} + gate_auto: !include {file: common/nspanel_terminal/nav_tile.yaml, vars: {page: page_gate, to: page_gate_auto, icon: "\U000F06A9"}} + gate_auto_open: !include {file: common/nspanel_terminal/switch_tile.yaml, vars: {page: page_gate_auto, id: gate_auto_open, name: "Auto-otváranie", entity: switch.mcu_gate_auto_open, icon: "\U000F1169", domain: switch}} + gate_auto_close: !include {file: common/nspanel_terminal/switch_tile.yaml, vars: {page: page_gate_auto, id: gate_auto_close, name: "Auto-zatváranie", entity: switch.mcu_gate_auto_close, icon: "\U000F17F7", domain: switch}} + # Kúrenie + thermostat: !include {file: common/nspanel_terminal/thermostat.yaml, vars: {id: thermo, page: page_thermostat, title: "Kúrenie - Romanko", prev: page_gate, next: page_status, entity: climate.bt_trv_office_r}} + +# the grid pages; home, status and light detail come from panel.yaml, the thermostat page from thermostat.yaml +lvgl: + pages: + - <<: !include {file: common/nspanel_terminal/grid_page.yaml, vars: {id: page_office, title: "Romanko", prev: page_home, next: page_gate, skip: false}} + - <<: !include {file: common/nspanel_terminal/grid_page.yaml, vars: {id: page_gate, title: "Brána", prev: page_office, next: page_thermostat, skip: false}} + - <<: !include {file: common/nspanel_terminal/grid_page.yaml, vars: {id: page_gate_auto, title: "Automatizácia brány", prev: page_gate, next: page_gate, skip: true}} script: - id: geiger_click @@ -51,59 +80,8 @@ script: return esphome::random_uint32() % 450 + 50; - script.execute: geiger_click -nspanel_lovelace: - cards: - - type: cardGrid - title: Romanko - entities: - - name: Svetlo - entity_id: light.mcu_nspanel_office_r_light - icon: wall-sconce-flat - - name: LED pásik - entity_id: light.office_r_desk_strip - icon: led-strip-variant - - entity_id: delete - - name: Monitor - entity_id: light.office_r_display_lamp - icon: monitor-star - - name: (Monitor) - entity_id: light.office_r_display_lamp_ambilight - icon: monitor-star - - - type: cardGrid - title: Brána - entities: - - name: Otvoriť - entity_id: button.mcu_gate_open - icon: gate-open - - name: Zatvoriť - entity_id: button.mcu_gate_close - icon: gate - - name: Automatizácia - entity_id: navigate.card_gate_automation - - - type: cardThermo - title: Kúrenie - thermo_entity_id: climate.bt_trv_office_r - - - type: cardEntities - title: Automatizácia - id: card_gate_automation - hidden: true - entities: - - name: Auto-otváranie - entity_id: switch.gate_auto_open - - name: Auto-zatváranie - entity_id: switch.gate_auto_close - - - type: cardEntities - title: Info - entities: - - name: Zariadenie - entity_id: button.office_r_nspanel_info - icon: information-outline - binary_sensor: + # both buttons show the Romanko page, where the change is visible - platform: gpio name: Left Button pin: @@ -114,7 +92,8 @@ binary_sensor: action: light.toggle data: entity_id: light.office_r_desk_strip - - lambda: 'id(nspanel_id).render_default_page();' + - lvgl.page.show: page_office + - script.execute: wake_screen - platform: gpio name: Right Button @@ -123,17 +102,14 @@ binary_sensor: inverted: true on_click: - light.toggle: light_1 - - lambda: 'id(nspanel_id).render_default_page();' + - lvgl.page.show: page_office + - script.execute: wake_screen output: - id: relay_1 platform: gpio pin: number: 22 - # - id: relay_2 - # platform: gpio - # pin: - # number: 19 light: - platform: esp32_rmt_led_strip diff --git a/mcu-nspanel-patio.yaml b/mcu-nspanel-patio.yaml index 3a12a94..f47532e 100644 --- a/mcu-nspanel-patio.yaml +++ b/mcu-nspanel-patio.yaml @@ -17,7 +17,10 @@ substitutions: device: nspanel-patio name: Patio NSPanel area: Living Room & Kitchen - comment: ${area}, Patio | NSPanel + comment: ${area}, Patio | NSPanel (nspanel-terminal) + brightness: "80" + # backlight after 15 s idle + dim_brightness: "20" esphome: name: mcu-${device} @@ -28,140 +31,65 @@ esphome: packages: common: !include common/common.yaml ipv6_only: !include common/ipv6_only.yaml - nspanel: !include - file: common/nspanel.yaml + panel: !include + file: common/nspanel_terminal/panel.yaml vars: temperature_entity: sensor.zigbee_living_room_kitchen_temperature temperature_name: Living Room Temperature + first_page: page_kitchen_living + last_page: page_thermostat + # Grid page tiles: each package adds its tile to the page and fills it in this order + # Kuchyňa / Obývačka + l_kitchen: !include {file: common/nspanel_terminal/light_tile.yaml, vars: {page: page_kitchen_living, id: l_kitchen, name: "Kuchyňa", entity: light.kitchen, icon: "\U000F0769", dim: true, kmin: 2700, hs: false}} + l_dining: !include {file: common/nspanel_terminal/light_tile.yaml, vars: {page: page_kitchen_living, id: l_dining, name: "Stôl", entity: light.dining_table, icon: "\U000F0769", dim: true, kmin: 2700, hs: false}} + l_living: !include {file: common/nspanel_terminal/light_tile.yaml, vars: {page: page_kitchen_living, id: l_living, name: "Gauč", entity: light.living_room, icon: "\U000F0769", dim: true, kmin: 2700, hs: false}} + l_tv: !include {file: common/nspanel_terminal/light_tile.yaml, vars: {page: page_kitchen_living, id: l_tv, name: "TV", entity: light.mcu_tv_light_strip, icon: "\U000F1051", dim: true, kmin: 0, hs: false}} + l_dining_amb: !include {file: common/nspanel_terminal/light_tile.yaml, vars: {page: page_kitchen_living, id: l_dining_amb, name: "(Stôl)", entity: light.dining_table_ambilight, icon: "\U000F18DE", dim: true, kmin: 1700, hs: true}} + l_living_amb: !include {file: common/nspanel_terminal/light_tile.yaml, vars: {page: page_kitchen_living, id: l_living_amb, name: "(Gauč)", entity: light.living_room_ambilight, icon: "\U000F18DE", dim: true, kmin: 1700, hs: true}} + # Kuchyňa + l_worktop: !include {file: common/nspanel_terminal/light_tile.yaml, vars: {page: page_kitchen, id: l_worktop, name: "Linka", entity: light.worktop_lights, icon: "\U000F181C", dim: true, kmin: 2000, hs: false}} + l_stove: !include {file: common/nspanel_terminal/light_tile.yaml, vars: {page: page_kitchen, id: l_stove, name: "Sporák", entity: light.mcu_kitchen_stove, icon: "\U000F04DE", dim: true, kmin: 2000, hs: false}} + # Von + l_patio: !include {file: common/nspanel_terminal/light_tile.yaml, vars: {page: page_outside, id: l_patio, name: "Terasa", entity: light.patio_lights, icon: "\U000F1253", dim: true, kmin: 2000, hs: false}} + s_patio_socket: !include {file: common/nspanel_terminal/switch_tile.yaml, vars: {page: page_outside, id: s_patio_socket, name: "Terasa", entity: switch.mcu_patio_relay, icon: "\U000F1108", domain: switch}} + s_patio_back: !include {file: common/nspanel_terminal/switch_tile.yaml, vars: {page: page_outside, id: s_patio_back, name: "Vzadu", entity: switch.mcu_nspanel_patio_outside_light_back, icon: "\U000F1987", domain: switch}} + s_shed_light: !include {file: common/nspanel_terminal/switch_tile.yaml, vars: {page: page_outside, id: s_shed_light, name: "Z. domček", entity: switch.mcu_shed_light, icon: "\U000F091D", domain: switch}} + s_shed_socket: !include {file: common/nspanel_terminal/switch_tile.yaml, vars: {page: page_outside, id: s_shed_socket, name: "Z. domček", entity: switch.mcu_shed_socket, icon: "\U000F1108", domain: switch}} + s_garden: !include {file: common/nspanel_terminal/switch_tile.yaml, vars: {page: page_outside, id: s_garden, name: "Záhrada", entity: switch.mcu_shed_garden_light, icon: "\U000F1987", domain: switch}} + # Závlaha, robot -> page_irrigation_auto + v_a1: !include {file: common/nspanel_terminal/switch_tile.yaml, vars: {page: page_irrigation, id: v_a1, name: "A1", entity: switch.mcu_well_irrigation_valve_a1, icon: "\U000F1066", domain: switch}} + v_a2: !include {file: common/nspanel_terminal/switch_tile.yaml, vars: {page: page_irrigation, id: v_a2, name: "A2", entity: switch.mcu_well_irrigation_valve_a2, icon: "\U000F1066", domain: switch}} + v_a3: !include {file: common/nspanel_terminal/switch_tile.yaml, vars: {page: page_irrigation, id: v_a3, name: "A3", entity: switch.mcu_well_irrigation_valve_a3, icon: "\U000F1066", domain: switch}} + v_a4: !include {file: common/nspanel_terminal/switch_tile.yaml, vars: {page: page_irrigation, id: v_a4, name: "A4", entity: switch.mcu_well_irrigation_valve_a4, icon: "\U000F1066", domain: switch}} + v_a5: !include {file: common/nspanel_terminal/switch_tile.yaml, vars: {page: page_irrigation, id: v_a5, name: "A5", entity: switch.mcu_well_irrigation_valve_a5, icon: "\U000F1066", domain: switch}} + irrigation_auto: !include {file: common/nspanel_terminal/nav_tile.yaml, vars: {page: page_irrigation, to: page_irrigation_auto, icon: "\U000F06A9"}} + ir_morning: !include {file: common/nspanel_terminal/switch_tile.yaml, vars: {page: page_irrigation_auto, id: ir_morning, name: "Ráno", entity: automation.irrigation_morning, icon: "\U000F059C", domain: automation}} + ir_patio: !include {file: common/nspanel_terminal/switch_tile.yaml, vars: {page: page_irrigation_auto, id: ir_patio, name: "Terasa", entity: automation.irrigation_patio, icon: "\U000F024A", domain: automation}} + ir_grass: !include {file: common/nspanel_terminal/switch_tile.yaml, vars: {page: page_irrigation_auto, id: ir_grass, name: "Rast trávy", entity: automation.irrigation_grow_grass, icon: "\U000F1510", domain: automation}} + # Brána, robot -> page_gate_auto + gate_open: !include {file: common/nspanel_terminal/action_tile.yaml, vars: {page: page_gate, id: gate_open, name: "Otvoriť", icon: "\U000F116A", action: button.press, entity: button.mcu_gate_open}} + gate_close: !include {file: common/nspanel_terminal/action_tile.yaml, vars: {page: page_gate, id: gate_close, name: "Zatvoriť", icon: "\U000F0299", action: button.press, entity: button.mcu_gate_close}} + gate_spacer: !include {file: common/nspanel_terminal/spacer_tile.yaml, vars: {page: page_gate}} + gate: !include {file: common/nspanel_terminal/gate.yaml, vars: {page: page_gate, state: select.mcu_gate_state}} + gate_auto: !include {file: common/nspanel_terminal/nav_tile.yaml, vars: {page: page_gate, to: page_gate_auto, icon: "\U000F06A9"}} + gate_auto_open: !include {file: common/nspanel_terminal/switch_tile.yaml, vars: {page: page_gate_auto, id: gate_auto_open, name: "Auto-otváranie", entity: switch.mcu_gate_auto_open, icon: "\U000F1169", domain: switch}} + gate_auto_close: !include {file: common/nspanel_terminal/switch_tile.yaml, vars: {page: page_gate_auto, id: gate_auto_close, name: "Auto-zatváranie", entity: switch.mcu_gate_auto_close, icon: "\U000F17F7", domain: switch}} + # Kúrenie + thermo: !include {file: common/nspanel_terminal/thermostat.yaml, vars: {id: thermo, page: page_thermostat, title: "Kúrenie - Obývačka", prev: page_gate, next: page_status, entity: climate.bt_trv_living_room_kitchen}} -nspanel_lovelace: - cards: - - type: cardGrid - title: Kuchyňa / Obývačka - id: card_home - entities: - - name: Kuchyňa / Obývačka - entity_id: light.kitchen - icon: ceiling-light - - name: Stôl - entity_id: light.dining_table - icon: ceiling-light - - name: Gauč - entity_id: light.living_room - icon: ceiling-light - - name: TV - entity_id: light.mcu_tv_light_strip - icon: led-strip-variant - - name: (Stôl) - entity_id: light.dining_table_ambilight - icon: ceiling-light-multiple-outline - - name: (Gauč) - entity_id: light.living_room_ambilight - icon: ceiling-light-multiple-outline - - - type: cardGrid - title: Kuchyňa - entities: - - name: Linka - entity_id: light.worktop_lights - icon: countertop - - name: Sporák - entity_id: light.mcu_kitchen_stove - icon: stove - - - type: cardGrid - title: Von - id: card_outside - entities: - - name: Terasa - entity_id: light.patio_lights - icon: lightbulb-group - - name: Terasa - entity_id: switch.mcu_patio_relay - icon: power-socket-fr - - name: Vzadu - entity_id: switch.mcu_nspanel_patio_outside_light_back - icon: light-flood-down - - name: Z. domček - entity_id: switch.mcu_shed_light - icon: wall-sconce-flat - # state_template: '{{ is_state("binary_sensor.shed_status", "off") }}' - - name: Z. domček - entity_id: switch.mcu_shed_socket - icon: power-socket-fr - # state_template: '{{ is_state("binary_sensor.shed_status", "off") }}' - - name: Záhrada - entity_id: switch.mcu_shed_garden_light - icon: light-flood-down - # state_template: '{{ is_state("binary_sensor.shed_status", "off") }}' - - - type: cardGrid - title: Závlaha - entities: - - name: A1 - entity_id: switch.mcu_well_irrigation_valve_a1 - icon: valve - - name: A2 - entity_id: switch.mcu_well_irrigation_valve_a2 - icon: valve - - name: A3 - entity_id: switch.mcu_well_irrigation_valve_a3 - icon: valve - - name: A4 - entity_id: switch.mcu_well_irrigation_valve_a4 - icon: valve - - name: A5 - entity_id: switch.mcu_well_irrigation_valve_a5 - icon: valve - - name: Automatizácia - entity_id: navigate.card_irrigation_automation - - - type: cardGrid - title: Brána - entities: - - name: Otvoriť - entity_id: button.mcu_gate_open - icon: gate-open - - name: Zatvoriť - entity_id: button.mcu_gate_close - icon: gate - - name: Automatizácia - entity_id: navigate.card_gate_automation - - - type: cardThermo - title: Kúrenie - thermo_entity_id: climate.bt_trv_living_room_kitchen - - - type: cardEntities - title: Automatizácia - id: card_gate_automation - hidden: true - entities: - - name: Auto-otváranie - entity_id: switch.gate_auto_open - - name: Auto-zatváranie - entity_id: switch.gate_auto_close - - - type: cardEntities - title: Automatizácia - id: card_irrigation_automation - hidden: true - entities: - - name: Ráno - entity_id: automation.irrigation_morning - - name: Terasa - entity_id: automation.irrigation_patio - - name: Rast trávy - entity_id: automation.irrigation_grow_grass - - - type: cardEntities - title: Info - entities: - - name: Zariadenie - entity_id: button.patio_nspanel_info - icon: information-outline +# the grid pages; home, status and light detail come from panel.yaml, thermostat pages from thermostat.yaml +lvgl: + pages: + - <<: !include {file: common/nspanel_terminal/grid_page.yaml, vars: {id: page_kitchen_living, title: "Kuchyňa / Obývačka", prev: page_home, next: page_kitchen, skip: false}} + - <<: !include {file: common/nspanel_terminal/grid_page.yaml, vars: {id: page_kitchen, title: "Kuchyňa", prev: page_kitchen_living, next: page_outside, skip: false}} + - <<: !include {file: common/nspanel_terminal/grid_page.yaml, vars: {id: page_outside, title: "Von", prev: page_kitchen, next: page_irrigation, skip: false}} + - <<: !include {file: common/nspanel_terminal/grid_page.yaml, vars: {id: page_irrigation, title: "Závlaha", prev: page_outside, next: page_gate, skip: false}} + - <<: !include {file: common/nspanel_terminal/grid_page.yaml, vars: {id: page_irrigation_auto, title: "Automatizácia závlahy", prev: page_irrigation, next: page_irrigation, skip: true}} + - <<: !include {file: common/nspanel_terminal/grid_page.yaml, vars: {id: page_gate, title: "Brána", prev: page_irrigation, next: page_thermostat, skip: false}} + - <<: !include {file: common/nspanel_terminal/grid_page.yaml, vars: {id: page_gate_auto, title: "Automatizácia brány", prev: page_gate, next: page_gate, skip: true}} binary_sensor: + # both buttons show the Von page, where the change is visible - platform: gpio name: Left Button pin: @@ -169,7 +97,8 @@ binary_sensor: inverted: true on_click: - switch.toggle: relay_1 - - script.execute: show_outside_card + - lvgl.page.show: page_outside + - script.execute: wake_screen - platform: gpio name: Right Button @@ -188,7 +117,8 @@ binary_sensor: action: light.toggle data: entity_id: light.patio_lights - - script.execute: show_outside_card + - lvgl.page.show: page_outside + - script.execute: wake_screen else: - switch.toggle: relay_2 @@ -210,13 +140,3 @@ switch: entity_category: config pin: number: 19 - -script: - # jump straight to the "Von" card (one render instead of home + next + next): - # make it the default page for a moment, render it, restore the home card - - id: show_outside_card - then: - - lambda: |- - id(nspanel_id).set_default_page("card_outside"); - id(nspanel_id).render_default_page(); - id(nspanel_id).set_default_page("card_home");