mirror of
https://github.com/randybb/esphome-configs.git
synced 2026-12-06 09:06:52 +01:00
nspanel: drop the nspanel_lovelace leftovers
No panel uses common/nspanel.yaml, nspanel_popup.yaml, nspanel_sleep_dim.yaml or the lui.tft secret any more.
This commit is contained in:
1 parent
9b5229323f
commit
cafa2da954
5 files changed
+1
-308
No files matched your search
@@ -1,166 +0,0 @@
|
||||
---
|
||||
# Sonoff NSPanel with the native Lovelace UI (randybb/esphome-nspanel-lovelace-native).
|
||||
# The device file adds the cards, buttons and relays:
|
||||
# packages:
|
||||
# common: !include common/common.yaml
|
||||
# nspanel: !include
|
||||
# file: common/nspanel.yaml
|
||||
# vars:
|
||||
# temperature_entity: sensor.zigbee_bedroom_temperature
|
||||
# nspanel_lovelace:
|
||||
# cards: [...]
|
||||
defaults:
|
||||
temperature_name: Temperature
|
||||
ntc_reference_temperature: 25°C
|
||||
|
||||
esphome:
|
||||
on_boot:
|
||||
then:
|
||||
- switch.turn_off: screen_power
|
||||
- delay: 1s
|
||||
- switch.turn_on: screen_power
|
||||
- delay: 2s
|
||||
- lambda: 'id(nspanel_id).set_display_dim(5, 80);'
|
||||
|
||||
esp32:
|
||||
variant: esp32
|
||||
toolchain: esp-idf
|
||||
framework:
|
||||
type: esp-idf
|
||||
advanced:
|
||||
flash_chip: generic
|
||||
minimum_chip_revision: 3.0
|
||||
sram1_as_iram: true
|
||||
|
||||
packages:
|
||||
popup: !include nspanel_popup.yaml
|
||||
|
||||
external_components:
|
||||
- source:
|
||||
type: git
|
||||
url: https://github.com/randybb/esphome-nspanel-lovelace-native
|
||||
ref: devices
|
||||
refresh: 0s
|
||||
components: [nspanel_lovelace]
|
||||
|
||||
api:
|
||||
homeassistant_services: true
|
||||
homeassistant_states: true
|
||||
actions:
|
||||
- action: play_rtttl
|
||||
variables:
|
||||
song: string
|
||||
then:
|
||||
- rtttl.play:
|
||||
rtttl: !lambda 'return song;'
|
||||
|
||||
- action: notify
|
||||
variables:
|
||||
heading: string
|
||||
message: string
|
||||
song: string
|
||||
then:
|
||||
- lambda: 'id(nspanel_id).notify_on_screensaver(heading, message, 10000);'
|
||||
- rtttl.play:
|
||||
rtttl: !lambda 'return song;'
|
||||
|
||||
- action: notify_fullscreen
|
||||
variables:
|
||||
title: string
|
||||
description: string
|
||||
button1: string
|
||||
button2: string
|
||||
timeout: int
|
||||
icon: string
|
||||
then:
|
||||
- lambda: 'id(nspanel_id).notify_on_screensaver(title, description, timeout);'
|
||||
- rtttl.play: "scale_up:d=32,o=5,b=100:c,c#,d#,e,f#,g#,a#,b"
|
||||
|
||||
uart:
|
||||
id: display_uart
|
||||
tx_pin: 16
|
||||
rx_pin: 17
|
||||
baud_rate: 115200
|
||||
|
||||
nspanel_lovelace:
|
||||
id: nspanel_id
|
||||
sleep_timeout: 10
|
||||
experimental_vertical_ui: true
|
||||
locale:
|
||||
language: sk
|
||||
temperature_unit: celcius
|
||||
screensaver:
|
||||
time_id: ha_time
|
||||
time_format: '%H:%M'
|
||||
date_format: '%A, %d. %b. %Y'
|
||||
weather:
|
||||
entity_id: sensor.weather_forecast_daily
|
||||
icon_color: [255, 255, 255]
|
||||
entities:
|
||||
- entity_id: ${temperature_entity}
|
||||
icon:
|
||||
value: home-thermometer-outline
|
||||
color: [255, 255, 255]
|
||||
precision: 1
|
||||
|
||||
output:
|
||||
- platform: ledc
|
||||
id: buzzer_out
|
||||
pin:
|
||||
number: 21
|
||||
|
||||
switch:
|
||||
- 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
|
||||
name: ${temperature_name}
|
||||
id: temperature
|
||||
sensor: resistance_sensor
|
||||
calibration:
|
||||
b_constant: 3950
|
||||
reference_temperature: ${ntc_reference_temperature}
|
||||
reference_resistance: 10kOhm
|
||||
|
||||
text_sensor:
|
||||
- platform: homeassistant
|
||||
id: name_day
|
||||
entity_id: sensor.nameday_sk
|
||||
on_value:
|
||||
- lambda: |-
|
||||
id(nspanel_id).set_time_format("%H:%M~" + x);
|
||||
id(nspanel_id).update_time();
|
||||
|
||||
# HMI protocol version reported by the TFT on startup (52/53 for this UI)
|
||||
- platform: template
|
||||
name: TFT Version
|
||||
entity_category: diagnostic
|
||||
update_interval: 60s
|
||||
lambda: |-
|
||||
using esphome::nspanel_lovelace::Configuration;
|
||||
const auto ver = Configuration::get_version();
|
||||
if (ver == 0) return {"unknown"};
|
||||
return {std::to_string(ver) + " (" + Configuration::get_model_str() + ")"};
|
||||
@@ -1,98 +0,0 @@
|
||||
---
|
||||
# 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,42 +0,0 @@
|
||||
---
|
||||
# NSPanel screensaver dims to 0 at night (sun below -6°), unless the room lights are on.
|
||||
# packages:
|
||||
# sleep_dim: !include
|
||||
# file: common/nspanel_sleep_dim.yaml
|
||||
# vars:
|
||||
# sleep_override_entity: light.bedroom_lights
|
||||
script:
|
||||
- id: apply_sleep_dim
|
||||
then:
|
||||
- lambda: |-
|
||||
uint8_t dim;
|
||||
if (id(sleep_override).state) dim = 5; // sleepOverride
|
||||
else if (id(sun_id).is_above_horizon(-6)) dim = 5; // day
|
||||
else dim = 0; // night
|
||||
id(nspanel_id).set_display_inactive_dim(dim);
|
||||
|
||||
time:
|
||||
- id: !extend ha_time
|
||||
on_time_sync:
|
||||
- script.execute: apply_sleep_dim
|
||||
|
||||
binary_sensor:
|
||||
- platform: homeassistant # sleepOverride
|
||||
id: sleep_override
|
||||
entity_id: ${sleep_override_entity}
|
||||
on_state:
|
||||
- script.execute: apply_sleep_dim
|
||||
|
||||
sun:
|
||||
id: sun_id
|
||||
time_id: ha_time
|
||||
latitude: 48.15°
|
||||
longitude: 17.11°
|
||||
on_sunrise:
|
||||
- elevation: -6°
|
||||
then:
|
||||
- script.execute: apply_sleep_dim
|
||||
on_sunset:
|
||||
- elevation: -6°
|
||||
then:
|
||||
- script.execute: apply_sleep_dim
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
# nspanel-terminal version of common/nspanel_sleep_dim.yaml: the idle (dimmed) brightness drops to 0 at night
|
||||
# NSPanel sleep dim: the idle (dimmed) brightness drops to 0 at night
|
||||
# (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
|
||||
|
||||
@@ -10,7 +10,6 @@ api_key: "oSsCFxRUqIJLpT98cQwSwNxYoC7zbUh0YBHczAWRyBI="
|
||||
ota_password: "password"
|
||||
|
||||
ha_url: http://ha.local:8123/
|
||||
tft_url: http://ha.local:8123/local/tft/lui.tft
|
||||
tft_url_terminal: http://ha.local/local/tft/terminal-eu.tft
|
||||
|
||||
mqtt_ip: ha.local
|
||||
|
||||
Reference in new issue
Block a user