feat: esphome updates
This commit is contained in:
@@ -10,18 +10,6 @@ substitutions:
|
||||
sntp_server_1: "0.pool.ntp.org"
|
||||
sntp_server_2: "1.pool.ntp.org"
|
||||
sntp_server_3: "2.pool.ntp.org"
|
||||
log_level: "WARN"
|
||||
|
||||
globals:
|
||||
- id: fast_boot
|
||||
type: int
|
||||
restore_value: yes
|
||||
initial_value: '0'
|
||||
|
||||
- id: restore_mode
|
||||
type: int
|
||||
restore_value: yes
|
||||
initial_value: "1"
|
||||
|
||||
esphome:
|
||||
name: "${name}"
|
||||
@@ -34,27 +22,27 @@ esphome:
|
||||
name: "${project_name}"
|
||||
version: "${project_version}"
|
||||
on_boot:
|
||||
then:
|
||||
- light.turn_on:
|
||||
id: rgbww_light
|
||||
- delay: 100ms
|
||||
- light.turn_on:
|
||||
id: rgbww_light
|
||||
brightness: 20%
|
||||
- delay: 100ms
|
||||
- light.turn_on:
|
||||
id: rgbww_light
|
||||
red: 100%
|
||||
green: 50%
|
||||
blue: 0%
|
||||
white: 100%
|
||||
then:
|
||||
- light.turn_on:
|
||||
id: rgbww_light
|
||||
- delay: 100ms
|
||||
- light.turn_on:
|
||||
id: rgbww_light
|
||||
brightness: 20%
|
||||
- delay: 100ms
|
||||
- light.turn_on:
|
||||
id: rgbww_light
|
||||
red: 100%
|
||||
green: 50%
|
||||
blue: 0%
|
||||
white: 100%
|
||||
|
||||
interval:
|
||||
- interval: 15s
|
||||
then:
|
||||
- if:
|
||||
condition:
|
||||
api.connected: # check if api connected
|
||||
api.connected:
|
||||
else:
|
||||
- light.turn_on:
|
||||
id: rgbww_light
|
||||
@@ -68,22 +56,35 @@ preferences:
|
||||
flash_write_interval: 1min
|
||||
|
||||
api:
|
||||
batch_delay: 0ms
|
||||
|
||||
ota:
|
||||
- platform: esphome
|
||||
|
||||
wifi:
|
||||
domain: .cloonar.smart
|
||||
fast_connect: False
|
||||
# Disable fast_connect so we do a full scan (required for hidden SSIDs)
|
||||
fast_connect: True
|
||||
domain: "${dns_domain}"
|
||||
|
||||
# Your hidden network
|
||||
networks:
|
||||
- ssid: !secret wifi_ssid
|
||||
password: !secret wifi_password
|
||||
hidden: True
|
||||
channel: 1
|
||||
hidden: true
|
||||
|
||||
manual_ip:
|
||||
static_ip: 10.42.100.13
|
||||
gateway: 10.42.100.1
|
||||
subnet: 255.255.255.0
|
||||
dns1: 8.8.8.8
|
||||
dns2: 1.1.1.1
|
||||
|
||||
# Fallback access point if Wi-Fi fails
|
||||
ap:
|
||||
ssid: "${name}_AP"
|
||||
password: "bulb_fallback_pw"
|
||||
ap_timeout: 2min # after 2 min of failed join, enable AP
|
||||
|
||||
binary_sensor:
|
||||
- platform: status
|
||||
@@ -101,7 +102,7 @@ sensor:
|
||||
name: "WiFi Signal dB"
|
||||
id: wifi_signal_db
|
||||
update_interval: 60s
|
||||
entity_category: "diagnostic"
|
||||
entity_category: diagnostic
|
||||
|
||||
- platform: copy
|
||||
source_id: wifi_signal_db
|
||||
@@ -109,8 +110,7 @@ sensor:
|
||||
filters:
|
||||
- lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
|
||||
unit_of_measurement: "Signal %"
|
||||
entity_category: "diagnostic"
|
||||
device_class: ""
|
||||
entity_category: diagnostic
|
||||
|
||||
output:
|
||||
- platform: esp8266_pwm
|
||||
@@ -164,59 +164,51 @@ text_sensor:
|
||||
name: "Mac Address"
|
||||
entity_category: diagnostic
|
||||
|
||||
# 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
|
||||
|
||||
# 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);
|
||||
seconds %= (24 * 3600);
|
||||
int hours = seconds / 3600;
|
||||
seconds = seconds % 3600;
|
||||
int minutes = seconds / 60;
|
||||
seconds = seconds % 60;
|
||||
if ( days > 3650 ) {
|
||||
seconds %= 3600;
|
||||
int minutes = seconds / 60;
|
||||
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 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() };
|
||||
return { (String(seconds) + "s").c_str() };
|
||||
}
|
||||
icon: mdi:clock-start
|
||||
|
||||
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:
|
||||
# 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 'return id(sntp_time).now().strftime("%a %d %b %Y - %I:%M:%S %p");'
|
||||
|
||||
Reference in New Issue
Block a user