fix esphome reboots on no wifi
This commit is contained in:
+1
-1
@@ -1 +1 @@
|
||||
{"pid": 68, "version": 1, "ha_version": "2025.12.4", "start_ts": 1766303118.5575826}
|
||||
{"pid": 67, "version": 1, "ha_version": "2026.1.2", "start_ts": 1768726150.935691}
|
||||
@@ -61,6 +61,8 @@ wifi:
|
||||
# Define dns domain / suffix to add to hostname
|
||||
domain: "${dns_domain}"
|
||||
#min_auth_mode: WPA2
|
||||
# Reboot eventually when Wi-Fi is down (default is 15min)
|
||||
reboot_timeout: 56h
|
||||
|
||||
#captive_portal: # extra fallback mechanism for when connecting if the configured WiFi fails
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
############################################################################################
|
||||
# SPECIFIC DEVICE VARIABLE SUBSTITUTIONS
|
||||
# If NOT using a secrets file, just replace
|
||||
# If NOT using a secrets file, just replace
|
||||
# these with the values (in quotes)
|
||||
###########################################################################################
|
||||
substitutions:
|
||||
@@ -25,10 +25,10 @@ time:
|
||||
# Change sync interval from default 5min to 6 hours (or as set in substitutions)
|
||||
update_interval: ${sntp_update_interval}
|
||||
# Set specific sntp servers to use
|
||||
servers:
|
||||
servers:
|
||||
- "${sntp_server_1}"
|
||||
- "${sntp_server_2}"
|
||||
- "${sntp_server_3}"
|
||||
- "${sntp_server_3}"
|
||||
# Publish the time the device was last restarted
|
||||
on_time_sync:
|
||||
then:
|
||||
@@ -65,11 +65,27 @@ text_sensor:
|
||||
update_interval: "1min"
|
||||
entity_category: diagnostic
|
||||
lambda: |-
|
||||
auto time_text = id(sntp_time).now().strftime("%H:%M:%S - %d-%m-%Y");
|
||||
return { time_text };
|
||||
// If SNTP time is valid, show real time/date.
|
||||
if (id(sntp_time).now().is_valid()) {
|
||||
auto t = id(sntp_time).now().strftime("%H:%M:%S - %d-%m-%Y");
|
||||
return { t };
|
||||
}
|
||||
|
||||
// Fallback: show internal clock based on current_mins (minutes from midnight).
|
||||
// NOTE: current_mins is expected to be a global defined in the main device YAML.
|
||||
int mins = id(current_mins);
|
||||
if (mins < 0) mins = 0;
|
||||
if (mins >= 1440) mins = mins % 1440;
|
||||
|
||||
int hour = mins / 60;
|
||||
int minute = mins % 60;
|
||||
|
||||
char buff[32];
|
||||
snprintf(buff, sizeof(buff), "%02d:%02d (fallback)", hour, minute);
|
||||
return { std::string(buff) };
|
||||
|
||||
- platform: template
|
||||
name: "Time: Sync Status"
|
||||
id: time_sync
|
||||
update_interval: "1min"
|
||||
entity_category: diagnostic
|
||||
entity_category: diagnostic
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
############################################################################################
|
||||
# PACKAGE: Xmas Tree Water Warning Light
|
||||
# FILE: xmas_tree_water_warning.yaml
|
||||
#
|
||||
# PURPOSE:
|
||||
# - Monitors a water sensor.
|
||||
# - If the sensor reads FALSE (off) AND the warning light is enabled:
|
||||
# 1) Blink immediately when the sensor first goes false
|
||||
# 2) Continue blinking every 5 minutes while it remains false
|
||||
#
|
||||
# DESIGN GUARANTEE:
|
||||
# - The warning light ALWAYS ends in the same state it was in
|
||||
# before the automation started.
|
||||
#
|
||||
# IMPORTANT:
|
||||
# - Home Assistant templates cannot safely use YAML anchors inside states().
|
||||
# - If you change the entity ids below, update BOTH:
|
||||
# - the anchors, and
|
||||
# - the two template strings in conditions/action variables.
|
||||
############################################################################################
|
||||
|
||||
############################################################################################
|
||||
# VARIABLES (YAML ANCHORS) - HA SAFE CONTAINER
|
||||
# - We store anchors under a valid customize dictionary.
|
||||
# - Customizing a non-existent entity is harmless.
|
||||
############################################################################################
|
||||
homeassistant:
|
||||
customize:
|
||||
sensor.xmas_tree_package_anchors:
|
||||
water_sensor_input: &water_sensor_input binary_sensor.xmas_tree_water_x32ld_water_leak
|
||||
warning_light_output: &warning_light_output switch.spare_tuya_smart_plug_zigbee_x31sp
|
||||
|
||||
############################################################################################
|
||||
# ENABLE CONTROL
|
||||
############################################################################################
|
||||
input_boolean:
|
||||
enable_xmas_tree_warning_light:
|
||||
name: Enable Xmas Tree Warning Light
|
||||
icon: mdi:alarm-light-outline
|
||||
|
||||
############################################################################################
|
||||
# MIRRORED BINARY SENSOR (AS REQUESTED)
|
||||
############################################################################################
|
||||
template:
|
||||
- binary_sensor:
|
||||
- name: Enable Xmas Tree Warning Light
|
||||
unique_id: enable_xmas_tree_warning_light_binary_sensor
|
||||
icon: mdi:alarm-light-outline
|
||||
state: "{{ is_state('input_boolean.enable_xmas_tree_warning_light', 'on') }}"
|
||||
|
||||
############################################################################################
|
||||
# AUTOMATION: Flash warning light immediately and then every 5 minutes while sensor is FALSE
|
||||
############################################################################################
|
||||
automation:
|
||||
- id: xmas_tree_water_warning_light_flash
|
||||
alias: "Xmas Tree - Water Warning Light Flash"
|
||||
description: >
|
||||
If enabled and the water sensor reads false (off), blink immediately on transition
|
||||
to false, and also every 5 minutes while it stays false.
|
||||
mode: single
|
||||
trigger:
|
||||
# Immediate blink when the water sensor transitions to FALSE (off)
|
||||
- platform: state
|
||||
entity_id: *water_sensor_input
|
||||
to: "off"
|
||||
|
||||
# Repeat reminder every 5 minutes while condition remains true
|
||||
- platform: time_pattern
|
||||
minutes: "/5"
|
||||
|
||||
condition:
|
||||
# Only run if the warning feature is enabled
|
||||
- condition: state
|
||||
entity_id: input_boolean.enable_xmas_tree_warning_light
|
||||
state: "on"
|
||||
|
||||
# Only run if water sensor is FALSE (off) and valid
|
||||
- condition: template
|
||||
value_template: "{{ states('binary_sensor.xmas_tree_water_x32ld_water_leak') == 'off' }}"
|
||||
|
||||
# Only run if warning light output is available
|
||||
- condition: template
|
||||
value_template: "{{ states('switch.spare_tuya_smart_plug_zigbee_x31sp') not in ['unknown','unavailable'] }}"
|
||||
|
||||
action:
|
||||
# Capture original state so we can restore it at the end
|
||||
- variables:
|
||||
original_state: "{{ states('switch.spare_tuya_smart_plug_zigbee_x31sp') }}"
|
||||
|
||||
# Blink pattern:
|
||||
# - Toggle for 1 second
|
||||
# - Toggle back for 1 second
|
||||
# - Repeat 5 times
|
||||
- repeat:
|
||||
count: 5
|
||||
sequence:
|
||||
- service: homeassistant.toggle
|
||||
target:
|
||||
entity_id: *warning_light_output
|
||||
- delay:
|
||||
seconds: 1
|
||||
- service: homeassistant.toggle
|
||||
target:
|
||||
entity_id: *warning_light_output
|
||||
- delay:
|
||||
seconds: 1
|
||||
|
||||
# Restore the original state explicitly
|
||||
- choose:
|
||||
- conditions:
|
||||
- condition: template
|
||||
value_template: "{{ original_state == 'on' }}"
|
||||
sequence:
|
||||
- service: homeassistant.turn_on
|
||||
target:
|
||||
entity_id: *warning_light_output
|
||||
default:
|
||||
- service: homeassistant.turn_off
|
||||
target:
|
||||
entity_id: *warning_light_output
|
||||
Reference in New Issue
Block a user