215 lines
5.0 KiB
YAML
215 lines
5.0 KiB
YAML
substitutions:
|
|
name: "livingroom-bulb-5"
|
|
friendly_name: "Living Room Bulb 5"
|
|
room: "Living Room"
|
|
device_description: "athom 7w rgbcw light bulb"
|
|
project_name: "Athom Technology.Athom RGBCW Bulb"
|
|
dns_domain: ".cloonar.smart"
|
|
timezone: ""
|
|
sntp_update_interval: 6h
|
|
sntp_server_1: "0.pool.ntp.org"
|
|
sntp_server_2: "1.pool.ntp.org"
|
|
sntp_server_3: "2.pool.ntp.org"
|
|
|
|
esphome:
|
|
name: "${name}"
|
|
friendly_name: "${friendly_name}"
|
|
comment: "${device_description}"
|
|
area: "${room}"
|
|
name_add_mac_suffix: false
|
|
min_version: 2024.6.0
|
|
project:
|
|
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%
|
|
|
|
interval:
|
|
- interval: 15s
|
|
then:
|
|
- if:
|
|
condition:
|
|
api.connected:
|
|
else:
|
|
- light.turn_on:
|
|
id: rgbww_light
|
|
brightness: 100%
|
|
|
|
esp8266:
|
|
board: esp8285
|
|
restore_from_flash: true
|
|
|
|
preferences:
|
|
flash_write_interval: 1min
|
|
|
|
api:
|
|
batch_delay: 0ms
|
|
|
|
ota:
|
|
- platform: esphome
|
|
|
|
wifi:
|
|
# 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
|
|
channel: 1
|
|
hidden: true
|
|
|
|
manual_ip:
|
|
static_ip: 10.42.100.15
|
|
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
|
|
name: "Status"
|
|
entity_category: diagnostic
|
|
|
|
sensor:
|
|
- platform: uptime
|
|
name: "Uptime Sensor"
|
|
id: uptime_sensor
|
|
entity_category: diagnostic
|
|
internal: true
|
|
|
|
- platform: wifi_signal
|
|
name: "WiFi Signal dB"
|
|
id: wifi_signal_db
|
|
update_interval: 60s
|
|
entity_category: diagnostic
|
|
|
|
- platform: copy
|
|
source_id: wifi_signal_db
|
|
name: "WiFi Signal Percent"
|
|
filters:
|
|
- lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
|
|
unit_of_measurement: "Signal %"
|
|
entity_category: diagnostic
|
|
|
|
output:
|
|
- platform: esp8266_pwm
|
|
id: red_output
|
|
pin: GPIO4
|
|
min_power: 0.000499
|
|
max_power: 1
|
|
- platform: esp8266_pwm
|
|
id: green_output
|
|
pin: GPIO12
|
|
min_power: 0.000499
|
|
max_power: 1
|
|
- platform: esp8266_pwm
|
|
id: blue_output
|
|
pin: GPIO14
|
|
min_power: 0.000499
|
|
max_power: 1
|
|
- platform: esp8266_pwm
|
|
id: warm_white_output
|
|
pin: GPIO13
|
|
min_power: 0.000499
|
|
max_power: 0.9
|
|
- platform: esp8266_pwm
|
|
id: white_output
|
|
pin: GPIO5
|
|
min_power: 0.000499
|
|
max_power: 0.9
|
|
|
|
light:
|
|
- platform: rgbww
|
|
id: rgbww_light
|
|
name: "RGBCW_Bulb"
|
|
red: red_output
|
|
green: green_output
|
|
blue: blue_output
|
|
warm_white: warm_white_output
|
|
cold_white: white_output
|
|
cold_white_color_temperature: 6000 K
|
|
warm_white_color_temperature: 3000 K
|
|
color_interlock: true
|
|
|
|
text_sensor:
|
|
- platform: wifi_info
|
|
ip_address:
|
|
name: "IP Address"
|
|
entity_category: diagnostic
|
|
ssid:
|
|
name: "Connected SSID"
|
|
entity_category: diagnostic
|
|
mac_address:
|
|
name: "Mac Address"
|
|
entity_category: diagnostic
|
|
|
|
- platform: template
|
|
name: 'Last Restart'
|
|
id: device_last_restart
|
|
icon: mdi:clock
|
|
entity_category: diagnostic
|
|
|
|
- platform: template
|
|
name: "Uptime"
|
|
entity_category: diagnostic
|
|
lambda: |-
|
|
int seconds = (id(uptime_sensor).state);
|
|
int days = seconds / (24 * 3600);
|
|
seconds %= (24 * 3600);
|
|
int hours = seconds / 3600;
|
|
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 {
|
|
return { (String(seconds) + "s").c_str() };
|
|
}
|
|
icon: mdi:clock-start
|
|
|
|
time:
|
|
- platform: sntp
|
|
id: sntp_time
|
|
timezone: "${timezone}"
|
|
update_interval: ${sntp_update_interval}
|
|
servers:
|
|
- "${sntp_server_1}"
|
|
- "${sntp_server_2}"
|
|
- "${sntp_server_3}"
|
|
on_time_sync:
|
|
then:
|
|
- 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");'
|