multiple esphome device updates and new devices
This commit is contained in:
@@ -78,24 +78,27 @@ substitutions:
|
||||
evening_on_default: "1260" # Default in minutes from midnight. Default 21:00 => 1260
|
||||
evening_off_default: "1439" # Default in minutes from midnight. Default 23:59 => 1439 => 1440 is midnight
|
||||
|
||||
#############################################
|
||||
# Included Common Packages
|
||||
# https://esphome.io/components/esphome.html
|
||||
#############################################
|
||||
##########################################################################################
|
||||
# PACKAGES: Included Common Packages
|
||||
# https://esphome.io/components/packages.html
|
||||
##########################################################################################
|
||||
packages:
|
||||
common_wifi: !include
|
||||
file: common/network_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
local_static_ip_address: "${static_ip_address}"
|
||||
local_ota_pass: "${ota_pass}"
|
||||
common_api: !include
|
||||
file: common/api_common.yaml
|
||||
vars:
|
||||
local_api_key: "${api_key}"
|
||||
common_webportal: !include
|
||||
file: common/webportal_common.yaml
|
||||
#common_webportal: !include
|
||||
# file: common/webportal_common.yaml
|
||||
common_mqtt: !include
|
||||
file: common/mqtt_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
common_sntp: !include
|
||||
file: common/sntp_common.yaml
|
||||
common_general_sensors: !include
|
||||
@@ -122,6 +125,8 @@ esphome:
|
||||
on_boot:
|
||||
priority: 900 # High priority to run after globals are initialized
|
||||
then:
|
||||
# This evaluates if we switch on 4+ times in 20 seconds
|
||||
# If so, just change to on mode permanently.
|
||||
- lambda: |-
|
||||
// 1) Figure out the current time in "seconds from midnight"
|
||||
// using SNTP if available, otherwise current_mins * 60.
|
||||
@@ -159,6 +164,7 @@ esphome:
|
||||
id(boost_timer) = 0; // and reset boost_timer = 0 (for time sync if no sntp)
|
||||
ESP_LOGI("power_cycle", "Boot count=%d => BOOST mode", id(boot_count));
|
||||
}
|
||||
- script.execute: evaluate_relay_state # Check what the relay should be doing straight away
|
||||
|
||||
#############################################
|
||||
# ESP Platform and Framework
|
||||
@@ -166,7 +172,7 @@ esphome:
|
||||
#############################################
|
||||
esp8266:
|
||||
board: esp01_1m # The original sonoff basic
|
||||
restore_from_flash: True # restore some values on reboot
|
||||
restore_from_flash: true # restore some values on reboot
|
||||
|
||||
preferences:
|
||||
flash_write_interval: 5min
|
||||
@@ -218,31 +224,31 @@ globals:
|
||||
# Morning On time (minutes from midnight),
|
||||
- id: morning_on
|
||||
type: int
|
||||
restore_value: False
|
||||
restore_value: true
|
||||
initial_value: "${morning_on_default}"
|
||||
|
||||
# Morning Off time (minutes from midnight),
|
||||
- id: morning_off
|
||||
type: int
|
||||
restore_value: False
|
||||
restore_value: true
|
||||
initial_value: "${morning_off_default}"
|
||||
|
||||
# Evening On time (minutes from midnight),
|
||||
- id: evening_on
|
||||
type: int
|
||||
restore_value: False
|
||||
restore_value: true
|
||||
initial_value: "${evening_on_default}"
|
||||
|
||||
# Evening Off time (minutes from midnight),
|
||||
- id: evening_off
|
||||
type: int
|
||||
restore_value: False
|
||||
restore_value: true
|
||||
initial_value: "${evening_off_default}"
|
||||
|
||||
# Boost Duration (minutes),
|
||||
- id: boost_duration
|
||||
type: int
|
||||
restore_value: False
|
||||
restore_value: true
|
||||
initial_value: "${boost_duration_default}"
|
||||
|
||||
####################################################
|
||||
@@ -254,14 +260,13 @@ globals:
|
||||
####################################################
|
||||
- id: operation_mode
|
||||
type: int
|
||||
restore_value: false
|
||||
restore_value: true
|
||||
initial_value: "2"
|
||||
|
||||
####################################################
|
||||
# current_mins is set if SNTP is invalid.
|
||||
# We assume user powers on the device at 12:00 noon
|
||||
# => 12 * 60 = 720 minutes from midnight.
|
||||
# Not restored, so it resets each boot.
|
||||
####################################################
|
||||
- id: current_mins
|
||||
type: int
|
||||
@@ -602,6 +607,23 @@ button:
|
||||
id(operation_mode) = 3;
|
||||
# 2) immediately re-evaluate relay state
|
||||
- script.execute: evaluate_relay_state
|
||||
- platform: template
|
||||
name: "Default timer settings"
|
||||
id: default_timer_settings_button
|
||||
icon: "mdi:restore"
|
||||
on_press:
|
||||
- lambda: |-
|
||||
// Restore all timing globals to their YAML defaults
|
||||
id(morning_on) = ${morning_on_default};
|
||||
id(morning_off) = ${morning_off_default};
|
||||
id(evening_on) = ${evening_on_default};
|
||||
id(evening_off) = ${evening_off_default};
|
||||
id(boost_duration)= ${boost_duration_default};
|
||||
// Reset mode to TIMER and clear any running boost
|
||||
id(operation_mode)= 2;
|
||||
id(boost_timer) = 0;
|
||||
ESP_LOGI("timer","Default timer settings applied");
|
||||
- script.execute: evaluate_relay_state
|
||||
|
||||
#################################################################################################
|
||||
# SELECT COMPONENT
|
||||
|
Reference in New Issue
Block a user