esphome sntp offline fixes
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
# DOWNSTAIRS 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
|
||||
#
|
||||
##########################################################################################
|
||||
##########################################################################################
|
||||
|
||||
@@ -46,12 +53,12 @@ substitutions:
|
||||
# Device Naming
|
||||
device_name: "esp-downstbathtowelrail"
|
||||
friendly_name: "Downstairs Bathroom Towelrail"
|
||||
description_comment: "Sonoff Basic controlling ON/OFF/Timer for the Heated Towel Rail in the Downstairs Bathroom"
|
||||
description_comment: "Heated Towel Rail, Downstairs Bathroom :: Sonoff Basic"
|
||||
device_area: "Downstairs Bathroom" # Allows ESP device to be automatically linked to an 'Area' in Home Assistant.
|
||||
|
||||
# Project Naming
|
||||
project_name: "Sonoff Technologies.Sonoff Basic V1" # Project Details
|
||||
project_version: "v2.1" # Project V denotes release of yaml file, allowing checking of deployed vs latest version
|
||||
project_version: "v2.2" # Project V denotes release of yaml file, allowing checking of deployed vs latest version
|
||||
|
||||
# Passwords
|
||||
api_key: !secret esp-api_key # unfortunately you can't use substitutions inside secrets names
|
||||
@@ -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