additional esphome devices and fixes
This commit is contained in:
@@ -0,0 +1,316 @@
|
||||
#:########################################################################################:#
|
||||
# TITLE: LOUNGE NSPANEL 2
|
||||
# zorruno.com layout v1.1 2026
|
||||
#:########################################################################################:#
|
||||
# REPO:
|
||||
#
|
||||
#:########################################################################################:#
|
||||
# VERSIONS:
|
||||
# V1.0 2026-05-16 Initial version
|
||||
#:########################################################################################:#
|
||||
# HARDWARE:
|
||||
# - Sonoff NS Panel
|
||||
#:########################################################################################:#
|
||||
# OPERATION NOTES:
|
||||
# -
|
||||
#:########################################################################################:#
|
||||
# OFFLINE NOTES:
|
||||
#
|
||||
#:########################################################################################:#
|
||||
|
||||
#:########################################################################################:#
|
||||
# SUBSTITUTIONS: Specific device variable substitutions
|
||||
# If NOT using a secrets file, just replace these with the passwords etc (in quotes)
|
||||
#:########################################################################################:#
|
||||
substitutions:
|
||||
# Device Naming
|
||||
device_name: "esp-nspanel2lounge"
|
||||
friendly_name: "Lounge NSPanel Touchscreen"
|
||||
description_comment: "D1 Mini ESP32 outside entranceway with BT Proxy (Layout V1.1)"
|
||||
device_area: "Lounge" # Allows ESP device to be automatically linked to an 'Area' in Home Assistant.
|
||||
|
||||
# Removed as the remote package will pull this in correctly for the blueprint
|
||||
# Project Naming
|
||||
#project_name: "Lounge NSPanel Touchscreen.Sonoff NS Panel"
|
||||
#project_version: "v1.0"
|
||||
|
||||
# Passwords & Secrets (unfortunately you can't use substitutions inside secrets names)
|
||||
api_key: !secret esp-api_key
|
||||
ota_pass: !secret esp-ota_pass
|
||||
ota_password: "${ota_pass}" #this is for NSPanel Only as a workaround
|
||||
static_ip_address: !secret esp-nspanel2lounge_ip
|
||||
|
||||
# If we are changing IP addresses, you must update the current IP address here, otherwise it remains
|
||||
# Don't forget to switch it back when changed.
|
||||
current_ip_address: ${static_ip_address}
|
||||
|
||||
# Device Settings
|
||||
log_level: "INFO" # NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
|
||||
update_interval: "60s" # update time for general sensors etc
|
||||
|
||||
## NSPanel Specifics
|
||||
upload_tft_automatically: true
|
||||
boot_sound: false
|
||||
|
||||
#:########################################################################################:#
|
||||
# PACKAGES: Included Common Packages
|
||||
# https://esphome.io/components/packages.html
|
||||
#:########################################################################################:#
|
||||
packages:
|
||||
#### WIFI, Network (Static/DHCP/IPV6 etc), Fallback AP, Safemode ####
|
||||
common_wifi: !include
|
||||
file: common/network_common_esp32.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
local_static_ip_address: "${static_ip_address}"
|
||||
local_ota_pass: "${ota_pass}"
|
||||
local_current_ip_address: "${current_ip_address}"
|
||||
|
||||
#### HOME ASSISTANT API (choose encryption or no encryption options) ####
|
||||
#common_api: !include
|
||||
# file: common/api_common.yaml
|
||||
#file: common/api_common_noencryption.yaml
|
||||
# vars:
|
||||
# local_api_key: "${api_key}"
|
||||
|
||||
#### MQTT ####
|
||||
#common_mqtt: !include
|
||||
# file: common/mqtt_common.yaml
|
||||
# vars:
|
||||
# local_device_name: "${device_name}"
|
||||
|
||||
#### WEB PORTAL ####
|
||||
#common_webportal: !include common/webportal_common.yaml
|
||||
|
||||
#### SNTP (Only use if you want/need accurate timeclocks) ####
|
||||
#common_sntp: !include common/sntp_common.yaml
|
||||
|
||||
#### DIAGNOSTICS Sensors ####
|
||||
#diag_basic: !include common/include_basic_diag_sensors.yaml
|
||||
#diag_more: !include common/include_more_diag_sensors.yaml
|
||||
#diag_debug: !include common/include_debug_diag_sensors.yaml
|
||||
#diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
|
||||
|
||||
# Core and optional configurations
|
||||
remote_package:
|
||||
url: https://github.com/edwardtfn/NSPanel-Easy
|
||||
ref: v2026.5.5
|
||||
refresh: 300s
|
||||
files:
|
||||
- nspanel_esphome.yaml # Basic package
|
||||
# Optional advanced and add-on configurations
|
||||
# - esphome/nspanel_esphome_addon_climate_cool.yaml
|
||||
# - esphome/nspanel_esphome_addon_climate_heat.yaml
|
||||
# - esphome/nspanel_esphome_addon_climate_dual.yaml
|
||||
# - esphome/nspanel_esphome_addon_cover.yaml
|
||||
# - esphome/nspanel_esphome_addon_display_light.yaml # Show the display as a light in Home Assistant
|
||||
|
||||
#:########################################################################################:#
|
||||
# ESPHOME:
|
||||
# https://esphome.io/components/esphome.html
|
||||
#:########################################################################################:#
|
||||
esphome:
|
||||
name: "${device_name}"
|
||||
friendly_name: "${friendly_name}"
|
||||
comment: "${description_comment}" # appears on the esphome page in HA
|
||||
area: "${device_area}"
|
||||
min_version: 2024.6.0
|
||||
#project:
|
||||
# name: "${project_name}"
|
||||
# version: "${project_version}"
|
||||
|
||||
#:########################################################################################:#
|
||||
# ESP PLATFORM AND FRAMEWORK:
|
||||
# https://esphome.io/components/esp32.html
|
||||
#:########################################################################################:#
|
||||
esp32:
|
||||
board: esp32dev
|
||||
framework:
|
||||
type: esp-idf # Suggested ESP-IDF framework
|
||||
version: recommended
|
||||
advanced:
|
||||
minimum_chip_revision: "3.1" # This makes the binary slightly smaller
|
||||
sram1_as_iram: true
|
||||
|
||||
|
||||
#uart:
|
||||
# id: tf_uart
|
||||
# tx_pin: GPIO16
|
||||
# rx_pin: GPIO17
|
||||
# baud_rate: 115200
|
||||
|
||||
|
||||
#:########################################################################################:#
|
||||
# LOGGING:
|
||||
# https://esphome.io/components/logger.html
|
||||
#:########################################################################################:#
|
||||
logger:
|
||||
level: "${log_level}"
|
||||
#baud_rate: 0 # set to 0 for no logging via UART if you want
|
||||
|
||||
#:########################################################################################:#
|
||||
# HOME ASSISTANT STATE IMPORT:
|
||||
# Import the last remembered lounge scene from Home Assistant.
|
||||
#:########################################################################################:#
|
||||
text_sensor:
|
||||
- platform: homeassistant
|
||||
id: lounge_last_scene
|
||||
entity_id: input_text.lounge_last_scene
|
||||
internal: true
|
||||
|
||||
#:########################################################################################:#
|
||||
# NSPANEL BUTTON / RELAY LABELS:
|
||||
# Extend existing NSPanel Easy entities rather than redefining GPIOs.
|
||||
#:########################################################################################:#
|
||||
binary_sensor:
|
||||
- id: !extend right_button
|
||||
name: "Lounge Stair Downlights Button"
|
||||
|
||||
switch:
|
||||
- id: !extend relay_2
|
||||
name: "Lounge Stair Downlights"
|
||||
|
||||
- platform: template
|
||||
id: nspanel_ha_loss_test
|
||||
name: "HA Loss Test"
|
||||
optimistic: true
|
||||
restore_mode: RESTORE_DEFAULT_OFF
|
||||
|
||||
#:########################################################################################:#
|
||||
# NSPANEL HARDWARE BUTTON LOCAL / HA ACTIONS:
|
||||
#
|
||||
# Behaviour:
|
||||
# - HA connected and HA Loss Test OFF:
|
||||
# - Left button toggles lounge scene between Bright and All Off
|
||||
# - Left relay is forced ON
|
||||
# - Right button toggles Relay 2 / Lounge Stair Downlights
|
||||
#
|
||||
# - HA disconnected OR HA Loss Test ON:
|
||||
# - Left button toggles Relay 1
|
||||
# - Right button toggles Relay 2 / Lounge Stair Downlights
|
||||
#
|
||||
# Notes:
|
||||
# - Uses NSPanel Easy script IDs and relay IDs.
|
||||
# - Avoid enabling Relay 1 local mode in the NSPanel blueprint, otherwise the package
|
||||
# may toggle Relay 1 before this custom logic can handle the press.
|
||||
#:########################################################################################:#
|
||||
script:
|
||||
- id: nspanel_lounge_force_left_relay_on_when_ha_connected
|
||||
mode: restart
|
||||
then:
|
||||
- if:
|
||||
condition:
|
||||
lambda: |-
|
||||
const bool actual_ha_online =
|
||||
wifi_component->is_connected() &&
|
||||
api_server->is_connected_with_state_subscription();
|
||||
|
||||
const bool effective_ha_online =
|
||||
actual_ha_online && !id(nspanel_ha_loss_test).state;
|
||||
|
||||
return effective_ha_online;
|
||||
then:
|
||||
- switch.turn_on: relay_1
|
||||
|
||||
- id: nspanel_lounge_left_button_action
|
||||
mode: restart
|
||||
then:
|
||||
- if:
|
||||
condition:
|
||||
lambda: |-
|
||||
const bool actual_ha_online =
|
||||
wifi_component->is_connected() &&
|
||||
api_server->is_connected_with_state_subscription();
|
||||
|
||||
const bool effective_ha_online =
|
||||
actual_ha_online && !id(nspanel_ha_loss_test).state;
|
||||
|
||||
return effective_ha_online;
|
||||
then:
|
||||
- script.execute: nspanel_lounge_force_left_relay_on_when_ha_connected
|
||||
|
||||
- if:
|
||||
condition:
|
||||
lambda: |-
|
||||
return id(lounge_last_scene).has_state() &&
|
||||
id(lounge_last_scene).state != "All Off";
|
||||
then:
|
||||
- homeassistant.action:
|
||||
action: script.lounge_set_scene
|
||||
data:
|
||||
scene_name: "All Off"
|
||||
else:
|
||||
- homeassistant.action:
|
||||
action: script.lounge_set_scene
|
||||
data:
|
||||
scene_name: "Bright"
|
||||
|
||||
else:
|
||||
- lambda: |-
|
||||
const bool actual_ha_online =
|
||||
wifi_component->is_connected() &&
|
||||
api_server->is_connected_with_state_subscription();
|
||||
|
||||
// If NSPanel Easy relay local mode already handled the press, do not double toggle.
|
||||
if (id(hardware_settings).relay1_local) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If this is a real HA/API outage and NSPanel Easy fallback already handled it,
|
||||
// do not double toggle. HA Loss Test still toggles here because HA is actually online.
|
||||
if (id(hardware_settings).relay1_fallback && !actual_ha_online) {
|
||||
return;
|
||||
}
|
||||
|
||||
relay_1->toggle();
|
||||
|
||||
- id: nspanel_lounge_right_button_action
|
||||
mode: restart
|
||||
then:
|
||||
- lambda: |-
|
||||
const bool actual_ha_online =
|
||||
wifi_component->is_connected() &&
|
||||
api_server->is_connected_with_state_subscription();
|
||||
|
||||
// If NSPanel Easy relay local mode already handled the press, do not double toggle.
|
||||
if (id(hardware_settings).relay2_local) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If this is a real HA/API outage and NSPanel Easy fallback already handled it,
|
||||
// do not double toggle. HA Loss Test still toggles here because HA is actually online.
|
||||
if (id(hardware_settings).relay2_fallback && !actual_ha_online) {
|
||||
return;
|
||||
}
|
||||
|
||||
relay_2->toggle();
|
||||
|
||||
- id: !extend button_left_press_short
|
||||
then:
|
||||
- script.execute: nspanel_lounge_left_button_action
|
||||
|
||||
- id: !extend button_right_press_short
|
||||
then:
|
||||
- script.execute: nspanel_lounge_right_button_action
|
||||
|
||||
#:########################################################################################:#
|
||||
# INTERVAL:
|
||||
# Keep Relay 1 ON whenever Home Assistant is effectively connected.
|
||||
#:########################################################################################:#
|
||||
interval:
|
||||
- interval: 5s
|
||||
then:
|
||||
- script.execute: nspanel_lounge_force_left_relay_on_when_ha_connected
|
||||
|
||||
#:########################################################################################:#
|
||||
# BLUETOOTH:
|
||||
# https://esphome.io/components/bluetooth_proxy.html
|
||||
# https://esphome.io/components/esp32_ble_tracker.html
|
||||
#:########################################################################################:#
|
||||
#bluetooth_proxy:
|
||||
# active: true
|
||||
|
||||
#esp32_ble_tracker:
|
||||
# scan_parameters:
|
||||
# # Defaults used so Bluetooth can co-exist with WiFi
|
||||
# active: true
|
||||
Reference in New Issue
Block a user