feat(nut-server): overwrite UPS name

Signed-off-by: bullshit <coding@ow-software.pl>
This commit is contained in:
bullshit committed 2025-09-01 22:12:44 +02:00
1 parent 7ee6783fd7
commit 564bcc0f86
4 files changed
+27 -18

No files matched your search

+4
View File
@@ -10,6 +10,10 @@ substitutions:
# Override timezone if needed (defaults to Europe/Warsaw from regional template)
timezone: "Europe/Vienna" # Austrian timezone
# My QNAP NAS acts as a slave and forces these settings
nut_password: "" # disable nutpassword
nut_ups_name: "qnapups" # Custom name for NUT protocol (different from component ID)
esphome:
name: "${name}"
friendly_name: "${friendly_name}"
+8 -8
View File
@@ -9,7 +9,7 @@ substitutions:
nut_username: "nutuser" # Username for authentication
nut_password: "nutpass" # Password (leave empty to disable auth)
nut_max_clients: "4" # Maximum simultaneous clients (1-10)
# UPS name is now automatically derived from the ups_hid component ID
nut_ups_name: "ups_monitor" # NUT protocol UPS name (optional, defaults to component ID)
# Network Configuration (static IP recommended for servers)
use_static_ip: "false" # Set to "true" to enable static IP
@@ -20,12 +20,12 @@ substitutions:
# NUT Server Component
nut_server:
ups_hid_id: ups_monitor
ups_hid_id: ups_monitor # UPS HID component ID (fixed)
port: ${nut_port}
username: "${nut_username}"
password: "${nut_password}"
max_clients: ${nut_max_clients}
# UPS name is automatically derived from ups_hid component ID (ups_monitor)
ups_name: "${nut_ups_name}" # Custom NUT protocol name (optional)
# Static IP configuration (uncomment to enable)
# Recommended for NUT server to ensure consistent network access
@@ -72,7 +72,7 @@ text_sensor:
id: nut_server_info
icon: "mdi:information-outline"
lambda: |-
std::string info = "UPS: ups_monitor, Port: ${nut_port}";
std::string info = "UPS: ${nut_ups_name}, Port: ${nut_port}";
if (std::string("${nut_password}").empty()) {
info += ", Auth: Disabled";
} else {
@@ -109,12 +109,12 @@ interval:
# Connect with NUT client tools:
#
# 1. Using upsc command:
# upsc ups_monitor@<esp32_ip>:${nut_port}
# upsc -u ${nut_username} -p ${nut_password} ups_monitor@<esp32_ip>:${nut_port}
# upsc ${nut_ups_name}@<esp32_ip>:${nut_port}
# upsc -u ${nut_username} -p ${nut_password} ${nut_ups_name}@<esp32_ip>:${nut_port}
#
# 2. Using telnet for testing:
# telnet <esp32_ip> ${nut_port}
# Commands: HELP, VERSION, LOGIN ${nut_username} ${nut_password}, LIST UPS, LIST VAR ups_monitor
# Commands: HELP, VERSION, LOGIN ${nut_username} ${nut_password}, LIST UPS, LIST VAR ${nut_ups_name}
#
# 3. Home Assistant NUT integration:
# sensor:
@@ -135,7 +135,7 @@ interval:
# sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# sock.connect(('<esp32_ip>', ${nut_port}))
# sock.send(b"LOGIN ${nut_username} ${nut_password}\n")
# sock.send(b"LIST VAR ups_monitor\n")
# sock.send(b"LIST VAR ${nut_ups_name}\n")
# response = sock.recv(4096).decode()
# print(response)
# sock.close()
+8 -8
View File
@@ -9,7 +9,7 @@ substitutions:
nut_username: "nutuser" # Username for authentication
nut_password: "nutpass" # Password (leave empty to disable auth)
nut_max_clients: "4" # Maximum simultaneous clients (1-10)
# UPS name is now automatically derived from the ups_hid component ID
nut_ups_name: "ups_monitor" # NUT protocol UPS name (optional, defaults to component ID)
# Network Configuration (static IP recommended for servers)
use_static_ip: "false" # Set to "true" to enable static IP
@@ -25,7 +25,7 @@ nut_server:
username: "${nut_username}"
password: "${nut_password}"
max_clients: ${nut_max_clients}
# UPS name is automatically derived from ups_hid component ID (ups_monitor)
ups_name: "${nut_ups_name}" # Custom NUT protocol name (optional)
# Static IP configuration (uncomment to enable)
# Recommended for NUT server to ensure consistent network access
@@ -80,7 +80,7 @@ text_sensor:
sorting_group_id: nut_server_group
sorting_weight: 2
lambda: |-
std::string info = "UPS: ups_monitor, Port: ${nut_port}";
std::string info = "UPS: ${nut_ups_name}, Port: ${nut_port}";
if (std::string("${nut_password}").empty()) {
info += ", Auth: Disabled";
} else {
@@ -100,7 +100,7 @@ text_sensor:
sorting_weight: 3
lambda: |-
// Provide ready-to-use connection string for clients
return "ups_monitor@" + WiFi.localIP().toString().c_str() + ":${nut_port}";
return "${nut_ups_name}@" + WiFi.localIP().toString().c_str() + ":${nut_port}";
sensor:
# NUT server connected clients counter (future feature placeholder)
@@ -157,12 +157,12 @@ interval:
# Connect with NUT client tools:
#
# 1. Using upsc command:
# upsc ups_monitor@<esp32_ip>:${nut_port}
# upsc -u ${nut_username} -p ${nut_password} ups_monitor@<esp32_ip>:${nut_port}
# upsc ${nut_ups_name}@<esp32_ip>:${nut_port}
# upsc -u ${nut_username} -p ${nut_password} ${nut_ups_name}@<esp32_ip>:${nut_port}
#
# 2. Using telnet for testing:
# telnet <esp32_ip> ${nut_port}
# Commands: HELP, VERSION, LOGIN ${nut_username} ${nut_password}, LIST UPS, LIST VAR ups_monitor
# Commands: HELP, VERSION, LOGIN ${nut_username} ${nut_password}, LIST UPS, LIST VAR ${nut_ups_name}
#
# 3. Home Assistant NUT integration:
# sensor:
@@ -183,7 +183,7 @@ interval:
# sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# sock.connect(('<esp32_ip>', ${nut_port}))
# sock.send(b"LOGIN ${nut_username} ${nut_password}\n")
# sock.send(b"LIST VAR ups_monitor\n")
# sock.send(b"LIST VAR ${nut_ups_name}\n")
# response = sock.recv(4096).decode()
# print(response)
# sock.close()