esphome device updates

This commit is contained in:
root
2025-09-20 15:18:46 +12:00
parent a27b79fbd9
commit 1e1d0571d9
32 changed files with 3756 additions and 1188 deletions
+39 -39
View File
@@ -1,8 +1,8 @@
substitutions:
##############################################
############################################################################################
# SPECIFIC DEVICE VARIABLE SUBSTITUTIONS
# If NOT using a secrets file, just replace these with the passwords etc (in quotes)
#############################################
###########################################################################################
wifi_ssid: !secret ha_wifi_ssid
wifi_password: !secret ha_wifi_password
fallback_ap_password: !secret fallback_ap_password
@@ -30,7 +30,7 @@ substitutions:
base_interval_hours: "23" # Base interval in hours
random_offset_max_minutes: "59" # Max random offset in minutes
#############################################
###########################################################################################
# Common Wifi Settings
# https://esphome.io/components/wifi.html
#
@@ -38,13 +38,13 @@ substitutions:
# NONE (least power saving, Default for ESP8266)
# LIGHT (Default for ESP32)
# HIGH (most power saving)
#############################################
###########################################################################################
wifi:
ssid: ${wifi_ssid}
password: ${wifi_password}
#enable_rrm: true # (ESP32 only) enable 802.11k Radio Resource Management
#enable_btm: true # (ESP32 only) enable 802.11v BSS Transition Management
#power_save_mode: LIGHT # https://esphome.io/components/wifi.html#wifi-power-save-mode
power_save_mode: none # https://esphome.io/components/wifi.html#wifi-power-save-mode
manual_ip: # optional static IP address
static_ip: ${local_static_ip_address}
gateway: ${static_ip_gateway}
@@ -63,60 +63,60 @@ wifi:
#captive_portal: # extra fallback mechanism for when connecting if the configured WiFi fails
#############################################
###########################################################################################
# Enable Over the Air Update Capability
# https://esphome.io/components/ota.html?highlight=ota
#############################################
###########################################################################################
ota:
- platform: esphome
password: ${local_ota_pass}
version: 2
#- platform: web_server # Uncomment if you want to be able to do OTA with the web interface
#############################################
###########################################################################################
# Safe Mode
# Safe mode will detect boot loops
# https://esphome.io/components/safe_mode
#############################################
###########################################################################################
safe_mode:
#############################################
###########################################################################################
# Network
# global configuration for all types of networks
# https://esphome.io/components/network.html
#############################################
###########################################################################################
network:
enable_ipv6: ${ipv6_enable}
#############################################
##########################################################################################
# Interval
# Restart Networking every x hours + rand mins
# This ensure that the device is connected to the best AP
#############################################
script:
- id: random_reconnect
mode: restart
then:
- lambda: |-
// Compute total delay: base hours + random offset minutes
uint32_t extra;
#if defined(ESP32)
// ESP32 (both Arduino & IDF builds) uses esp_random()
extra = esp_random() % (${random_offset_max_minutes} + 1);
#elif defined(ESP8266)
// ESP8266 Arduino core
extra = os_random() % (${random_offset_max_minutes} + 1);
#else
// Fallback to esp_random() on other platforms
extra = esp_random() % (${random_offset_max_minutes} + 1);
#endif
uint32_t total_s = ${base_interval_hours} * 3600 + extra * 60;
ESP_LOGI("random_reconnect", "Next reconnect in %u seconds", total_s);
// Delay inside lambda (blocks script execution but OK for reconnect timing)
delay(total_s * 1000);
- logger.log: "network_check: performing reconnect"
- wifi.disable: {}
- delay: 1s
- wifi.enable: {}
- script.execute: random_reconnect
##########################################################################################
#script:
# - id: random_reconnect
# mode: restart
# then:
# - lambda: |-
# // Compute total delay: base hours + random offset minutes
# uint32_t extra;
# #if defined(ESP32)
# // ESP32 (both Arduino & IDF builds) uses esp_random()
# extra = esp_random() % (${random_offset_max_minutes} + 1);
# #elif defined(ESP8266)
# // ESP8266 Arduino core
# extra = os_random() % (${random_offset_max_minutes} + 1);
# #else
# // Fallback to esp_random() on other platforms
# extra = esp_random() % (${random_offset_max_minutes} + 1);
# #endif
# uint32_t total_s = ${base_interval_hours} * 3600 + extra * 60;
# ESP_LOGI("random_reconnect", "Next reconnect in %u seconds", total_s);
# // Delay inside lambda (blocks script execution but OK for reconnect timing)
# delay(total_s * 1000);
# - logger.log: "network_check: performing reconnect"
# - wifi.disable: {}
# - delay: 1s
# - wifi.enable: {}
# - script.execute: random_reconnect