mirror of
https://github.com/randybb/esphome-configs.git
synced 2026-10-14 08:35:12 +02:00
nspanel: popups for OTA progress and device info, Info card on every panel
common/nspanel_popup.yaml shows a popupNotify page during OTA (written straight to the display uart, since OTA blocks the loop that sends the component's queued commands) and a device info popup (version, build time, IPs) from the Info button on the new last card or the show_info API action. The OTA gets id ota_esphome to extend it. Also documents the NSPanel pinout.
This commit is contained in:
1 parent
c5ab280725
commit
271a5a5a54
9 files changed
+230
No files matched your search
@@ -31,6 +31,9 @@ esp32:
|
|||||||
minimum_chip_revision: 3.0
|
minimum_chip_revision: 3.0
|
||||||
sram1_as_iram: true
|
sram1_as_iram: true
|
||||||
|
|
||||||
|
packages:
|
||||||
|
popup: !include nspanel_popup.yaml
|
||||||
|
|
||||||
external_components:
|
external_components:
|
||||||
- source:
|
- source:
|
||||||
type: git
|
type: git
|
||||||
|
|||||||
@@ -0,0 +1,98 @@
|
|||||||
|
---
|
||||||
|
# NSPanel popups (popupNotify page), without changes to nspanel_lovelace:
|
||||||
|
# - OTA progress
|
||||||
|
# - device info (version, IPs) via the show_info API action
|
||||||
|
# Needs nspanel_lovelace (id nspanel_id), its uart (id display_uart) and the
|
||||||
|
# ota id ota_esphome (common/ota_esp32.yaml).
|
||||||
|
# The component doesn't track these popups; the panel either reboots (OTA)
|
||||||
|
# or goes back to the default page afterwards.
|
||||||
|
api:
|
||||||
|
actions:
|
||||||
|
- action: show_info
|
||||||
|
then:
|
||||||
|
- script.execute: info_popup
|
||||||
|
|
||||||
|
script:
|
||||||
|
- id: info_popup
|
||||||
|
mode: restart
|
||||||
|
then:
|
||||||
|
- lambda: |-
|
||||||
|
char build[Application::BUILD_TIME_STR_SIZE];
|
||||||
|
App.get_build_time_string(build);
|
||||||
|
std::string msg = "ESPHome " ESPHOME_VERSION "\r\n";
|
||||||
|
msg += build;
|
||||||
|
// global/ULA first, link-local last
|
||||||
|
std::vector<std::string> ips;
|
||||||
|
for (int pass = 0; pass < 2; pass++) {
|
||||||
|
for (auto &ip : wifi::global_wifi_component->wifi_sta_ip_addresses()) {
|
||||||
|
if (!ip.is_set()) continue;
|
||||||
|
char buf[network::IP_ADDRESS_BUFFER_SIZE];
|
||||||
|
ip.str_to(buf);
|
||||||
|
bool ll = strncmp(buf, "fe80", 4) == 0;
|
||||||
|
if (ll == (pass == 1)) ips.emplace_back(buf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (auto &ip : ips) msg += "\r\n" + ip;
|
||||||
|
id(nspanel_id).send_display_command("pageType~popupNotify");
|
||||||
|
id(nspanel_id).send_display_command(
|
||||||
|
"entityUpdateDetail~info~" + App.get_friendly_name() + "~65535~~65535~~65535~" + msg + "~65535~15");
|
||||||
|
- delay: 15s
|
||||||
|
- lambda: 'id(nspanel_id).render_default_page();'
|
||||||
|
|
||||||
|
# OTA blocks the main loop, and nspanel_lovelace only sends its queued
|
||||||
|
# commands from loop(), so these frames go straight to the uart in the
|
||||||
|
# component's format: 55 BB, length (LE), command, CRC16 (LE).
|
||||||
|
- id: ota_popup
|
||||||
|
parameters:
|
||||||
|
message: string
|
||||||
|
then:
|
||||||
|
- lambda: |-
|
||||||
|
auto send = [](const std::string &cmd) {
|
||||||
|
uint8_t hdr[4] = {0x55, 0xBB, uint8_t(cmd.size() & 0xFF), uint8_t(cmd.size() >> 8)};
|
||||||
|
uint16_t crc = crc16(hdr, 4);
|
||||||
|
crc = crc16(reinterpret_cast<const uint8_t *>(cmd.data()), cmd.size(), crc);
|
||||||
|
uint8_t tail[2] = {uint8_t(crc & 0xFF), uint8_t(crc >> 8)};
|
||||||
|
id(display_uart).write_array(hdr, 4);
|
||||||
|
id(display_uart).write_array(reinterpret_cast<const uint8_t *>(cmd.data()), cmd.size());
|
||||||
|
id(display_uart).write_array(tail, 2);
|
||||||
|
id(display_uart).flush();
|
||||||
|
};
|
||||||
|
send("dimmode~100~100");
|
||||||
|
send("pageType~popupNotify");
|
||||||
|
send("entityUpdateDetail~ota~Aktualizácia firmvéru~65535~~65535~~65535~" + message + "~65535~0");
|
||||||
|
|
||||||
|
ota:
|
||||||
|
- id: !extend ota_esphome
|
||||||
|
on_begin:
|
||||||
|
- script.execute:
|
||||||
|
id: ota_popup
|
||||||
|
message: Nahrávam…
|
||||||
|
on_progress:
|
||||||
|
- lambda: |-
|
||||||
|
static int last = -1;
|
||||||
|
int pct = (int) x / 10 * 10;
|
||||||
|
if (pct != last) {
|
||||||
|
last = pct;
|
||||||
|
id(ota_popup)->execute("Nahrávam… " + std::to_string(pct) + " %");
|
||||||
|
}
|
||||||
|
on_end:
|
||||||
|
- script.execute:
|
||||||
|
id: ota_popup
|
||||||
|
message: Hotovo, reštartujem
|
||||||
|
on_error:
|
||||||
|
- script.execute:
|
||||||
|
id: ota_popup
|
||||||
|
message: Aktualizácia zlyhala
|
||||||
|
- delay: 5s
|
||||||
|
- lambda: |-
|
||||||
|
id(nspanel_id).set_display_dim(5, 80);
|
||||||
|
id(nspanel_id).render_default_page();
|
||||||
|
|
||||||
|
button:
|
||||||
|
# put button.<device>_info on a card: the panel presses it through HA
|
||||||
|
- platform: template
|
||||||
|
name: Info
|
||||||
|
id: info_button
|
||||||
|
entity_category: diagnostic
|
||||||
|
on_press:
|
||||||
|
- script.execute: info_popup
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
---
|
---
|
||||||
ota:
|
ota:
|
||||||
- platform: esphome
|
- platform: esphome
|
||||||
|
id: ota_esphome
|
||||||
password: !secret ota_password
|
password: !secret ota_password
|
||||||
allow_partition_access: true
|
allow_partition_access: true
|
||||||
@@ -1,4 +1,18 @@
|
|||||||
---
|
---
|
||||||
|
# Hardware: Sonoff NSPanel (EU)
|
||||||
|
# Pinout:
|
||||||
|
# GPIO2 IO2
|
||||||
|
# GPIO4 Screen power -> Screen Power (switch gpio) (inverted)
|
||||||
|
# GPIO14 Left button -> Left Button (binary_sensor gpio) (inverted)
|
||||||
|
# GPIO16 Display UART TX -> display_uart (uart tx_pin)
|
||||||
|
# GPIO17 Display UART RX -> display_uart (uart rx_pin)
|
||||||
|
# GPIO19 Relay 2
|
||||||
|
# GPIO21 Buzzer -> buzzer_out (output ledc)
|
||||||
|
# GPIO22 Relay 1 -> relay_1 (output gpio)
|
||||||
|
# GPIO23 Relay 3 (no relay, connector)
|
||||||
|
# GPIO27 Right button -> Right Button (binary_sensor gpio) (inverted)
|
||||||
|
# GPIO37 ALS (light sensor)
|
||||||
|
# GPIO38 NTC temperature (ADC) -> ntc_source (sensor adc)
|
||||||
substitutions:
|
substitutions:
|
||||||
device: nspanel-bedroom
|
device: nspanel-bedroom
|
||||||
name: Bedroom NSPanel
|
name: Bedroom NSPanel
|
||||||
@@ -51,6 +65,13 @@ nspanel_lovelace:
|
|||||||
title: Kúrenie
|
title: Kúrenie
|
||||||
thermo_entity_id: climate.bt_trv_bedroom
|
thermo_entity_id: climate.bt_trv_bedroom
|
||||||
|
|
||||||
|
- type: cardEntities
|
||||||
|
title: Info
|
||||||
|
entities:
|
||||||
|
- name: Zariadenie
|
||||||
|
entity_id: button.bedroom_nspanel_info
|
||||||
|
icon: information-outline
|
||||||
|
|
||||||
binary_sensor:
|
binary_sensor:
|
||||||
- platform: gpio
|
- platform: gpio
|
||||||
name: Left Button
|
name: Left Button
|
||||||
|
|||||||
@@ -1,4 +1,18 @@
|
|||||||
---
|
---
|
||||||
|
# Hardware: Sonoff NSPanel (EU)
|
||||||
|
# Pinout:
|
||||||
|
# GPIO2 IO2
|
||||||
|
# GPIO4 Screen power -> Screen Power (switch gpio) (inverted)
|
||||||
|
# GPIO14 Left button -> Left Button (binary_sensor gpio) (inverted)
|
||||||
|
# GPIO16 Display UART TX -> display_uart (uart tx_pin)
|
||||||
|
# GPIO17 Display UART RX -> display_uart (uart rx_pin)
|
||||||
|
# GPIO19 Relay 2 -> Relay 2 (switch gpio)
|
||||||
|
# GPIO21 Buzzer -> buzzer_out (output ledc)
|
||||||
|
# GPIO22 Relay 1 -> Relay 1 (switch gpio)
|
||||||
|
# GPIO23 Relay 3 (no relay, connector)
|
||||||
|
# GPIO27 Right button -> Right Button (binary_sensor gpio) (inverted)
|
||||||
|
# GPIO37 ALS (light sensor)
|
||||||
|
# GPIO38 NTC temperature (ADC) -> ntc_source (sensor adc)
|
||||||
substitutions:
|
substitutions:
|
||||||
device: nspanel-dev
|
device: nspanel-dev
|
||||||
name: NSPanel DEV
|
name: NSPanel DEV
|
||||||
@@ -60,6 +74,7 @@ external_components:
|
|||||||
packages:
|
packages:
|
||||||
common: !include common/common.yaml
|
common: !include common/common.yaml
|
||||||
ipv6_only: !include common/ipv6_only.yaml
|
ipv6_only: !include common/ipv6_only.yaml
|
||||||
|
nspanel_popup: !include common/nspanel_popup.yaml
|
||||||
# common: !include common/common_dev.yaml
|
# common: !include common/common_dev.yaml
|
||||||
|
|
||||||
# web_server:
|
# web_server:
|
||||||
@@ -441,6 +456,13 @@ nspanel_lovelace:
|
|||||||
- name: Rast trávy
|
- name: Rast trávy
|
||||||
entity_id: automation.irrigation_grow_grass
|
entity_id: automation.irrigation_grow_grass
|
||||||
|
|
||||||
|
- type: cardEntities
|
||||||
|
title: Info
|
||||||
|
entities:
|
||||||
|
- name: Zariadenie
|
||||||
|
entity_id: button.nspanel_dev_info
|
||||||
|
icon: information-outline
|
||||||
|
|
||||||
binary_sensor:
|
binary_sensor:
|
||||||
- platform: gpio
|
- platform: gpio
|
||||||
name: Left Button
|
name: Left Button
|
||||||
|
|||||||
@@ -1,4 +1,18 @@
|
|||||||
---
|
---
|
||||||
|
# Hardware: Sonoff NSPanel (EU)
|
||||||
|
# Pinout:
|
||||||
|
# GPIO2 IO2
|
||||||
|
# GPIO4 Screen power -> Screen Power (switch gpio) (inverted)
|
||||||
|
# GPIO14 Left button -> Left Button (binary_sensor gpio) (inverted)
|
||||||
|
# GPIO16 Display UART TX -> display_uart (uart tx_pin)
|
||||||
|
# GPIO17 Display UART RX -> display_uart (uart rx_pin)
|
||||||
|
# GPIO19 Relay 2 -> Dining Table Light MAIN (switch gpio)
|
||||||
|
# GPIO21 Buzzer -> buzzer_out (output ledc)
|
||||||
|
# GPIO22 Relay 1 -> Kitchen Worktop Light (switch gpio)
|
||||||
|
# GPIO23 Relay 3 (no relay, connector)
|
||||||
|
# GPIO27 Right button -> Right Button (binary_sensor gpio) (inverted)
|
||||||
|
# GPIO37 ALS (light sensor)
|
||||||
|
# GPIO38 NTC temperature (ADC) -> ntc_source (sensor adc)
|
||||||
substitutions:
|
substitutions:
|
||||||
device: nspanel-fireplace
|
device: nspanel-fireplace
|
||||||
name: Fireplace NSPanel
|
name: Fireplace NSPanel
|
||||||
@@ -108,6 +122,13 @@ nspanel_lovelace:
|
|||||||
- name: Auto-zatváranie
|
- name: Auto-zatváranie
|
||||||
entity_id: switch.gate_auto_close
|
entity_id: switch.gate_auto_close
|
||||||
|
|
||||||
|
- type: cardEntities
|
||||||
|
title: Info
|
||||||
|
entities:
|
||||||
|
- name: Zariadenie
|
||||||
|
entity_id: button.fireplace_nspanel_info
|
||||||
|
icon: information-outline
|
||||||
|
|
||||||
binary_sensor:
|
binary_sensor:
|
||||||
- platform: gpio
|
- platform: gpio
|
||||||
name: Left Button
|
name: Left Button
|
||||||
|
|||||||
@@ -1,4 +1,18 @@
|
|||||||
---
|
---
|
||||||
|
# Hardware: Sonoff NSPanel (EU)
|
||||||
|
# Pinout:
|
||||||
|
# GPIO2 IO2
|
||||||
|
# GPIO4 Screen power -> Screen Power (switch gpio) (inverted)
|
||||||
|
# GPIO14 Left button -> Left Button (binary_sensor gpio) (inverted)
|
||||||
|
# GPIO16 Display UART TX -> display_uart (uart tx_pin)
|
||||||
|
# GPIO17 Display UART RX -> display_uart (uart rx_pin)
|
||||||
|
# GPIO19 Relay 2
|
||||||
|
# GPIO21 Buzzer -> buzzer_out (output ledc)
|
||||||
|
# GPIO22 Relay 1 -> relay_1 (output gpio)
|
||||||
|
# GPIO23 Relay 3 (no relay, connector)
|
||||||
|
# GPIO27 Right button -> Right Button (binary_sensor gpio) (inverted)
|
||||||
|
# GPIO37 ALS (light sensor)
|
||||||
|
# GPIO38 NTC temperature (ADC) -> ntc_source (sensor adc)
|
||||||
substitutions:
|
substitutions:
|
||||||
device: nspanel-office-j
|
device: nspanel-office-j
|
||||||
name: Office J NSPanel
|
name: Office J NSPanel
|
||||||
@@ -61,6 +75,13 @@ nspanel_lovelace:
|
|||||||
- name: Auto-zatváranie
|
- name: Auto-zatváranie
|
||||||
entity_id: switch.gate_auto_close
|
entity_id: switch.gate_auto_close
|
||||||
|
|
||||||
|
- type: cardEntities
|
||||||
|
title: Info
|
||||||
|
entities:
|
||||||
|
- name: Zariadenie
|
||||||
|
entity_id: button.office_j_nspanel_info
|
||||||
|
icon: information-outline
|
||||||
|
|
||||||
binary_sensor:
|
binary_sensor:
|
||||||
- platform: gpio
|
- platform: gpio
|
||||||
name: Left Button
|
name: Left Button
|
||||||
|
|||||||
@@ -1,4 +1,18 @@
|
|||||||
---
|
---
|
||||||
|
# Hardware: Sonoff NSPanel (EU)
|
||||||
|
# Pinout:
|
||||||
|
# GPIO2 IO2
|
||||||
|
# GPIO4 Screen power -> Screen Power (switch gpio) (inverted)
|
||||||
|
# GPIO14 Left button -> Left Button (binary_sensor gpio) (inverted)
|
||||||
|
# GPIO16 Display UART TX -> display_uart (uart tx_pin)
|
||||||
|
# GPIO17 Display UART RX -> display_uart (uart rx_pin)
|
||||||
|
# GPIO19 Relay 2 -> relay_2 (switch gpio)
|
||||||
|
# GPIO21 Buzzer -> buzzer_out (output ledc)
|
||||||
|
# GPIO22 Relay 1 -> relay_1 (output gpio)
|
||||||
|
# GPIO23 Relay 3 (no relay, connector) -> Presence Light (light esp32_rmt_led_strip)
|
||||||
|
# GPIO27 Right button -> Right Button (binary_sensor gpio) (inverted)
|
||||||
|
# GPIO37 ALS (light sensor)
|
||||||
|
# GPIO38 NTC temperature (ADC) -> ntc_source (sensor adc)
|
||||||
substitutions:
|
substitutions:
|
||||||
device: nspanel-office-r
|
device: nspanel-office-r
|
||||||
name: Office R NSPanel
|
name: Office R NSPanel
|
||||||
@@ -82,6 +96,13 @@ nspanel_lovelace:
|
|||||||
- name: Auto-zatváranie
|
- name: Auto-zatváranie
|
||||||
entity_id: switch.gate_auto_close
|
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:
|
binary_sensor:
|
||||||
- platform: gpio
|
- platform: gpio
|
||||||
name: Left Button
|
name: Left Button
|
||||||
|
|||||||
@@ -1,4 +1,18 @@
|
|||||||
---
|
---
|
||||||
|
# Hardware: Sonoff NSPanel (EU)
|
||||||
|
# Pinout:
|
||||||
|
# GPIO2 IO2
|
||||||
|
# GPIO4 Screen power -> Screen Power (switch gpio) (inverted)
|
||||||
|
# GPIO14 Left button -> Left Button (binary_sensor gpio) (inverted)
|
||||||
|
# GPIO16 Display UART TX -> display_uart (uart tx_pin)
|
||||||
|
# GPIO17 Display UART RX -> display_uart (uart rx_pin)
|
||||||
|
# GPIO19 Relay 2 -> Light MAIN (switch gpio)
|
||||||
|
# GPIO21 Buzzer -> buzzer_out (output ledc)
|
||||||
|
# GPIO22 Relay 1 -> Outside Light Back (switch gpio)
|
||||||
|
# GPIO23 Relay 3 (no relay, connector)
|
||||||
|
# GPIO27 Right button -> Right Button (binary_sensor gpio) (inverted)
|
||||||
|
# GPIO37 ALS (light sensor)
|
||||||
|
# GPIO38 NTC temperature (ADC) -> ntc_source (sensor adc)
|
||||||
substitutions:
|
substitutions:
|
||||||
device: nspanel-patio
|
device: nspanel-patio
|
||||||
name: Patio NSPanel
|
name: Patio NSPanel
|
||||||
@@ -137,6 +151,13 @@ nspanel_lovelace:
|
|||||||
- name: Rast trávy
|
- name: Rast trávy
|
||||||
entity_id: automation.irrigation_grow_grass
|
entity_id: automation.irrigation_grow_grass
|
||||||
|
|
||||||
|
- type: cardEntities
|
||||||
|
title: Info
|
||||||
|
entities:
|
||||||
|
- name: Zariadenie
|
||||||
|
entity_id: button.patio_nspanel_info
|
||||||
|
icon: information-outline
|
||||||
|
|
||||||
binary_sensor:
|
binary_sensor:
|
||||||
- platform: gpio
|
- platform: gpio
|
||||||
name: Left Button
|
name: Left Button
|
||||||
@@ -190,3 +211,4 @@ switch:
|
|||||||
entity_category: config
|
entity_category: config
|
||||||
pin:
|
pin:
|
||||||
number: 19
|
number: 19
|
||||||
|
|
||||||
Reference in new issue
Block a user