laundry esphome migration
This commit is contained in:
8
esphome/common/api_common.yaml
Normal file
8
esphome/common/api_common.yaml
Normal file
@@ -0,0 +1,8 @@
|
||||
#############################################
|
||||
# Enable the Home Assistant API
|
||||
# https://esphome.io/components/api.html
|
||||
#############################################
|
||||
api:
|
||||
encryption:
|
||||
key: ${local_api_key}
|
||||
|
205
esphome/common/esp-generic-startfile.yaml.trmp
Normal file
205
esphome/common/esp-generic-startfile.yaml.trmp
Normal file
@@ -0,0 +1,205 @@
|
||||
|
||||
# This is a generic starter yaml file for
|
||||
# espHome, by zorruno 2024
|
||||
# <DEVICENAME> would be something like loungefancontroller
|
||||
# yaml file would then be esp-loungefancontroller.yaml
|
||||
|
||||
#############################################
|
||||
#############################################
|
||||
# TITLE
|
||||
# Details of what the device is plus
|
||||
# any relevant web links
|
||||
#############################################
|
||||
#############################################
|
||||
|
||||
#############################################
|
||||
# SECRETS
|
||||
# Secrets file is usually at config/secrets.yaml
|
||||
# or config/esphome/secrets.yaml
|
||||
# depending on your setup with HA
|
||||
#############################################
|
||||
# SECRETS FILE needs these specific secrets:
|
||||
# esp-<DEVICENAME>_api_key
|
||||
# esp-<DEVICENAME>_ota_pass
|
||||
# esp-<DEVICENAME>_static_ip (Optional)
|
||||
# esp-<DEVICENAME>_gateway (Optional)
|
||||
# esp-<DEVICENAME>_subnet (Optional)
|
||||
#
|
||||
# SECRETS FILE needs these generic Secrets:
|
||||
# wifi_ssid
|
||||
# wifi_password
|
||||
# fallback_ap_password
|
||||
# mqtt_server
|
||||
# mqtt_username
|
||||
# mqtt_password
|
||||
# web_server_username (Optional)
|
||||
# web_server_password (Optional)
|
||||
#############################################
|
||||
|
||||
#############################################
|
||||
# VARIABLE SUBSTITUTIONS
|
||||
# Give the device a useful name & description here
|
||||
# and change values accordingly.
|
||||
#############################################
|
||||
substitutions:
|
||||
device_name: esp-<DEVICENAME>
|
||||
friendly_name: "Device friendly name"
|
||||
description_comment: "A Description of this device"
|
||||
|
||||
# if NOT using a secrets file, just replace these with the passwords etc (in quotes)
|
||||
api_key: !secret esp-<DEVICENAME>_api_key # unfortunately you can't use substitutions in secrets names
|
||||
ota_pass: !secret esp-<DEVICENAME>_ota_pass # unfortunately you can't use substitutions in secrets names
|
||||
wifi_ssid: !secret wifi_ssid
|
||||
wifi_password: !secret wifi_password
|
||||
fallback_ap_password: !secret fallback_ap_password
|
||||
|
||||
# Add these if we are giving it a static ip, or remove them in the Wifi section
|
||||
#static_ip_address: !secret esp-<DEVICENAME>_static_ip
|
||||
#static_ip_gateway: !secret esp-<DEVICENAME>_gateway
|
||||
#static_ip_subnet: !secret esp-<DEVICENAME>_subnet
|
||||
|
||||
mqtt_server: !secret mqtt_server
|
||||
mqtt_username: !secret mqtt_username
|
||||
mqtt_password: !secret mqtt_password
|
||||
mqtt_topic: "esphome" # main topic for the mqtt server, call it what you like
|
||||
|
||||
web_server_username: !secret web_server_username
|
||||
web_server_password: !secret web_server_password
|
||||
|
||||
update_time: 60s # update time for for general temp sensors etc
|
||||
|
||||
#############################################
|
||||
# ESPHome
|
||||
# https://esphome.io/components/esphome.html
|
||||
#############################################
|
||||
esphome:
|
||||
name: ${device_name}
|
||||
friendly_name: ${friendly_name} # appears as main name on the esphome page in HA
|
||||
comment: ${description_comment} # appears as comment on the esphome page in HA
|
||||
#min_version: 2024.6.0
|
||||
|
||||
#############################################
|
||||
# ESP Platform and Framework
|
||||
# https://esphome.io/components/esp32.html
|
||||
#############################################
|
||||
esp32:
|
||||
board: <ESP-DEVICE>
|
||||
framework:
|
||||
type: esp-idf # Suggest using the ESP-IDF Framework. Changing from 'arduino' to 'esp-idf' needs a cabled flash to correct partitions
|
||||
version: recommended # recommended, latest or dev
|
||||
|
||||
#############################################
|
||||
# ESPHome Logging Enabl
|
||||
# https://esphome.io/components/logger.html
|
||||
#############################################
|
||||
logger:
|
||||
level: INFO # INFO Level suggested, or DEBUG for testing
|
||||
#baud_rate: 0 #set to 0 for no logging via UART, needed if you are using it for other serial things (eg PZEM)
|
||||
#esp8266_store_log_strings_in_flash: false
|
||||
#tx_buffer_size: 64
|
||||
|
||||
#############################################
|
||||
# Enable the Home Assistant API
|
||||
# https://esphome.io/components/api.html
|
||||
#############################################
|
||||
api:
|
||||
encryption:
|
||||
key: ${api_key}
|
||||
|
||||
#############################################
|
||||
# Enable Over the Air Update Capability
|
||||
# https://esphome.io/components/ota.html?highlight=ota
|
||||
#############################################
|
||||
ota:
|
||||
- platform: esphome
|
||||
password: ${ota_pass}
|
||||
|
||||
#############################################
|
||||
# Safe Mode
|
||||
# Safe mode will detect boot loops
|
||||
# https://esphome.io/components/safe_mode
|
||||
#############################################
|
||||
safe_mode:
|
||||
|
||||
#############################################
|
||||
# Wifi Settings
|
||||
# https://esphome.io/components/wifi.html
|
||||
#
|
||||
# Power Save mode (can reduce wifi reliability)
|
||||
# NONE (least power saving, Default for ESP8266)
|
||||
# LIGHT (Default for ESP32)
|
||||
# HIGH (most power saving)
|
||||
#############################################
|
||||
wifi:
|
||||
ssid: ${wifi_ssid}
|
||||
password: ${wifi_password}
|
||||
#power_save_mode: LIGHT #https://esphome.io/components/wifi.html#wifi-power-save-mode
|
||||
#manual_ip: #optional static IP address
|
||||
#static_ip: ${static_ip_address}
|
||||
#gateway: ${static_ip_gateway}
|
||||
#subnet: ${static_ip_subnet}
|
||||
ap: # Details for fallback hotspot in case wifi connection fails https://esphome.io/components/wifi.html#access-point-mode
|
||||
ssid: ${device_name} fallback AP
|
||||
password: ${fallback_ap_password}
|
||||
ap_timeout: 30min # Time until it brings up fallback AP. default is 1min
|
||||
|
||||
#############################################
|
||||
# Web Portal for display and monitoring
|
||||
# Turning this off is probably a good idea to save resources.
|
||||
# https://esphome.io/components/web_server.html
|
||||
#############################################
|
||||
#web_server:
|
||||
# port: 80
|
||||
# auth:
|
||||
# username: ${web_server_username} #probably a good idea to secure it
|
||||
# password: ${web_server_password}
|
||||
|
||||
#############################################
|
||||
# MQTT Monitoring
|
||||
# https://esphome.io/components/mqtt.html?highlight=mqtt
|
||||
# MUST also have api enabled if you enable MQTT
|
||||
#############################################
|
||||
mqtt:
|
||||
broker: ${mqtt_server}
|
||||
topic_prefix: ${mqtt_topic}/${device_name}
|
||||
username: ${mqtt_username}
|
||||
password: ${mqtt_password}
|
||||
|
||||
#############################################
|
||||
# Time Component
|
||||
# https://esphome.io/components/time/index.html#time-component
|
||||
# Sync with HA Time. Probably not really necessary.
|
||||
#############################################
|
||||
#time:
|
||||
# - platform: homeassistant
|
||||
# id: homeassistant_time
|
||||
|
||||
#############################################
|
||||
# Text Sensors
|
||||
# https://esphome.io/components/text_sensor/index.html
|
||||
#############################################
|
||||
text_sensor:
|
||||
- platform: version
|
||||
name: ${friendly_name} Version
|
||||
- platform: wifi_info
|
||||
ip_address:
|
||||
name: ${friendly_name} IP Address
|
||||
|
||||
#############################################
|
||||
# General Sensors
|
||||
# https://esphome.io/components/sensor/index.html
|
||||
#############################################
|
||||
sensor:
|
||||
- platform: uptime # Uptime for this device
|
||||
name: ${friendly_name} Uptime
|
||||
update_interval: ${update_time}
|
||||
- platform: wifi_signal # Wifi Strength
|
||||
name: ${friendly_name} Wifi Signal
|
||||
update_interval: ${update_time}
|
||||
|
||||
#############################################
|
||||
# Binary Sensors
|
||||
# https://esphome.io/components/binary_sensor/index.html
|
||||
#############################################
|
||||
#binary_sensor:
|
||||
|
@@ -17,5 +17,6 @@ mqtt:
|
||||
topic_prefix: ${mqtt_topic}/${devicename}
|
||||
username: ${mqtt_username}
|
||||
password: ${mqtt_password}
|
||||
discovery: false # enable entity discovery (true is default, we don't want two HA Instances)
|
||||
discovery: False # enable entity discovery (true is default)
|
||||
discover_ip: False # enable device discovery (true is default)
|
||||
id: mqtt_client
|
||||
|
@@ -17,6 +17,9 @@ substitutions:
|
||||
# eg so you can use a single firmware for all devices
|
||||
add_mac_suffix: "false"
|
||||
|
||||
# Enable or disable the use of IPv6 networking on the device
|
||||
ipv6_enable: "false"
|
||||
|
||||
# Add these if we are giving it a static ip, or remove them in the Wifi section
|
||||
static_ip_subnet: !secret ha_wifi_subnet
|
||||
static_ip_gateway: !secret ha_wifi_gateway
|
||||
@@ -43,7 +46,7 @@ wifi:
|
||||
ap: # Details for fallback hotspot in case wifi connection fails https://esphome.io/components/wifi.html#access-point-mode
|
||||
ssid: ${devicename} AP
|
||||
password: ${fallback_ap_password}
|
||||
ap_timeout: 30min # Time until it brings up fallback AP. default is 1min
|
||||
ap_timeout: 10min # Time until it brings up fallback AP. default is 1min
|
||||
# Allow rapid re-connection to previously connect WiFi SSID, skipping scan of all SSID
|
||||
fast_connect: "${wifi_fast_connect}"
|
||||
# Define dns domain / suffix to add to hostname
|
||||
@@ -51,14 +54,6 @@ wifi:
|
||||
|
||||
captive_portal: # extra fallback mechanism for when connecting if the configured WiFi fails
|
||||
|
||||
#############################################
|
||||
# Enable the Home Assistant API
|
||||
# https://esphome.io/components/api.html
|
||||
#############################################
|
||||
api:
|
||||
encryption:
|
||||
key: ${local_api_key}
|
||||
|
||||
#############################################
|
||||
# Enable Over the Air Update Capability
|
||||
# https://esphome.io/components/ota.html?highlight=ota
|
||||
@@ -73,3 +68,11 @@ ota:
|
||||
# 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}
|
@@ -1,76 +0,0 @@
|
||||
#substitutions:
|
||||
# local_gpioinvert: "True"
|
||||
# local_singleclick_duration: "300000" # 5 minutes in ms
|
||||
# local_doubleclick_duration: "1800000" # 30 minutes in ms
|
||||
# local_tripleclick_duration: "7200000" # 2 hours in ms
|
||||
|
||||
#globals:
|
||||
# - id: single_click_delay
|
||||
# type: long
|
||||
# restore_value: no
|
||||
# initial_value: ${local_singleclick_duration}
|
||||
# - id: double_click_delay
|
||||
# type: long
|
||||
# restore_value: no
|
||||
# initial_value: ${local_doubleclick_duration}
|
||||
# - id: triple_click_delay
|
||||
# type: long
|
||||
# restore_value: no
|
||||
# initial_value: ${local_tripleclick_duration}
|
||||
|
||||
binary_sensor:
|
||||
- platform: gpio
|
||||
pin:
|
||||
number: ${local_gpio}
|
||||
mode: INPUT
|
||||
inverted: True
|
||||
name: ${local_name}
|
||||
on_multi_click:
|
||||
# Single Click: one press (short press/release)
|
||||
- timing:
|
||||
- ON for at most 1s
|
||||
- OFF for at least 0.5s
|
||||
then:
|
||||
- lambda: |-
|
||||
if (id(local_relay_id).state) {
|
||||
ESP_LOGD(id(local_gpio},"Single click: ",id(local_relay_id)," is on, turning it off.");
|
||||
id(local_relay_id).turn_off();
|
||||
} else {
|
||||
ESP_LOGD(id(local_gpio), "Single click: ",id(local_relay_id)," is off, turning it on for %d ms.", id(local_singleclick_duraton));
|
||||
id(local_relay_id).turn_on();
|
||||
delay(id(local_singleclick_duration));
|
||||
id(local_relay_id).turn_off();
|
||||
}
|
||||
# Double Click: two quick press/release cycles
|
||||
- timing:
|
||||
- ON for at most 1s
|
||||
- OFF for at most 1s
|
||||
- ON for at most 1s
|
||||
- OFF for at least 0.5s
|
||||
then:
|
||||
- lambda: |-
|
||||
ESP_LOGD(id(local_gpio), "Double click detected: turning ",id(local_relay_id)," on for %d ms.", id(local_doubleclick_duration));
|
||||
id(local_relay_id).turn_on();
|
||||
delay(id(local_doubleclick_duration));
|
||||
id(local_relay_id).turn_off();
|
||||
# Triple Click: three quick press/release cycles
|
||||
- timing:
|
||||
- ON for at most 1s
|
||||
- OFF for at most 1s
|
||||
- ON for at most 1s
|
||||
- OFF for at most 1s
|
||||
- ON for at most 1s
|
||||
- OFF for at least 0.5s
|
||||
then:
|
||||
- lambda: |-
|
||||
ESP_LOGD(id(local_gpio), "Triple click detected: turning ",id(local_relay_id)," on for %d ms.", id(local_tripleclick_duration));
|
||||
id(local_relay_id).turn_on();
|
||||
delay(id(local_tripleclick_duration));
|
||||
id(local_relay_id).turn_off();
|
||||
# Hold: button held for at least 4 seconds
|
||||
- timing:
|
||||
- ON for at least 4s
|
||||
then:
|
||||
- lambda: |-
|
||||
ESP_LOGD(id(local_gpio), "Hold detected: turning ",id(local_relay_id)," on indefinitely.");
|
||||
id(local_relay_id).turn_on();
|
@@ -1,76 +0,0 @@
|
||||
defaults:
|
||||
local_gpioinvert: "True"
|
||||
local_singleclick_duration: "300000" # 5 minutes in ms
|
||||
local_doubleclick_duration: "1800000" # 30 minutes in ms
|
||||
local_tripleclick_duration: "7200000" # 2 hours in ms
|
||||
|
||||
#globals:
|
||||
# - id: single_click_delay
|
||||
# type: long
|
||||
# restore_value: no
|
||||
# initial_value: ${local_singleclick_duration}
|
||||
# - id: double_click_delay
|
||||
# type: long
|
||||
# restore_value: no
|
||||
# initial_value: ${local_doubleclick_duration}
|
||||
# - id: triple_click_delay
|
||||
# type: long
|
||||
# restore_value: no
|
||||
# initial_value: ${local_tripleclick_duration}
|
||||
|
||||
binary_sensor:
|
||||
- platform: gpio
|
||||
pin:
|
||||
number: ${local_gpio}
|
||||
mode: INPUT
|
||||
inverted: ${local_gpioinvert}
|
||||
name: ${local_name}
|
||||
on_multi_click:
|
||||
# Single Click: one press (short press/release)
|
||||
- timing:
|
||||
- ON for at most 1s
|
||||
- OFF for at least 0.5s
|
||||
then:
|
||||
- lambda: |-
|
||||
if (id(${local_relay_id}).state) {
|
||||
ESP_LOGD("${local_gpio}", "Single click: ${local_relay_id} is on, turning it off.");
|
||||
id(${local_relay_id}).turn_off();
|
||||
} else {
|
||||
ESP_LOGD("${local_gpio}", "Single click: ${local_relay_id} is off, turning it on for %d ms.", id(single_click_delay));
|
||||
id(${local_relay_id}).turn_on();
|
||||
delay(id(single_click_delay));
|
||||
id(${local_relay_id}).turn_off();
|
||||
}
|
||||
# Double Click: two quick press/release cycles
|
||||
- timing:
|
||||
- ON for at most 1s
|
||||
- OFF for at most 1s
|
||||
- ON for at most 1s
|
||||
- OFF for at least 0.5s
|
||||
then:
|
||||
- lambda: |-
|
||||
ESP_LOGD(${local_gpio}, "Double click detected: turning ",${local_relay_id}," on for %d ms.", id(double_click_delay));
|
||||
id(${local_relay_id}).turn_on();
|
||||
delay(id(double_click_delay));
|
||||
id(${local_relay_id}).turn_off();
|
||||
# Triple Click: three quick press/release cycles
|
||||
- timing:
|
||||
- ON for at most 1s
|
||||
- OFF for at most 1s
|
||||
- ON for at most 1s
|
||||
- OFF for at most 1s
|
||||
- ON for at most 1s
|
||||
- OFF for at least 0.5s
|
||||
then:
|
||||
- lambda: |-
|
||||
ESP_LOGD(${local_gpio}, "Triple click detected: turning ",${local_relay_id}," on for %d ms.", id(triple_click_delay));
|
||||
id(${local_relay_id}).turn_on();
|
||||
delay(id(triple_click_delay));
|
||||
id(${local_relay_id}).turn_off();
|
||||
# Hold: button held for at least 4 seconds
|
||||
- timing:
|
||||
- ON for at least 4s
|
||||
then:
|
||||
- lambda: |-
|
||||
ESP_LOGD(${local_gpio}, "Hold detected (threshold %d ms): turning ",${local_relay_id}," on indefinitely.");
|
||||
id(${local_relay_id}).turn_on();
|
111
esphome/common/sensors_common copy.yaml
Normal file
111
esphome/common/sensors_common copy.yaml
Normal file
@@ -0,0 +1,111 @@
|
||||
#############################################
|
||||
# GENERAL COMMON SENSORS
|
||||
# https://esphome.io/components/sensor/
|
||||
#############################################
|
||||
sensor:
|
||||
- platform: uptime # Uptime for this device in seconds
|
||||
name: "Uptime (s):"
|
||||
update_interval: ${local_update_interval}
|
||||
id: uptime_sensor
|
||||
entity_category: "diagnostic"
|
||||
- platform: wifi_signal # Wifi Strength
|
||||
name: "Wifi (dB):"
|
||||
id: wifi_signal_db
|
||||
update_interval: ${local_update_interval}
|
||||
entity_category: "diagnostic"
|
||||
- platform: copy # Reports the WiFi signal strength in %
|
||||
source_id: wifi_signal_db
|
||||
name: "WiFi (%):"
|
||||
filters:
|
||||
- lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
|
||||
unit_of_measurement: "% Max"
|
||||
entity_category: "diagnostic"
|
||||
device_class: ""
|
||||
|
||||
binary_sensor:
|
||||
- platform: status
|
||||
name: "Network Status"
|
||||
icon: mdi:check-network-outline
|
||||
entity_category: diagnostic
|
||||
|
||||
#############################################
|
||||
# Text Sensors
|
||||
# https://esphome.io/components/text_sensor/index.html
|
||||
#############################################
|
||||
text_sensor:
|
||||
######################################################
|
||||
# General ESPHome Info
|
||||
######################################################
|
||||
- platform: version
|
||||
name: "Version:"
|
||||
entity_category: "diagnostic"
|
||||
- platform: wifi_info
|
||||
ip_address:
|
||||
icon: mdi:ip-network
|
||||
entity_category: diagnostic
|
||||
name: "IP Address:"
|
||||
ssid:
|
||||
name: "Connected SSID"
|
||||
icon: mdi:wifi-strength-2
|
||||
entity_category: diagnostic
|
||||
mac_address:
|
||||
name: "MAC Address:"
|
||||
icon: mdi:network-pos
|
||||
entity_category: diagnostic
|
||||
- platform: uptime # Uptime for this device human readable
|
||||
name: "Uptime:"
|
||||
icon: mdi:clock-start
|
||||
update_interval: ${local_update_interval}
|
||||
entity_category: "diagnostic"
|
||||
|
||||
|
||||
######################################################
|
||||
# Creates a sensor showing when the device was last restarted
|
||||
# Uptime template sensor, and SNTP are needed
|
||||
######################################################
|
||||
#- platform: template
|
||||
# name: ${local_friendly_name} Last Restart
|
||||
# id: device_last_restart
|
||||
# icon: mdi:clock
|
||||
# entity_category: diagnostic
|
||||
# #device_class: timestamp
|
||||
|
||||
######################################################
|
||||
# Creates a sensor of the uptime of the device, in formatted days, hours, minutes and seconds
|
||||
######################################################
|
||||
- platform: template
|
||||
name: "Uptime (Days)"
|
||||
entity_category: diagnostic
|
||||
lambda: |-
|
||||
int seconds = (id(uptime_sensor).state);
|
||||
int days = seconds / (24 * 3600);
|
||||
seconds = seconds % (24 * 3600);
|
||||
int hours = seconds / 3600;
|
||||
seconds = seconds % 3600;
|
||||
int minutes = seconds / 60;
|
||||
seconds = seconds % 60;
|
||||
if ( days > 3650 ) {
|
||||
return { "Starting up" };
|
||||
} else if ( days ) {
|
||||
return { (String(days) +"d " + String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
|
||||
} else if ( hours ) {
|
||||
return { (String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
|
||||
} else if ( minutes ) {
|
||||
return { (String(minutes) +"m "+ String(seconds) +"s").c_str() };
|
||||
} else {
|
||||
return { (String(seconds) +"s").c_str() };
|
||||
}
|
||||
icon: mdi:clock-start
|
||||
|
||||
button:
|
||||
- platform: safe_mode
|
||||
name: "Safe Mode Restart: ${local_friendly_name}"
|
||||
entity_category: "diagnostic"
|
||||
- platform: restart
|
||||
name: "Restart: ${local_friendly_name}"
|
||||
entity_category: "diagnostic"
|
||||
disabled_by_default: true
|
||||
- platform: factory_reset
|
||||
name: "FACTORY RESET: ${local_friendly_name}"
|
||||
entity_category: "diagnostic"
|
||||
disabled_by_default: true
|
@@ -4,24 +4,30 @@
|
||||
#############################################
|
||||
sensor:
|
||||
- platform: uptime # Uptime for this device in seconds
|
||||
name: "Uptime (s): ${local_friendly_name}"
|
||||
name: "Uptime (s):"
|
||||
update_interval: ${local_update_interval}
|
||||
id: uptime_sensor
|
||||
entity_category: "diagnostic"
|
||||
- platform: wifi_signal # Wifi Strength
|
||||
name: "Wifi dB: ${local_friendly_name}"
|
||||
name: "Wifi (dB):"
|
||||
id: wifi_signal_db
|
||||
update_interval: ${local_update_interval}
|
||||
entity_category: "diagnostic"
|
||||
- platform: copy # Reports the WiFi signal strength in %
|
||||
source_id: wifi_signal_db
|
||||
name: "WiFi Percent: ${local_friendly_name}"
|
||||
name: "WiFi (%):"
|
||||
filters:
|
||||
- lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
|
||||
unit_of_measurement: "% Max"
|
||||
entity_category: "diagnostic"
|
||||
device_class: ""
|
||||
|
||||
binary_sensor:
|
||||
- platform: status
|
||||
name: "Network Status"
|
||||
icon: mdi:check-network-outline
|
||||
entity_category: diagnostic
|
||||
|
||||
#############################################
|
||||
# Text Sensors
|
||||
# https://esphome.io/components/text_sensor/index.html
|
||||
@@ -31,66 +37,88 @@ text_sensor:
|
||||
# General ESPHome Info
|
||||
######################################################
|
||||
- platform: version
|
||||
name: "Version: ${local_friendly_name}"
|
||||
name: "Version:"
|
||||
entity_category: "diagnostic"
|
||||
|
||||
- platform: wifi_info
|
||||
ip_address:
|
||||
name: "IP Address: ${local_friendly_name}"
|
||||
|
||||
icon: mdi:ip-network
|
||||
entity_category: diagnostic
|
||||
name: "IP Address:"
|
||||
ssid:
|
||||
name: "Connected SSID"
|
||||
icon: mdi:wifi-strength-2
|
||||
entity_category: diagnostic
|
||||
mac_address:
|
||||
name: "MAC Address:"
|
||||
icon: mdi:network-pos
|
||||
entity_category: diagnostic
|
||||
- platform: uptime # Uptime for this device human readable
|
||||
name: "Uptime: ${local_friendly_name}"
|
||||
name: "Uptime:"
|
||||
icon: mdi:clock-start
|
||||
update_interval: ${local_update_interval}
|
||||
entity_category: "diagnostic"
|
||||
|
||||
######################################################
|
||||
# Creates a sensor showing when the device was last restarted
|
||||
# Uptime template sensor, and SNTP are needed
|
||||
######################################################
|
||||
#- platform: template
|
||||
# name: ${local_friendly_name} Last Restart
|
||||
# id: device_last_restart
|
||||
# icon: mdi:clock
|
||||
# entity_category: diagnostic
|
||||
# #device_class: timestamp
|
||||
|
||||
######################################################
|
||||
# Creates a sensor of the uptime of the device, in formatted days, hours, minutes and seconds
|
||||
######################################################
|
||||
#- platform: template
|
||||
# name: "Uptime"
|
||||
# entity_category: diagnostic
|
||||
# lambda: |-
|
||||
# int seconds = (id(uptime_sensor).state);
|
||||
# int days = seconds / (24 * 3600);
|
||||
# seconds = seconds % (24 * 3600);
|
||||
# int hours = seconds / 3600;
|
||||
# seconds = seconds % 3600;
|
||||
# int minutes = seconds / 60;
|
||||
# seconds = seconds % 60;
|
||||
# if ( days > 3650 ) {
|
||||
# return { "Starting up" };
|
||||
# } else if ( days ) {
|
||||
# return { (String(days) +"d " + String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
|
||||
# } else if ( hours ) {
|
||||
# return { (String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
|
||||
# } else if ( minutes ) {
|
||||
# return { (String(minutes) +"m "+ String(seconds) +"s").c_str() };
|
||||
# } else {
|
||||
# return { (String(seconds) +"s").c_str() };
|
||||
# }
|
||||
# icon: mdi:clock-start
|
||||
# - platform: template
|
||||
# name: "Uptime (Days)"
|
||||
# entity_category: diagnostic
|
||||
# lambda: |-
|
||||
# int seconds = (id(uptime_sensor).state);
|
||||
# int days = seconds / (24 * 3600);
|
||||
# seconds = seconds % (24 * 3600);
|
||||
# int hours = seconds / 3600;
|
||||
# seconds = seconds % 3600;
|
||||
# int minutes = seconds / 60;
|
||||
# seconds = seconds % 60;
|
||||
# if ( days > 3650 ) {
|
||||
# return "Starting up" ;
|
||||
# } else if ( days ) {
|
||||
# return (String(days) +"d " + String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() ;
|
||||
# } else if ( hours ) {
|
||||
# return (String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() ;
|
||||
# } else if ( minutes ) {
|
||||
# return (String(minutes) +"m "+ String(seconds) +"s").c_str() ;
|
||||
# } else {
|
||||
# return (String(seconds) +"s").c_str() ;
|
||||
# }
|
||||
# icon: mdi:clock-start
|
||||
|
||||
# - platform: template
|
||||
# name: "Uptime (Days)"
|
||||
# entity_category: diagnostic
|
||||
# lambda: |-
|
||||
# int seconds = (id(uptime_sensor).state);
|
||||
# int days = seconds / (24 * 3600);
|
||||
# seconds = seconds % (24 * 3600);
|
||||
# int hours = seconds / 3600;
|
||||
# seconds = seconds % 3600;
|
||||
# int minutes = seconds / 60;
|
||||
# seconds = seconds % 60;
|
||||
# if ( days > 3650 ) {
|
||||
# return { "Starting up" };
|
||||
# } else if ( days ) {
|
||||
# return { (String(days) +"d " + String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
|
||||
# } else if ( hours ) {
|
||||
# return { (String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
|
||||
# } else if ( minutes ) {
|
||||
# return { (String(minutes) +"m "+ String(seconds) +"s").c_str() };
|
||||
# } else {
|
||||
# return { (String(seconds) +"s").c_str() };
|
||||
# }
|
||||
# icon: mdi:clock-start
|
||||
|
||||
button:
|
||||
- platform: safe_mode
|
||||
name: "Safe Mode Restart: ${local_friendly_name}"
|
||||
name: "Safe Mode Restart:"
|
||||
entity_category: "diagnostic"
|
||||
disabled_by_default: true
|
||||
- platform: restart
|
||||
name: "Restart: ${local_friendly_name}"
|
||||
name: "Restart:"
|
||||
entity_category: "diagnostic"
|
||||
disabled_by_default: true
|
||||
- platform: factory_reset
|
||||
name: "FACTORY RESET: ${local_friendly_name}"
|
||||
name: "FACTORY RESET:"
|
||||
entity_category: "diagnostic"
|
||||
disabled_by_default: true
|
||||
|
75
esphome/common/sntp_common.yaml
Normal file
75
esphome/common/sntp_common.yaml
Normal file
@@ -0,0 +1,75 @@
|
||||
##############################################
|
||||
# SPECIFIC DEVICE VARIABLE SUBSTITUTIONS
|
||||
# If NOT using a secrets file, just replace
|
||||
# these with the values (in quotes)
|
||||
#############################################
|
||||
substitutions:
|
||||
timezone: "Pacific/Auckland"
|
||||
sntp_update_interval: 6h # Set the duration between the sntp service polling
|
||||
# Network time servers https://www.ntppool.org/zone/@
|
||||
sntp_server_1: !secret ntp_server_1
|
||||
sntp_server_2: !secret ntp_server_2
|
||||
sntp_server_3: !secret ntp_server_3
|
||||
|
||||
#############################################
|
||||
# Real time clock time source for ESPHome
|
||||
# If it's invalid, we fall back to an internal clock
|
||||
# https://esphome.io/components/time/index.html
|
||||
# https://esphome.io/components/time/sntp
|
||||
#############################################
|
||||
time:
|
||||
- platform: sntp
|
||||
id: sntp_time
|
||||
# Define the timezone of the device
|
||||
timezone: "${timezone}"
|
||||
# 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:
|
||||
- "${sntp_server_1}"
|
||||
- "${sntp_server_2}"
|
||||
- "${sntp_server_3}"
|
||||
# Publish the time the device was last restarted
|
||||
on_time_sync:
|
||||
then:
|
||||
- logger.log: "Synchronised SNTP clock"
|
||||
- text_sensor.template.publish:
|
||||
id: time_sync
|
||||
state: "SNTP clock Syncd"
|
||||
# Update last restart time, but only once.
|
||||
- if:
|
||||
condition:
|
||||
lambda: 'return id(device_last_restart).state == "";'
|
||||
then:
|
||||
- text_sensor.template.publish:
|
||||
id: device_last_restart
|
||||
#state: !lambda 'return id(sntp_time).now().strftime("%a %d %b %Y - %I:%M:%S %p");'
|
||||
state: !lambda |-
|
||||
// grab the current SNTP time
|
||||
auto now = id(sntp_time).now();
|
||||
// format it as e.g. "Fri 23 May 2025 - 03:45:12 PM"
|
||||
return now.strftime("%a %d %b %Y - %I:%M:%S %p");
|
||||
|
||||
text_sensor:
|
||||
# Creates a sensor showing when the device was last restarted
|
||||
- platform: template
|
||||
name: "Last Restart"
|
||||
id: device_last_restart
|
||||
icon: mdi:clock
|
||||
entity_category: diagnostic
|
||||
#device_class: timestamp
|
||||
|
||||
- platform: template
|
||||
name: "Internal Time"
|
||||
id: time_text
|
||||
update_interval: "1min"
|
||||
entity_category: diagnostic
|
||||
lambda: |-
|
||||
auto time_text = id(sntp_time).now().strftime("%H:%M:%S - %d-%m-%Y");
|
||||
return { time_text };
|
||||
|
||||
- platform: template
|
||||
name: "Time Sync Status"
|
||||
id: time_sync
|
||||
update_interval: "1min"
|
||||
entity_category: diagnostic
|
20
esphome/common/webportal_common.yaml
Normal file
20
esphome/common/webportal_common.yaml
Normal file
@@ -0,0 +1,20 @@
|
||||
##############################################
|
||||
# SPECIFIC DEVICE VARIABLE SUBSTITUTIONS
|
||||
# If NOT using a secrets file, just replace
|
||||
# these with the values (in quotes)
|
||||
#############################################
|
||||
substitutions:
|
||||
web_server_username: !secret web_server_username
|
||||
web_server_password: !secret web_server_password
|
||||
|
||||
#############################################
|
||||
# Web Portal for display and monitoring
|
||||
# Turning this off is maybe a good idea to save resources,
|
||||
# especially on an esp8266.
|
||||
# https://esphome.io/components/web_server.html
|
||||
#############################################
|
||||
web_server:
|
||||
port: 80
|
||||
auth:
|
||||
username: ${web_server_username} # probably a good idea to secure it
|
||||
password: ${web_server_password}
|
Reference in New Issue
Block a user