esphome sntp offline fixes
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
# MASTER BATHROOM HEATED TOWEL RAIL
|
||||
# Controlled by a Sonoff Basic
|
||||
#
|
||||
# V2.2 2025-06-14 Fixes to offline time when sntp/network unavailable
|
||||
# V2.1 2025-06-12 Added select and button to chose modes, added countdown & startup to boost
|
||||
# V2.0 2025-06-05 YAML Tidyups
|
||||
# V1.1 2025-04-12 Fixes to timers and offline modes
|
||||
@@ -35,6 +36,12 @@
|
||||
# mqtt_timer_topic/operation/TIMER : Device will obey timer settings
|
||||
# mqtt_timer_topic/operation/BOOST : Turn on for (boost_duration) minutes then BOOST (also on startup)
|
||||
#
|
||||
# operation_mode:
|
||||
# 0 = OFF
|
||||
# 1 = ON
|
||||
# 2 = TIMER
|
||||
# 3 = BOOST
|
||||
#
|
||||
##########################################################################################
|
||||
##########################################################################################
|
||||
|
||||
@@ -68,7 +75,7 @@ substitutions:
|
||||
morning_on_default: "300" # Default in minutes from midnight. Default 05:00 => 300
|
||||
morning_off_default: "420" # Default in minutes from midnight. Default 07:00 => 420
|
||||
evening_on_default: "1260" # Default in minutes from midnight. Default 21:00 => 1260
|
||||
evening_off_default: "1440" # Default in minutes from midnight. Default 24:00 => 1440 => 1440 is midnight
|
||||
evening_off_default: "1439" # Default in minutes from midnight. Default 23:59 => 1439 => 1440 is midnight
|
||||
|
||||
#############################################
|
||||
# Included Common Packages
|
||||
@@ -596,23 +603,14 @@ interval:
|
||||
- interval: "1min" # Must be 1min as this is used to calculate times
|
||||
then:
|
||||
- lambda: |-
|
||||
|
||||
// Do we have correct time from SNTP? If not...
|
||||
if (!id(time_sync).has_state()) {
|
||||
// Set minutes since midnight
|
||||
id(current_mins) = id(current_mins) +1 ;
|
||||
|
||||
// wrap around at 1440 => next day
|
||||
if (id(current_mins) >= 1440) {
|
||||
id(current_mins) = 0;
|
||||
}
|
||||
|
||||
// If we do have proper SNMP time...
|
||||
if (!id(sntp_time).now().is_valid()) {
|
||||
id(current_mins) += 1;
|
||||
if (id(current_mins) >= 1440) id(current_mins) = 0;
|
||||
} else {
|
||||
// Use real time from SNTP
|
||||
auto now = id(sntp_time).now();
|
||||
id(current_mins) = now.hour * 60 + now.minute;
|
||||
}
|
||||
auto now = id(sntp_time).now();
|
||||
id(current_mins) = now.hour * 60 + now.minute;
|
||||
}
|
||||
|
||||
// operation_mode:
|
||||
// 0 = OFF
|
||||
|
Reference in New Issue
Block a user