Compare commits
No commits in common. "c3f260370201169b39beaafc5499d53e29d14660" and "b48ec98cb33b7306b7d95261cdbcfe0094f68e9c" have entirely different histories.
c3f2603702
...
b48ec98cb3
29 changed files with 337 additions and 553 deletions
|
|
@ -6,4 +6,4 @@ https://github.com/tasmota/mgos32-to-tasmota32/releases
|
||||||
In Tasmota make OTA Update to minimal:
|
In Tasmota make OTA Update to minimal:
|
||||||
http://ota.tasmota.com/tasmota/release/tasmota-minimal.bin.gz
|
http://ota.tasmota.com/tasmota/release/tasmota-minimal.bin.gz
|
||||||
Make ESPHome Configuration in Dashboard:
|
Make ESPHome Configuration in Dashboard:
|
||||||
docker run --rm -p 6052:6052 -e ESPHOME_DASHBOARD_USE_PING=true -v "${PWD}":/config -it ghcr.io/esphome/esphome:latest
|
docker run --rm -p 6052:6052 -e ESPHOME_DASHBOARD_USE_PING=true -v "${PWD}":/config -it ghcr.io/esphome/esphome
|
||||||
|
|
|
||||||
|
|
@ -1,19 +0,0 @@
|
||||||
substitutions:
|
|
||||||
device_name: "install"
|
|
||||||
friendly_name: "Esphome Install"
|
|
||||||
|
|
||||||
esphome:
|
|
||||||
name: ${device_name}
|
|
||||||
comment: ${friendly_name}
|
|
||||||
platform: ESP8266
|
|
||||||
board: esp01_1m
|
|
||||||
|
|
||||||
web_server:
|
|
||||||
port: 80
|
|
||||||
|
|
||||||
ota:
|
|
||||||
platform: esphome
|
|
||||||
|
|
||||||
wifi:
|
|
||||||
ssid: Cloonar-Smart
|
|
||||||
password: 0m6sY7Ue3G31
|
|
||||||
|
|
@ -5,6 +5,8 @@ substitutions:
|
||||||
esphome:
|
esphome:
|
||||||
name: ${device_name}
|
name: ${device_name}
|
||||||
comment: ${friendly_name}
|
comment: ${friendly_name}
|
||||||
|
platform: ESP8266
|
||||||
|
board: esp01_1m
|
||||||
on_boot:
|
on_boot:
|
||||||
priority: 300
|
priority: 300
|
||||||
then:
|
then:
|
||||||
|
|
@ -21,9 +23,6 @@ esphome:
|
||||||
green: 50%
|
green: 50%
|
||||||
blue: 0%
|
blue: 0%
|
||||||
white: 100%
|
white: 100%
|
||||||
|
|
||||||
esp8266:
|
|
||||||
board: esp01_1m
|
|
||||||
|
|
||||||
interval:
|
interval:
|
||||||
- interval: 15s
|
- interval: 15s
|
||||||
|
|
@ -38,7 +37,6 @@ interval:
|
||||||
|
|
||||||
# Enable Home Assistant API
|
# Enable Home Assistant API
|
||||||
api:
|
api:
|
||||||
batch_delay: 0ms
|
|
||||||
|
|
||||||
ota:
|
ota:
|
||||||
platform: esphome
|
platform: esphome
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@ substitutions:
|
||||||
esphome:
|
esphome:
|
||||||
name: ${device_name}
|
name: ${device_name}
|
||||||
comment: ${friendly_name}
|
comment: ${friendly_name}
|
||||||
|
platform: ESP8266
|
||||||
|
board: esp01_1m
|
||||||
on_boot:
|
on_boot:
|
||||||
priority: 300
|
priority: 300
|
||||||
then:
|
then:
|
||||||
|
|
@ -21,9 +23,6 @@ esphome:
|
||||||
green: 50%
|
green: 50%
|
||||||
blue: 0%
|
blue: 0%
|
||||||
white: 100%
|
white: 100%
|
||||||
|
|
||||||
esp8266:
|
|
||||||
board: esp01_1m
|
|
||||||
|
|
||||||
interval:
|
interval:
|
||||||
- interval: 15s
|
- interval: 15s
|
||||||
|
|
@ -38,7 +37,6 @@ interval:
|
||||||
|
|
||||||
# Enable Home Assistant API
|
# Enable Home Assistant API
|
||||||
api:
|
api:
|
||||||
batch_delay: 0ms
|
|
||||||
|
|
||||||
ota:
|
ota:
|
||||||
platform: esphome
|
platform: esphome
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@ substitutions:
|
||||||
esphome:
|
esphome:
|
||||||
name: ${device_name}
|
name: ${device_name}
|
||||||
comment: ${friendly_name}
|
comment: ${friendly_name}
|
||||||
|
platform: ESP8266
|
||||||
|
board: esp01_1m
|
||||||
on_boot:
|
on_boot:
|
||||||
priority: 300
|
priority: 300
|
||||||
then:
|
then:
|
||||||
|
|
@ -21,9 +23,6 @@ esphome:
|
||||||
green: 50%
|
green: 50%
|
||||||
blue: 0%
|
blue: 0%
|
||||||
white: 100%
|
white: 100%
|
||||||
|
|
||||||
esp8266:
|
|
||||||
board: esp01_1m
|
|
||||||
|
|
||||||
interval:
|
interval:
|
||||||
- interval: 15s
|
- interval: 15s
|
||||||
|
|
@ -38,7 +37,6 @@ interval:
|
||||||
|
|
||||||
# Enable Home Assistant API
|
# Enable Home Assistant API
|
||||||
api:
|
api:
|
||||||
batch_delay: 0ms
|
|
||||||
|
|
||||||
ota:
|
ota:
|
||||||
platform: esphome
|
platform: esphome
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@ substitutions:
|
||||||
esphome:
|
esphome:
|
||||||
name: ${device_name}
|
name: ${device_name}
|
||||||
comment: ${friendly_name}
|
comment: ${friendly_name}
|
||||||
|
platform: ESP8266
|
||||||
|
board: esp01_1m
|
||||||
on_boot:
|
on_boot:
|
||||||
priority: 300
|
priority: 300
|
||||||
then:
|
then:
|
||||||
|
|
@ -21,9 +23,6 @@ esphome:
|
||||||
green: 50%
|
green: 50%
|
||||||
blue: 0%
|
blue: 0%
|
||||||
white: 100%
|
white: 100%
|
||||||
|
|
||||||
esp8266:
|
|
||||||
board: esp01_1m
|
|
||||||
|
|
||||||
interval:
|
interval:
|
||||||
- interval: 15s
|
- interval: 15s
|
||||||
|
|
@ -38,7 +37,6 @@ interval:
|
||||||
|
|
||||||
# Enable Home Assistant API
|
# Enable Home Assistant API
|
||||||
api:
|
api:
|
||||||
batch_delay: 0ms
|
|
||||||
|
|
||||||
ota:
|
ota:
|
||||||
platform: esphome
|
platform: esphome
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@ substitutions:
|
||||||
esphome:
|
esphome:
|
||||||
name: ${device_name}
|
name: ${device_name}
|
||||||
comment: ${friendly_name}
|
comment: ${friendly_name}
|
||||||
|
platform: ESP8266
|
||||||
|
board: esp01_1m
|
||||||
on_boot:
|
on_boot:
|
||||||
priority: 300
|
priority: 300
|
||||||
then:
|
then:
|
||||||
|
|
@ -21,9 +23,6 @@ esphome:
|
||||||
green: 50%
|
green: 50%
|
||||||
blue: 0%
|
blue: 0%
|
||||||
white: 100%
|
white: 100%
|
||||||
|
|
||||||
esp8266:
|
|
||||||
board: esp01_1m
|
|
||||||
|
|
||||||
interval:
|
interval:
|
||||||
- interval: 15s
|
- interval: 15s
|
||||||
|
|
@ -38,7 +37,6 @@ interval:
|
||||||
|
|
||||||
# Enable Home Assistant API
|
# Enable Home Assistant API
|
||||||
api:
|
api:
|
||||||
batch_delay: 0ms
|
|
||||||
|
|
||||||
ota:
|
ota:
|
||||||
platform: esphome
|
platform: esphome
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@ substitutions:
|
||||||
esphome:
|
esphome:
|
||||||
name: ${device_name}
|
name: ${device_name}
|
||||||
comment: ${friendly_name}
|
comment: ${friendly_name}
|
||||||
|
platform: ESP8266
|
||||||
|
board: esp01_1m
|
||||||
on_boot:
|
on_boot:
|
||||||
priority: 300
|
priority: 300
|
||||||
then:
|
then:
|
||||||
|
|
@ -21,9 +23,6 @@ esphome:
|
||||||
green: 50%
|
green: 50%
|
||||||
blue: 0%
|
blue: 0%
|
||||||
white: 100%
|
white: 100%
|
||||||
|
|
||||||
esp8266:
|
|
||||||
board: esp01_1m
|
|
||||||
|
|
||||||
interval:
|
interval:
|
||||||
- interval: 15s
|
- interval: 15s
|
||||||
|
|
@ -38,7 +37,6 @@ interval:
|
||||||
|
|
||||||
# Enable Home Assistant API
|
# Enable Home Assistant API
|
||||||
api:
|
api:
|
||||||
batch_delay: 0ms
|
|
||||||
|
|
||||||
ota:
|
ota:
|
||||||
platform: esphome
|
platform: esphome
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@ substitutions:
|
||||||
esphome:
|
esphome:
|
||||||
name: ${device_name}
|
name: ${device_name}
|
||||||
comment: ${friendly_name}
|
comment: ${friendly_name}
|
||||||
|
platform: ESP8266
|
||||||
|
board: esp01_1m
|
||||||
on_boot:
|
on_boot:
|
||||||
priority: 300
|
priority: 300
|
||||||
then:
|
then:
|
||||||
|
|
@ -21,9 +23,6 @@ esphome:
|
||||||
green: 50%
|
green: 50%
|
||||||
blue: 0%
|
blue: 0%
|
||||||
white: 100%
|
white: 100%
|
||||||
|
|
||||||
esp8266:
|
|
||||||
board: esp01_1m
|
|
||||||
|
|
||||||
interval:
|
interval:
|
||||||
- interval: 15s
|
- interval: 15s
|
||||||
|
|
@ -38,7 +37,6 @@ interval:
|
||||||
|
|
||||||
# Enable Home Assistant API
|
# Enable Home Assistant API
|
||||||
api:
|
api:
|
||||||
batch_delay: 0ms
|
|
||||||
|
|
||||||
ota:
|
ota:
|
||||||
platform: esphome
|
platform: esphome
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@ substitutions:
|
||||||
esphome:
|
esphome:
|
||||||
name: ${device_name}
|
name: ${device_name}
|
||||||
comment: ${friendly_name}
|
comment: ${friendly_name}
|
||||||
|
platform: ESP8266
|
||||||
|
board: esp01_1m
|
||||||
on_boot:
|
on_boot:
|
||||||
priority: 300
|
priority: 300
|
||||||
then:
|
then:
|
||||||
|
|
@ -21,9 +23,6 @@ esphome:
|
||||||
green: 50%
|
green: 50%
|
||||||
blue: 0%
|
blue: 0%
|
||||||
white: 100%
|
white: 100%
|
||||||
|
|
||||||
esp8266:
|
|
||||||
board: esp01_1m
|
|
||||||
|
|
||||||
interval:
|
interval:
|
||||||
- interval: 15s
|
- interval: 15s
|
||||||
|
|
@ -38,7 +37,6 @@ interval:
|
||||||
|
|
||||||
# Enable Home Assistant API
|
# Enable Home Assistant API
|
||||||
api:
|
api:
|
||||||
batch_delay: 0ms
|
|
||||||
|
|
||||||
ota:
|
ota:
|
||||||
platform: esphome
|
platform: esphome
|
||||||
|
|
|
||||||
|
|
@ -56,14 +56,13 @@ preferences:
|
||||||
flash_write_interval: 1min
|
flash_write_interval: 1min
|
||||||
|
|
||||||
api:
|
api:
|
||||||
batch_delay: 0ms
|
|
||||||
|
|
||||||
ota:
|
ota:
|
||||||
- platform: esphome
|
- platform: esphome
|
||||||
|
|
||||||
wifi:
|
wifi:
|
||||||
# Disable fast_connect so we do a full scan (required for hidden SSIDs)
|
# Disable fast_connect so we do a full scan (required for hidden SSIDs)
|
||||||
fast_connect: True
|
fast_connect: false
|
||||||
domain: "${dns_domain}"
|
domain: "${dns_domain}"
|
||||||
|
|
||||||
# Your hidden network
|
# Your hidden network
|
||||||
|
|
@ -85,6 +84,7 @@ wifi:
|
||||||
ssid: "${name}_AP"
|
ssid: "${name}_AP"
|
||||||
password: "bulb_fallback_pw"
|
password: "bulb_fallback_pw"
|
||||||
ap_timeout: 2min # after 2 min of failed join, enable AP
|
ap_timeout: 2min # after 2 min of failed join, enable AP
|
||||||
|
reboot_timeout: 5min # if still not joined after 5 min, reboot and retry
|
||||||
|
|
||||||
binary_sensor:
|
binary_sensor:
|
||||||
- platform: status
|
- platform: status
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ substitutions:
|
||||||
sntp_server_1: "0.pool.ntp.org"
|
sntp_server_1: "0.pool.ntp.org"
|
||||||
sntp_server_2: "1.pool.ntp.org"
|
sntp_server_2: "1.pool.ntp.org"
|
||||||
sntp_server_3: "2.pool.ntp.org"
|
sntp_server_3: "2.pool.ntp.org"
|
||||||
|
log_level: "WARN"
|
||||||
|
|
||||||
esphome:
|
esphome:
|
||||||
name: "${name}"
|
name: "${name}"
|
||||||
|
|
@ -22,27 +23,27 @@ esphome:
|
||||||
name: "${project_name}"
|
name: "${project_name}"
|
||||||
version: "${project_version}"
|
version: "${project_version}"
|
||||||
on_boot:
|
on_boot:
|
||||||
then:
|
then:
|
||||||
- light.turn_on:
|
- light.turn_on:
|
||||||
id: rgbww_light
|
id: rgbww_light
|
||||||
- delay: 100ms
|
- delay: 100ms
|
||||||
- light.turn_on:
|
- light.turn_on:
|
||||||
id: rgbww_light
|
id: rgbww_light
|
||||||
brightness: 20%
|
brightness: 20%
|
||||||
- delay: 100ms
|
- delay: 100ms
|
||||||
- light.turn_on:
|
- light.turn_on:
|
||||||
id: rgbww_light
|
id: rgbww_light
|
||||||
red: 100%
|
red: 100%
|
||||||
green: 50%
|
green: 50%
|
||||||
blue: 0%
|
blue: 0%
|
||||||
white: 100%
|
white: 100%
|
||||||
|
|
||||||
interval:
|
interval:
|
||||||
- interval: 15s
|
- interval: 15s
|
||||||
then:
|
then:
|
||||||
- if:
|
- if:
|
||||||
condition:
|
condition:
|
||||||
api.connected:
|
api.connected: # check if api connected
|
||||||
else:
|
else:
|
||||||
- light.turn_on:
|
- light.turn_on:
|
||||||
id: rgbww_light
|
id: rgbww_light
|
||||||
|
|
@ -56,35 +57,22 @@ preferences:
|
||||||
flash_write_interval: 1min
|
flash_write_interval: 1min
|
||||||
|
|
||||||
api:
|
api:
|
||||||
batch_delay: 0ms
|
|
||||||
|
|
||||||
ota:
|
ota:
|
||||||
- platform: esphome
|
- platform: esphome
|
||||||
|
|
||||||
wifi:
|
wifi:
|
||||||
# Disable fast_connect so we do a full scan (required for hidden SSIDs)
|
domain: .cloonar.smart
|
||||||
fast_connect: True
|
fast_connect: False
|
||||||
domain: "${dns_domain}"
|
|
||||||
|
|
||||||
# Your hidden network
|
|
||||||
networks:
|
networks:
|
||||||
- ssid: !secret wifi_ssid
|
- ssid: !secret wifi_ssid
|
||||||
password: !secret wifi_password
|
password: !secret wifi_password
|
||||||
channel: 1
|
channel: 1
|
||||||
hidden: true
|
hidden: True
|
||||||
|
|
||||||
manual_ip:
|
manual_ip:
|
||||||
static_ip: 10.42.100.12
|
static_ip: 10.42.100.12
|
||||||
gateway: 10.42.100.1
|
gateway: 10.42.100.1
|
||||||
subnet: 255.255.255.0
|
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:
|
binary_sensor:
|
||||||
- platform: status
|
- platform: status
|
||||||
|
|
@ -102,7 +90,7 @@ sensor:
|
||||||
name: "WiFi Signal dB"
|
name: "WiFi Signal dB"
|
||||||
id: wifi_signal_db
|
id: wifi_signal_db
|
||||||
update_interval: 60s
|
update_interval: 60s
|
||||||
entity_category: diagnostic
|
entity_category: "diagnostic"
|
||||||
|
|
||||||
- platform: copy
|
- platform: copy
|
||||||
source_id: wifi_signal_db
|
source_id: wifi_signal_db
|
||||||
|
|
@ -110,7 +98,8 @@ sensor:
|
||||||
filters:
|
filters:
|
||||||
- lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
|
- lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
|
||||||
unit_of_measurement: "Signal %"
|
unit_of_measurement: "Signal %"
|
||||||
entity_category: diagnostic
|
entity_category: "diagnostic"
|
||||||
|
device_class: ""
|
||||||
|
|
||||||
output:
|
output:
|
||||||
- platform: esp8266_pwm
|
- platform: esp8266_pwm
|
||||||
|
|
@ -164,51 +153,59 @@ text_sensor:
|
||||||
name: "Mac Address"
|
name: "Mac Address"
|
||||||
entity_category: diagnostic
|
entity_category: diagnostic
|
||||||
|
|
||||||
|
# Creates a sensor showing when the device was last restarted
|
||||||
- platform: template
|
- platform: template
|
||||||
name: 'Last Restart'
|
name: 'Last Restart'
|
||||||
id: device_last_restart
|
id: device_last_restart
|
||||||
icon: mdi:clock
|
icon: mdi:clock
|
||||||
entity_category: diagnostic
|
entity_category: diagnostic
|
||||||
|
# device_class: timestamp
|
||||||
|
|
||||||
|
# Creates a sensor of the uptime of the device, in formatted days, hours, minutes and seconds
|
||||||
- platform: template
|
- platform: template
|
||||||
name: "Uptime"
|
name: "Uptime"
|
||||||
entity_category: diagnostic
|
entity_category: diagnostic
|
||||||
lambda: |-
|
lambda: |-
|
||||||
int seconds = (id(uptime_sensor).state);
|
int seconds = (id(uptime_sensor).state);
|
||||||
int days = seconds / (24 * 3600);
|
int days = seconds / (24 * 3600);
|
||||||
seconds %= (24 * 3600);
|
seconds = seconds % (24 * 3600);
|
||||||
int hours = seconds / 3600;
|
int hours = seconds / 3600;
|
||||||
seconds %= 3600;
|
seconds = seconds % 3600;
|
||||||
int minutes = seconds / 60;
|
int minutes = seconds / 60;
|
||||||
seconds %= 60;
|
seconds = seconds % 60;
|
||||||
if (days > 3650) {
|
if ( days > 3650 ) {
|
||||||
return { "Starting up" };
|
return { "Starting up" };
|
||||||
} else if (days) {
|
} else if ( days ) {
|
||||||
return { (String(days) + "d " + String(hours) + "h " + String(minutes) + "m " + String(seconds) + "s").c_str() };
|
return { (String(days) +"d " + String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
|
||||||
} else if (hours) {
|
} else if ( hours ) {
|
||||||
return { (String(hours) + "h " + String(minutes) + "m " + String(seconds) + "s").c_str() };
|
return { (String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
|
||||||
} else if (minutes) {
|
} else if ( minutes ) {
|
||||||
return { (String(minutes) + "m " + String(seconds) + "s").c_str() };
|
return { (String(minutes) +"m "+ String(seconds) +"s").c_str() };
|
||||||
} else {
|
} else {
|
||||||
return { (String(seconds) + "s").c_str() };
|
return { (String(seconds) +"s").c_str() };
|
||||||
}
|
}
|
||||||
icon: mdi:clock-start
|
icon: mdi:clock-start
|
||||||
|
|
||||||
time:
|
time:
|
||||||
- platform: sntp
|
- platform: sntp
|
||||||
id: sntp_time
|
id: sntp_time
|
||||||
|
# Define the timezone of the device
|
||||||
timezone: "${timezone}"
|
timezone: "${timezone}"
|
||||||
|
# Change sync interval from default 5min to 6 hours (or as set in substitutions)
|
||||||
update_interval: ${sntp_update_interval}
|
update_interval: ${sntp_update_interval}
|
||||||
|
# Set specific sntp servers to use
|
||||||
servers:
|
servers:
|
||||||
- "${sntp_server_1}"
|
- "${sntp_server_1}"
|
||||||
- "${sntp_server_2}"
|
- "${sntp_server_2}"
|
||||||
- "${sntp_server_3}"
|
- "${sntp_server_3}"
|
||||||
|
# Publish the time the device was last restarted
|
||||||
on_time_sync:
|
on_time_sync:
|
||||||
then:
|
then:
|
||||||
|
# Update last restart time, but only once.
|
||||||
- if:
|
- if:
|
||||||
condition:
|
condition:
|
||||||
lambda: 'return id(device_last_restart).state == "";'
|
lambda: 'return id(device_last_restart).state == "";'
|
||||||
then:
|
then:
|
||||||
- text_sensor.template.publish:
|
- text_sensor.template.publish:
|
||||||
id: device_last_restart
|
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");'
|
||||||
|
|
@ -10,6 +10,18 @@ substitutions:
|
||||||
sntp_server_1: "0.pool.ntp.org"
|
sntp_server_1: "0.pool.ntp.org"
|
||||||
sntp_server_2: "1.pool.ntp.org"
|
sntp_server_2: "1.pool.ntp.org"
|
||||||
sntp_server_3: "2.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:
|
esphome:
|
||||||
name: "${name}"
|
name: "${name}"
|
||||||
|
|
@ -22,27 +34,27 @@ esphome:
|
||||||
name: "${project_name}"
|
name: "${project_name}"
|
||||||
version: "${project_version}"
|
version: "${project_version}"
|
||||||
on_boot:
|
on_boot:
|
||||||
then:
|
then:
|
||||||
- light.turn_on:
|
- light.turn_on:
|
||||||
id: rgbww_light
|
id: rgbww_light
|
||||||
- delay: 100ms
|
- delay: 100ms
|
||||||
- light.turn_on:
|
- light.turn_on:
|
||||||
id: rgbww_light
|
id: rgbww_light
|
||||||
brightness: 20%
|
brightness: 20%
|
||||||
- delay: 100ms
|
- delay: 100ms
|
||||||
- light.turn_on:
|
- light.turn_on:
|
||||||
id: rgbww_light
|
id: rgbww_light
|
||||||
red: 100%
|
red: 100%
|
||||||
green: 50%
|
green: 50%
|
||||||
blue: 0%
|
blue: 0%
|
||||||
white: 100%
|
white: 100%
|
||||||
|
|
||||||
interval:
|
interval:
|
||||||
- interval: 15s
|
- interval: 15s
|
||||||
then:
|
then:
|
||||||
- if:
|
- if:
|
||||||
condition:
|
condition:
|
||||||
api.connected:
|
api.connected: # check if api connected
|
||||||
else:
|
else:
|
||||||
- light.turn_on:
|
- light.turn_on:
|
||||||
id: rgbww_light
|
id: rgbww_light
|
||||||
|
|
@ -56,35 +68,22 @@ preferences:
|
||||||
flash_write_interval: 1min
|
flash_write_interval: 1min
|
||||||
|
|
||||||
api:
|
api:
|
||||||
batch_delay: 0ms
|
|
||||||
|
|
||||||
ota:
|
ota:
|
||||||
- platform: esphome
|
- platform: esphome
|
||||||
|
|
||||||
wifi:
|
wifi:
|
||||||
# Disable fast_connect so we do a full scan (required for hidden SSIDs)
|
domain: .cloonar.smart
|
||||||
fast_connect: True
|
fast_connect: False
|
||||||
domain: "${dns_domain}"
|
|
||||||
|
|
||||||
# Your hidden network
|
|
||||||
networks:
|
networks:
|
||||||
- ssid: !secret wifi_ssid
|
- ssid: !secret wifi_ssid
|
||||||
password: !secret wifi_password
|
password: !secret wifi_password
|
||||||
|
hidden: True
|
||||||
channel: 1
|
channel: 1
|
||||||
hidden: true
|
|
||||||
|
|
||||||
manual_ip:
|
manual_ip:
|
||||||
static_ip: 10.42.100.13
|
static_ip: 10.42.100.13
|
||||||
gateway: 10.42.100.1
|
gateway: 10.42.100.1
|
||||||
subnet: 255.255.255.0
|
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:
|
binary_sensor:
|
||||||
- platform: status
|
- platform: status
|
||||||
|
|
@ -102,7 +101,7 @@ sensor:
|
||||||
name: "WiFi Signal dB"
|
name: "WiFi Signal dB"
|
||||||
id: wifi_signal_db
|
id: wifi_signal_db
|
||||||
update_interval: 60s
|
update_interval: 60s
|
||||||
entity_category: diagnostic
|
entity_category: "diagnostic"
|
||||||
|
|
||||||
- platform: copy
|
- platform: copy
|
||||||
source_id: wifi_signal_db
|
source_id: wifi_signal_db
|
||||||
|
|
@ -110,7 +109,8 @@ sensor:
|
||||||
filters:
|
filters:
|
||||||
- lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
|
- lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
|
||||||
unit_of_measurement: "Signal %"
|
unit_of_measurement: "Signal %"
|
||||||
entity_category: diagnostic
|
entity_category: "diagnostic"
|
||||||
|
device_class: ""
|
||||||
|
|
||||||
output:
|
output:
|
||||||
- platform: esp8266_pwm
|
- platform: esp8266_pwm
|
||||||
|
|
@ -164,51 +164,59 @@ text_sensor:
|
||||||
name: "Mac Address"
|
name: "Mac Address"
|
||||||
entity_category: diagnostic
|
entity_category: diagnostic
|
||||||
|
|
||||||
|
# Creates a sensor showing when the device was last restarted
|
||||||
- platform: template
|
- platform: template
|
||||||
name: 'Last Restart'
|
name: 'Last Restart'
|
||||||
id: device_last_restart
|
id: device_last_restart
|
||||||
icon: mdi:clock
|
icon: mdi:clock
|
||||||
entity_category: diagnostic
|
entity_category: diagnostic
|
||||||
|
# device_class: timestamp
|
||||||
|
|
||||||
|
# Creates a sensor of the uptime of the device, in formatted days, hours, minutes and seconds
|
||||||
- platform: template
|
- platform: template
|
||||||
name: "Uptime"
|
name: "Uptime"
|
||||||
entity_category: diagnostic
|
entity_category: diagnostic
|
||||||
lambda: |-
|
lambda: |-
|
||||||
int seconds = (id(uptime_sensor).state);
|
int seconds = (id(uptime_sensor).state);
|
||||||
int days = seconds / (24 * 3600);
|
int days = seconds / (24 * 3600);
|
||||||
seconds %= (24 * 3600);
|
seconds = seconds % (24 * 3600);
|
||||||
int hours = seconds / 3600;
|
int hours = seconds / 3600;
|
||||||
seconds %= 3600;
|
seconds = seconds % 3600;
|
||||||
int minutes = seconds / 60;
|
int minutes = seconds / 60;
|
||||||
seconds %= 60;
|
seconds = seconds % 60;
|
||||||
if (days > 3650) {
|
if ( days > 3650 ) {
|
||||||
return { "Starting up" };
|
return { "Starting up" };
|
||||||
} else if (days) {
|
} else if ( days ) {
|
||||||
return { (String(days) + "d " + String(hours) + "h " + String(minutes) + "m " + String(seconds) + "s").c_str() };
|
return { (String(days) +"d " + String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
|
||||||
} else if (hours) {
|
} else if ( hours ) {
|
||||||
return { (String(hours) + "h " + String(minutes) + "m " + String(seconds) + "s").c_str() };
|
return { (String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
|
||||||
} else if (minutes) {
|
} else if ( minutes ) {
|
||||||
return { (String(minutes) + "m " + String(seconds) + "s").c_str() };
|
return { (String(minutes) +"m "+ String(seconds) +"s").c_str() };
|
||||||
} else {
|
} else {
|
||||||
return { (String(seconds) + "s").c_str() };
|
return { (String(seconds) +"s").c_str() };
|
||||||
}
|
}
|
||||||
icon: mdi:clock-start
|
icon: mdi:clock-start
|
||||||
|
|
||||||
time:
|
time:
|
||||||
- platform: sntp
|
- platform: sntp
|
||||||
id: sntp_time
|
id: sntp_time
|
||||||
|
# Define the timezone of the device
|
||||||
timezone: "${timezone}"
|
timezone: "${timezone}"
|
||||||
|
# Change sync interval from default 5min to 6 hours (or as set in substitutions)
|
||||||
update_interval: ${sntp_update_interval}
|
update_interval: ${sntp_update_interval}
|
||||||
|
# Set specific sntp servers to use
|
||||||
servers:
|
servers:
|
||||||
- "${sntp_server_1}"
|
- "${sntp_server_1}"
|
||||||
- "${sntp_server_2}"
|
- "${sntp_server_2}"
|
||||||
- "${sntp_server_3}"
|
- "${sntp_server_3}"
|
||||||
|
# Publish the time the device was last restarted
|
||||||
on_time_sync:
|
on_time_sync:
|
||||||
then:
|
then:
|
||||||
|
# Update last restart time, but only once.
|
||||||
- if:
|
- if:
|
||||||
condition:
|
condition:
|
||||||
lambda: 'return id(device_last_restart).state == "";'
|
lambda: 'return id(device_last_restart).state == "";'
|
||||||
then:
|
then:
|
||||||
- text_sensor.template.publish:
|
- text_sensor.template.publish:
|
||||||
id: device_last_restart
|
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");'
|
||||||
|
|
@ -10,6 +10,18 @@ substitutions:
|
||||||
sntp_server_1: "0.pool.ntp.org"
|
sntp_server_1: "0.pool.ntp.org"
|
||||||
sntp_server_2: "1.pool.ntp.org"
|
sntp_server_2: "1.pool.ntp.org"
|
||||||
sntp_server_3: "2.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:
|
esphome:
|
||||||
name: "${name}"
|
name: "${name}"
|
||||||
|
|
@ -22,27 +34,27 @@ esphome:
|
||||||
name: "${project_name}"
|
name: "${project_name}"
|
||||||
version: "${project_version}"
|
version: "${project_version}"
|
||||||
on_boot:
|
on_boot:
|
||||||
then:
|
then:
|
||||||
- light.turn_on:
|
- light.turn_on:
|
||||||
id: rgbww_light
|
id: rgbww_light
|
||||||
- delay: 100ms
|
- delay: 100ms
|
||||||
- light.turn_on:
|
- light.turn_on:
|
||||||
id: rgbww_light
|
id: rgbww_light
|
||||||
brightness: 20%
|
brightness: 20%
|
||||||
- delay: 100ms
|
- delay: 100ms
|
||||||
- light.turn_on:
|
- light.turn_on:
|
||||||
id: rgbww_light
|
id: rgbww_light
|
||||||
red: 100%
|
red: 100%
|
||||||
green: 50%
|
green: 50%
|
||||||
blue: 0%
|
blue: 0%
|
||||||
white: 100%
|
white: 100%
|
||||||
|
|
||||||
interval:
|
interval:
|
||||||
- interval: 15s
|
- interval: 15s
|
||||||
then:
|
then:
|
||||||
- if:
|
- if:
|
||||||
condition:
|
condition:
|
||||||
api.connected:
|
api.connected: # check if api connected
|
||||||
else:
|
else:
|
||||||
- light.turn_on:
|
- light.turn_on:
|
||||||
id: rgbww_light
|
id: rgbww_light
|
||||||
|
|
@ -56,35 +68,21 @@ preferences:
|
||||||
flash_write_interval: 1min
|
flash_write_interval: 1min
|
||||||
|
|
||||||
api:
|
api:
|
||||||
batch_delay: 0ms
|
|
||||||
|
|
||||||
ota:
|
ota:
|
||||||
- platform: esphome
|
- platform: esphome
|
||||||
|
|
||||||
wifi:
|
wifi:
|
||||||
# Disable fast_connect so we do a full scan (required for hidden SSIDs)
|
domain: .cloonar.smart
|
||||||
fast_connect: True
|
fast_connect: False
|
||||||
domain: "${dns_domain}"
|
|
||||||
|
|
||||||
# Your hidden network
|
|
||||||
networks:
|
networks:
|
||||||
- ssid: !secret wifi_ssid
|
- ssid: !secret wifi_ssid
|
||||||
password: !secret wifi_password
|
password: !secret wifi_password
|
||||||
channel: 1
|
hidden: True
|
||||||
hidden: true
|
|
||||||
|
|
||||||
manual_ip:
|
manual_ip:
|
||||||
static_ip: 10.42.100.14
|
static_ip: 10.42.100.14
|
||||||
gateway: 10.42.100.1
|
gateway: 10.42.100.1
|
||||||
subnet: 255.255.255.0
|
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:
|
binary_sensor:
|
||||||
- platform: status
|
- platform: status
|
||||||
|
|
@ -102,7 +100,7 @@ sensor:
|
||||||
name: "WiFi Signal dB"
|
name: "WiFi Signal dB"
|
||||||
id: wifi_signal_db
|
id: wifi_signal_db
|
||||||
update_interval: 60s
|
update_interval: 60s
|
||||||
entity_category: diagnostic
|
entity_category: "diagnostic"
|
||||||
|
|
||||||
- platform: copy
|
- platform: copy
|
||||||
source_id: wifi_signal_db
|
source_id: wifi_signal_db
|
||||||
|
|
@ -110,7 +108,8 @@ sensor:
|
||||||
filters:
|
filters:
|
||||||
- lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
|
- lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
|
||||||
unit_of_measurement: "Signal %"
|
unit_of_measurement: "Signal %"
|
||||||
entity_category: diagnostic
|
entity_category: "diagnostic"
|
||||||
|
device_class: ""
|
||||||
|
|
||||||
output:
|
output:
|
||||||
- platform: esp8266_pwm
|
- platform: esp8266_pwm
|
||||||
|
|
@ -164,51 +163,59 @@ text_sensor:
|
||||||
name: "Mac Address"
|
name: "Mac Address"
|
||||||
entity_category: diagnostic
|
entity_category: diagnostic
|
||||||
|
|
||||||
|
# Creates a sensor showing when the device was last restarted
|
||||||
- platform: template
|
- platform: template
|
||||||
name: 'Last Restart'
|
name: 'Last Restart'
|
||||||
id: device_last_restart
|
id: device_last_restart
|
||||||
icon: mdi:clock
|
icon: mdi:clock
|
||||||
entity_category: diagnostic
|
entity_category: diagnostic
|
||||||
|
# device_class: timestamp
|
||||||
|
|
||||||
|
# Creates a sensor of the uptime of the device, in formatted days, hours, minutes and seconds
|
||||||
- platform: template
|
- platform: template
|
||||||
name: "Uptime"
|
name: "Uptime"
|
||||||
entity_category: diagnostic
|
entity_category: diagnostic
|
||||||
lambda: |-
|
lambda: |-
|
||||||
int seconds = (id(uptime_sensor).state);
|
int seconds = (id(uptime_sensor).state);
|
||||||
int days = seconds / (24 * 3600);
|
int days = seconds / (24 * 3600);
|
||||||
seconds %= (24 * 3600);
|
seconds = seconds % (24 * 3600);
|
||||||
int hours = seconds / 3600;
|
int hours = seconds / 3600;
|
||||||
seconds %= 3600;
|
seconds = seconds % 3600;
|
||||||
int minutes = seconds / 60;
|
int minutes = seconds / 60;
|
||||||
seconds %= 60;
|
seconds = seconds % 60;
|
||||||
if (days > 3650) {
|
if ( days > 3650 ) {
|
||||||
return { "Starting up" };
|
return { "Starting up" };
|
||||||
} else if (days) {
|
} else if ( days ) {
|
||||||
return { (String(days) + "d " + String(hours) + "h " + String(minutes) + "m " + String(seconds) + "s").c_str() };
|
return { (String(days) +"d " + String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
|
||||||
} else if (hours) {
|
} else if ( hours ) {
|
||||||
return { (String(hours) + "h " + String(minutes) + "m " + String(seconds) + "s").c_str() };
|
return { (String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
|
||||||
} else if (minutes) {
|
} else if ( minutes ) {
|
||||||
return { (String(minutes) + "m " + String(seconds) + "s").c_str() };
|
return { (String(minutes) +"m "+ String(seconds) +"s").c_str() };
|
||||||
} else {
|
} else {
|
||||||
return { (String(seconds) + "s").c_str() };
|
return { (String(seconds) +"s").c_str() };
|
||||||
}
|
}
|
||||||
icon: mdi:clock-start
|
icon: mdi:clock-start
|
||||||
|
|
||||||
time:
|
time:
|
||||||
- platform: sntp
|
- platform: sntp
|
||||||
id: sntp_time
|
id: sntp_time
|
||||||
|
# Define the timezone of the device
|
||||||
timezone: "${timezone}"
|
timezone: "${timezone}"
|
||||||
|
# Change sync interval from default 5min to 6 hours (or as set in substitutions)
|
||||||
update_interval: ${sntp_update_interval}
|
update_interval: ${sntp_update_interval}
|
||||||
|
# Set specific sntp servers to use
|
||||||
servers:
|
servers:
|
||||||
- "${sntp_server_1}"
|
- "${sntp_server_1}"
|
||||||
- "${sntp_server_2}"
|
- "${sntp_server_2}"
|
||||||
- "${sntp_server_3}"
|
- "${sntp_server_3}"
|
||||||
|
# Publish the time the device was last restarted
|
||||||
on_time_sync:
|
on_time_sync:
|
||||||
then:
|
then:
|
||||||
|
# Update last restart time, but only once.
|
||||||
- if:
|
- if:
|
||||||
condition:
|
condition:
|
||||||
lambda: 'return id(device_last_restart).state == "";'
|
lambda: 'return id(device_last_restart).state == "";'
|
||||||
then:
|
then:
|
||||||
- text_sensor.template.publish:
|
- text_sensor.template.publish:
|
||||||
id: device_last_restart
|
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");'
|
||||||
|
|
@ -10,6 +10,18 @@ substitutions:
|
||||||
sntp_server_1: "0.pool.ntp.org"
|
sntp_server_1: "0.pool.ntp.org"
|
||||||
sntp_server_2: "1.pool.ntp.org"
|
sntp_server_2: "1.pool.ntp.org"
|
||||||
sntp_server_3: "2.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:
|
esphome:
|
||||||
name: "${name}"
|
name: "${name}"
|
||||||
|
|
@ -22,27 +34,27 @@ esphome:
|
||||||
name: "${project_name}"
|
name: "${project_name}"
|
||||||
version: "${project_version}"
|
version: "${project_version}"
|
||||||
on_boot:
|
on_boot:
|
||||||
then:
|
then:
|
||||||
- light.turn_on:
|
- light.turn_on:
|
||||||
id: rgbww_light
|
id: rgbww_light
|
||||||
- delay: 100ms
|
- delay: 100ms
|
||||||
- light.turn_on:
|
- light.turn_on:
|
||||||
id: rgbww_light
|
id: rgbww_light
|
||||||
brightness: 20%
|
brightness: 20%
|
||||||
- delay: 100ms
|
- delay: 100ms
|
||||||
- light.turn_on:
|
- light.turn_on:
|
||||||
id: rgbww_light
|
id: rgbww_light
|
||||||
red: 100%
|
red: 100%
|
||||||
green: 50%
|
green: 50%
|
||||||
blue: 0%
|
blue: 0%
|
||||||
white: 100%
|
white: 100%
|
||||||
|
|
||||||
interval:
|
interval:
|
||||||
- interval: 15s
|
- interval: 15s
|
||||||
then:
|
then:
|
||||||
- if:
|
- if:
|
||||||
condition:
|
condition:
|
||||||
api.connected:
|
api.connected: # check if api connected
|
||||||
else:
|
else:
|
||||||
- light.turn_on:
|
- light.turn_on:
|
||||||
id: rgbww_light
|
id: rgbww_light
|
||||||
|
|
@ -56,35 +68,21 @@ preferences:
|
||||||
flash_write_interval: 1min
|
flash_write_interval: 1min
|
||||||
|
|
||||||
api:
|
api:
|
||||||
batch_delay: 0ms
|
|
||||||
|
|
||||||
ota:
|
ota:
|
||||||
- platform: esphome
|
- platform: esphome
|
||||||
|
|
||||||
wifi:
|
wifi:
|
||||||
# Disable fast_connect so we do a full scan (required for hidden SSIDs)
|
domain: .cloonar.smart
|
||||||
fast_connect: True
|
fast_connect: False
|
||||||
domain: "${dns_domain}"
|
|
||||||
|
|
||||||
# Your hidden network
|
|
||||||
networks:
|
networks:
|
||||||
- ssid: !secret wifi_ssid
|
- ssid: !secret wifi_ssid
|
||||||
password: !secret wifi_password
|
password: !secret wifi_password
|
||||||
channel: 1
|
hidden: True
|
||||||
hidden: true
|
|
||||||
|
|
||||||
manual_ip:
|
manual_ip:
|
||||||
static_ip: 10.42.100.15
|
static_ip: 10.42.100.15
|
||||||
gateway: 10.42.100.1
|
gateway: 10.42.100.1
|
||||||
subnet: 255.255.255.0
|
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:
|
binary_sensor:
|
||||||
- platform: status
|
- platform: status
|
||||||
|
|
@ -102,7 +100,7 @@ sensor:
|
||||||
name: "WiFi Signal dB"
|
name: "WiFi Signal dB"
|
||||||
id: wifi_signal_db
|
id: wifi_signal_db
|
||||||
update_interval: 60s
|
update_interval: 60s
|
||||||
entity_category: diagnostic
|
entity_category: "diagnostic"
|
||||||
|
|
||||||
- platform: copy
|
- platform: copy
|
||||||
source_id: wifi_signal_db
|
source_id: wifi_signal_db
|
||||||
|
|
@ -110,7 +108,8 @@ sensor:
|
||||||
filters:
|
filters:
|
||||||
- lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
|
- lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
|
||||||
unit_of_measurement: "Signal %"
|
unit_of_measurement: "Signal %"
|
||||||
entity_category: diagnostic
|
entity_category: "diagnostic"
|
||||||
|
device_class: ""
|
||||||
|
|
||||||
output:
|
output:
|
||||||
- platform: esp8266_pwm
|
- platform: esp8266_pwm
|
||||||
|
|
@ -164,51 +163,59 @@ text_sensor:
|
||||||
name: "Mac Address"
|
name: "Mac Address"
|
||||||
entity_category: diagnostic
|
entity_category: diagnostic
|
||||||
|
|
||||||
|
# Creates a sensor showing when the device was last restarted
|
||||||
- platform: template
|
- platform: template
|
||||||
name: 'Last Restart'
|
name: 'Last Restart'
|
||||||
id: device_last_restart
|
id: device_last_restart
|
||||||
icon: mdi:clock
|
icon: mdi:clock
|
||||||
entity_category: diagnostic
|
entity_category: diagnostic
|
||||||
|
# device_class: timestamp
|
||||||
|
|
||||||
|
# Creates a sensor of the uptime of the device, in formatted days, hours, minutes and seconds
|
||||||
- platform: template
|
- platform: template
|
||||||
name: "Uptime"
|
name: "Uptime"
|
||||||
entity_category: diagnostic
|
entity_category: diagnostic
|
||||||
lambda: |-
|
lambda: |-
|
||||||
int seconds = (id(uptime_sensor).state);
|
int seconds = (id(uptime_sensor).state);
|
||||||
int days = seconds / (24 * 3600);
|
int days = seconds / (24 * 3600);
|
||||||
seconds %= (24 * 3600);
|
seconds = seconds % (24 * 3600);
|
||||||
int hours = seconds / 3600;
|
int hours = seconds / 3600;
|
||||||
seconds %= 3600;
|
seconds = seconds % 3600;
|
||||||
int minutes = seconds / 60;
|
int minutes = seconds / 60;
|
||||||
seconds %= 60;
|
seconds = seconds % 60;
|
||||||
if (days > 3650) {
|
if ( days > 3650 ) {
|
||||||
return { "Starting up" };
|
return { "Starting up" };
|
||||||
} else if (days) {
|
} else if ( days ) {
|
||||||
return { (String(days) + "d " + String(hours) + "h " + String(minutes) + "m " + String(seconds) + "s").c_str() };
|
return { (String(days) +"d " + String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
|
||||||
} else if (hours) {
|
} else if ( hours ) {
|
||||||
return { (String(hours) + "h " + String(minutes) + "m " + String(seconds) + "s").c_str() };
|
return { (String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
|
||||||
} else if (minutes) {
|
} else if ( minutes ) {
|
||||||
return { (String(minutes) + "m " + String(seconds) + "s").c_str() };
|
return { (String(minutes) +"m "+ String(seconds) +"s").c_str() };
|
||||||
} else {
|
} else {
|
||||||
return { (String(seconds) + "s").c_str() };
|
return { (String(seconds) +"s").c_str() };
|
||||||
}
|
}
|
||||||
icon: mdi:clock-start
|
icon: mdi:clock-start
|
||||||
|
|
||||||
time:
|
time:
|
||||||
- platform: sntp
|
- platform: sntp
|
||||||
id: sntp_time
|
id: sntp_time
|
||||||
|
# Define the timezone of the device
|
||||||
timezone: "${timezone}"
|
timezone: "${timezone}"
|
||||||
|
# Change sync interval from default 5min to 6 hours (or as set in substitutions)
|
||||||
update_interval: ${sntp_update_interval}
|
update_interval: ${sntp_update_interval}
|
||||||
|
# Set specific sntp servers to use
|
||||||
servers:
|
servers:
|
||||||
- "${sntp_server_1}"
|
- "${sntp_server_1}"
|
||||||
- "${sntp_server_2}"
|
- "${sntp_server_2}"
|
||||||
- "${sntp_server_3}"
|
- "${sntp_server_3}"
|
||||||
|
# Publish the time the device was last restarted
|
||||||
on_time_sync:
|
on_time_sync:
|
||||||
then:
|
then:
|
||||||
|
# Update last restart time, but only once.
|
||||||
- if:
|
- if:
|
||||||
condition:
|
condition:
|
||||||
lambda: 'return id(device_last_restart).state == "";'
|
lambda: 'return id(device_last_restart).state == "";'
|
||||||
then:
|
then:
|
||||||
- text_sensor.template.publish:
|
- text_sensor.template.publish:
|
||||||
id: device_last_restart
|
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");'
|
||||||
|
|
@ -10,6 +10,18 @@ substitutions:
|
||||||
sntp_server_1: "0.pool.ntp.org"
|
sntp_server_1: "0.pool.ntp.org"
|
||||||
sntp_server_2: "1.pool.ntp.org"
|
sntp_server_2: "1.pool.ntp.org"
|
||||||
sntp_server_3: "2.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:
|
esphome:
|
||||||
name: "${name}"
|
name: "${name}"
|
||||||
|
|
@ -22,27 +34,27 @@ esphome:
|
||||||
name: "${project_name}"
|
name: "${project_name}"
|
||||||
version: "${project_version}"
|
version: "${project_version}"
|
||||||
on_boot:
|
on_boot:
|
||||||
then:
|
then:
|
||||||
- light.turn_on:
|
- light.turn_on:
|
||||||
id: rgbww_light
|
id: rgbww_light
|
||||||
- delay: 100ms
|
- delay: 100ms
|
||||||
- light.turn_on:
|
- light.turn_on:
|
||||||
id: rgbww_light
|
id: rgbww_light
|
||||||
brightness: 20%
|
brightness: 20%
|
||||||
- delay: 100ms
|
- delay: 100ms
|
||||||
- light.turn_on:
|
- light.turn_on:
|
||||||
id: rgbww_light
|
id: rgbww_light
|
||||||
red: 100%
|
red: 100%
|
||||||
green: 50%
|
green: 50%
|
||||||
blue: 0%
|
blue: 0%
|
||||||
white: 100%
|
white: 100%
|
||||||
|
|
||||||
interval:
|
interval:
|
||||||
- interval: 15s
|
- interval: 15s
|
||||||
then:
|
then:
|
||||||
- if:
|
- if:
|
||||||
condition:
|
condition:
|
||||||
api.connected:
|
api.connected: # check if api connected
|
||||||
else:
|
else:
|
||||||
- light.turn_on:
|
- light.turn_on:
|
||||||
id: rgbww_light
|
id: rgbww_light
|
||||||
|
|
@ -56,35 +68,22 @@ preferences:
|
||||||
flash_write_interval: 1min
|
flash_write_interval: 1min
|
||||||
|
|
||||||
api:
|
api:
|
||||||
batch_delay: 0ms
|
|
||||||
|
|
||||||
ota:
|
ota:
|
||||||
- platform: esphome
|
- platform: esphome
|
||||||
|
|
||||||
wifi:
|
wifi:
|
||||||
# Disable fast_connect so we do a full scan (required for hidden SSIDs)
|
domain: .cloonar.smart
|
||||||
fast_connect: True
|
fast_connect: False
|
||||||
domain: "${dns_domain}"
|
|
||||||
|
|
||||||
# Your hidden network
|
|
||||||
networks:
|
networks:
|
||||||
- ssid: !secret wifi_ssid
|
- ssid: !secret wifi_ssid
|
||||||
password: !secret wifi_password
|
password: !secret wifi_password
|
||||||
|
hidden: True
|
||||||
channel: 1
|
channel: 1
|
||||||
hidden: true
|
|
||||||
|
|
||||||
manual_ip:
|
manual_ip:
|
||||||
static_ip: 10.42.100.16
|
static_ip: 10.42.100.16
|
||||||
gateway: 10.42.100.1
|
gateway: 10.42.100.1
|
||||||
subnet: 255.255.255.0
|
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:
|
binary_sensor:
|
||||||
- platform: status
|
- platform: status
|
||||||
|
|
@ -102,7 +101,7 @@ sensor:
|
||||||
name: "WiFi Signal dB"
|
name: "WiFi Signal dB"
|
||||||
id: wifi_signal_db
|
id: wifi_signal_db
|
||||||
update_interval: 60s
|
update_interval: 60s
|
||||||
entity_category: diagnostic
|
entity_category: "diagnostic"
|
||||||
|
|
||||||
- platform: copy
|
- platform: copy
|
||||||
source_id: wifi_signal_db
|
source_id: wifi_signal_db
|
||||||
|
|
@ -110,7 +109,8 @@ sensor:
|
||||||
filters:
|
filters:
|
||||||
- lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
|
- lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
|
||||||
unit_of_measurement: "Signal %"
|
unit_of_measurement: "Signal %"
|
||||||
entity_category: diagnostic
|
entity_category: "diagnostic"
|
||||||
|
device_class: ""
|
||||||
|
|
||||||
output:
|
output:
|
||||||
- platform: esp8266_pwm
|
- platform: esp8266_pwm
|
||||||
|
|
@ -164,51 +164,59 @@ text_sensor:
|
||||||
name: "Mac Address"
|
name: "Mac Address"
|
||||||
entity_category: diagnostic
|
entity_category: diagnostic
|
||||||
|
|
||||||
|
# Creates a sensor showing when the device was last restarted
|
||||||
- platform: template
|
- platform: template
|
||||||
name: 'Last Restart'
|
name: 'Last Restart'
|
||||||
id: device_last_restart
|
id: device_last_restart
|
||||||
icon: mdi:clock
|
icon: mdi:clock
|
||||||
entity_category: diagnostic
|
entity_category: diagnostic
|
||||||
|
# device_class: timestamp
|
||||||
|
|
||||||
|
# Creates a sensor of the uptime of the device, in formatted days, hours, minutes and seconds
|
||||||
- platform: template
|
- platform: template
|
||||||
name: "Uptime"
|
name: "Uptime"
|
||||||
entity_category: diagnostic
|
entity_category: diagnostic
|
||||||
lambda: |-
|
lambda: |-
|
||||||
int seconds = (id(uptime_sensor).state);
|
int seconds = (id(uptime_sensor).state);
|
||||||
int days = seconds / (24 * 3600);
|
int days = seconds / (24 * 3600);
|
||||||
seconds %= (24 * 3600);
|
seconds = seconds % (24 * 3600);
|
||||||
int hours = seconds / 3600;
|
int hours = seconds / 3600;
|
||||||
seconds %= 3600;
|
seconds = seconds % 3600;
|
||||||
int minutes = seconds / 60;
|
int minutes = seconds / 60;
|
||||||
seconds %= 60;
|
seconds = seconds % 60;
|
||||||
if (days > 3650) {
|
if ( days > 3650 ) {
|
||||||
return { "Starting up" };
|
return { "Starting up" };
|
||||||
} else if (days) {
|
} else if ( days ) {
|
||||||
return { (String(days) + "d " + String(hours) + "h " + String(minutes) + "m " + String(seconds) + "s").c_str() };
|
return { (String(days) +"d " + String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
|
||||||
} else if (hours) {
|
} else if ( hours ) {
|
||||||
return { (String(hours) + "h " + String(minutes) + "m " + String(seconds) + "s").c_str() };
|
return { (String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
|
||||||
} else if (minutes) {
|
} else if ( minutes ) {
|
||||||
return { (String(minutes) + "m " + String(seconds) + "s").c_str() };
|
return { (String(minutes) +"m "+ String(seconds) +"s").c_str() };
|
||||||
} else {
|
} else {
|
||||||
return { (String(seconds) + "s").c_str() };
|
return { (String(seconds) +"s").c_str() };
|
||||||
}
|
}
|
||||||
icon: mdi:clock-start
|
icon: mdi:clock-start
|
||||||
|
|
||||||
time:
|
time:
|
||||||
- platform: sntp
|
- platform: sntp
|
||||||
id: sntp_time
|
id: sntp_time
|
||||||
|
# Define the timezone of the device
|
||||||
timezone: "${timezone}"
|
timezone: "${timezone}"
|
||||||
|
# Change sync interval from default 5min to 6 hours (or as set in substitutions)
|
||||||
update_interval: ${sntp_update_interval}
|
update_interval: ${sntp_update_interval}
|
||||||
|
# Set specific sntp servers to use
|
||||||
servers:
|
servers:
|
||||||
- "${sntp_server_1}"
|
- "${sntp_server_1}"
|
||||||
- "${sntp_server_2}"
|
- "${sntp_server_2}"
|
||||||
- "${sntp_server_3}"
|
- "${sntp_server_3}"
|
||||||
|
# Publish the time the device was last restarted
|
||||||
on_time_sync:
|
on_time_sync:
|
||||||
then:
|
then:
|
||||||
|
# Update last restart time, but only once.
|
||||||
- if:
|
- if:
|
||||||
condition:
|
condition:
|
||||||
lambda: 'return id(device_last_restart).state == "";'
|
lambda: 'return id(device_last_restart).state == "";'
|
||||||
then:
|
then:
|
||||||
- text_sensor.template.publish:
|
- text_sensor.template.publish:
|
||||||
id: device_last_restart
|
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");'
|
||||||
|
|
@ -5,6 +5,8 @@ substitutions:
|
||||||
esphome:
|
esphome:
|
||||||
name: ${device_name}
|
name: ${device_name}
|
||||||
comment: ${friendly_name}
|
comment: ${friendly_name}
|
||||||
|
platform: ESP8266
|
||||||
|
board: esp01_1m
|
||||||
on_boot:
|
on_boot:
|
||||||
then:
|
then:
|
||||||
- light.turn_on:
|
- light.turn_on:
|
||||||
|
|
@ -18,8 +20,7 @@ esphome:
|
||||||
id: my_light
|
id: my_light
|
||||||
color_temperature: 2700 K
|
color_temperature: 2700 K
|
||||||
|
|
||||||
esp8266:
|
|
||||||
board: esp01_1m
|
|
||||||
|
|
||||||
interval:
|
interval:
|
||||||
- interval: 15s
|
- interval: 15s
|
||||||
|
|
@ -39,7 +40,6 @@ interval:
|
||||||
|
|
||||||
# Enable Home Assistant API
|
# Enable Home Assistant API
|
||||||
api:
|
api:
|
||||||
batch_delay: 0ms
|
|
||||||
|
|
||||||
ota:
|
ota:
|
||||||
platform: esphome
|
platform: esphome
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,10 @@ in {
|
||||||
variants = ["qt5"];
|
variants = ["qt5"];
|
||||||
})
|
})
|
||||||
|
|
||||||
|
vscode
|
||||||
|
code-cursor
|
||||||
|
|
||||||
|
|
||||||
dracula-theme
|
dracula-theme
|
||||||
foot
|
foot
|
||||||
fractal
|
fractal
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,10 @@
|
||||||
{ config, pkgs, ... }:
|
{ config, pkgs, ... }:
|
||||||
let
|
let
|
||||||
unstable = import (fetchTarball https://nixos.org/channels/nixos-unstable/nixexprs.tar.xz) {
|
# unstable = import (fetchTarball https://nixos.org/channels/nixos-unstable/nixexprs.tar.xz) {
|
||||||
config = { allowUnfree = true; };
|
# config = { allowUnfree = true; };
|
||||||
};
|
# };
|
||||||
in {
|
in {
|
||||||
environment.systemPackages = with pkgs; [
|
environment.systemPackages = with pkgs; [
|
||||||
unstable.claude-code
|
claude-code
|
||||||
unstable.code-cursor
|
|
||||||
unstable.vscode
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ in {
|
||||||
imports = [
|
imports = [
|
||||||
# ./mcp.nix
|
# ./mcp.nix
|
||||||
./coding.nix
|
./coding.nix
|
||||||
./android.nix
|
|
||||||
./nvim/default.nix
|
./nvim/default.nix
|
||||||
];
|
];
|
||||||
environment.systemPackages = with pkgs; [
|
environment.systemPackages = with pkgs; [
|
||||||
|
|
@ -38,7 +37,6 @@ in {
|
||||||
vim
|
vim
|
||||||
wget
|
wget
|
||||||
wireguard-tools
|
wireguard-tools
|
||||||
wkhtmltopdf
|
|
||||||
wol
|
wol
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ bindsym $mod+d exec foot -a launcher -e env TERMINAL_COMMAND="foot -c /etc/xdg/f
|
||||||
#bindsym $mod+d exec --no-startup-id bemenu --dmenu="dmenu -i -fn 'Source Sans Pro-10' -nb '#212121' -sb '#2b83a6' -sf '#ffffff'
|
#bindsym $mod+d exec --no-startup-id bemenu --dmenu="dmenu -i -fn 'Source Sans Pro-10' -nb '#212121' -sb '#2b83a6' -sf '#ffffff'
|
||||||
|
|
||||||
# start an explorer
|
# start an explorer
|
||||||
bindsym $mod+e exec --no-startup-id nautilus
|
bindsym $mod+e exec --no-startup-id thunar
|
||||||
|
|
||||||
# switching window with win+tab
|
# switching window with win+tab
|
||||||
bindsym $mod+Tab exec --no-startup-id wofi -show window
|
bindsym $mod+Tab exec --no-startup-id wofi -show window
|
||||||
|
|
@ -260,7 +260,7 @@ assign [app_id="foot" title="^(?!terminal-sway)$"] → $ws2
|
||||||
assign [app_id="chromium"] → $ws3
|
assign [app_id="chromium"] → $ws3
|
||||||
assign [app_id="firefox"] → $ws3
|
assign [app_id="firefox"] → $ws3
|
||||||
assign [app_id="librewolf"] → $ws3
|
assign [app_id="librewolf"] → $ws3
|
||||||
assign [app_id="nautilus"] → $ws4
|
assign [app_id="pcmanfm"] → $ws4
|
||||||
assign [app_id="libreoffice-calc"] → $ws5
|
assign [app_id="libreoffice-calc"] → $ws5
|
||||||
assign [app_id="libreoffice-writer"] → $ws5
|
assign [app_id="libreoffice-writer"] → $ws5
|
||||||
assign [class="vlc"] → $ws6
|
assign [class="vlc"] → $ws6
|
||||||
|
|
@ -310,9 +310,6 @@ exec dunst
|
||||||
exec 'sleep 2; swaymsg workspace "$ws8"; swaymsg layout tabbed'
|
exec 'sleep 2; swaymsg workspace "$ws8"; swaymsg layout tabbed'
|
||||||
exec mako --default-timeout=5000
|
exec mako --default-timeout=5000
|
||||||
|
|
||||||
# Battery low warning every minute
|
|
||||||
exec_always sh -c 'while :; do battery-alert-swaynag; sleep 60; done' &
|
|
||||||
|
|
||||||
# wallpaper
|
# wallpaper
|
||||||
# output eDP-1 scale 2 scale_filter linear
|
# output eDP-1 scale 2 scale_filter linear
|
||||||
output eDP-1 mode 2880x1920 scale 2 scale_filter linear
|
output eDP-1 mode 2880x1920 scale 2 scale_filter linear
|
||||||
|
|
|
||||||
|
|
@ -17,44 +17,6 @@ let
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
battery-alert-swaynag = pkgs.writeShellScriptBin "battery-alert-swaynag" ''
|
|
||||||
#!/usr/bin/env bash
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
# Detect a battery
|
|
||||||
cap_file=""
|
|
||||||
status_file=""
|
|
||||||
for d in /sys/class/power_supply/BAT*; do
|
|
||||||
if [[ -f "$d/capacity" ]]; then
|
|
||||||
cap_file="$d/capacity"
|
|
||||||
status_file="$d/status"
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [[ -z "$cap_file" ]]; then
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
capacity=$(cat "$cap_file")
|
|
||||||
status=$(cat "$status_file" 2>/dev/null || echo "Unknown")
|
|
||||||
|
|
||||||
if [[ "$capacity" -lt 20 && "$status" != "Charging" && "$status" != "Full" ]]; then
|
|
||||||
stamp="/run/user/$(id -u)/.battery_swaynag_stamp"
|
|
||||||
now=$(date +%s)
|
|
||||||
last=0
|
|
||||||
if [[ -f "$stamp" ]]; then
|
|
||||||
last=$(cat "$stamp" 2>/dev/null || echo 0)
|
|
||||||
fi
|
|
||||||
# Avoid spamming: at most once every 5 minutes
|
|
||||||
if (( now - last >= 300 )); then
|
|
||||||
echo "$now" > "$stamp"
|
|
||||||
swaynag -t warning -m "Battery low: ''${capacity}% - plug in the charger." -b "Dismiss" "true" &
|
|
||||||
disown || true
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
'';
|
|
||||||
|
|
||||||
|
|
||||||
sway-conf = builtins.readFile ./sway.conf + ''
|
sway-conf = builtins.readFile ./sway.conf + ''
|
||||||
exec swaybg -m center -c 252525 -i ~/.wallpaper.png
|
exec swaybg -m center -c 252525 -i ~/.wallpaper.png
|
||||||
|
|
@ -70,7 +32,6 @@ in {
|
||||||
waybar
|
waybar
|
||||||
wayland
|
wayland
|
||||||
wofi
|
wofi
|
||||||
battery-alert-swaynag
|
|
||||||
];
|
];
|
||||||
|
|
||||||
programs.sway = {
|
programs.sway = {
|
||||||
|
|
|
||||||
|
|
@ -1,49 +0,0 @@
|
||||||
{ config, lib, pkgs, ... }:
|
|
||||||
let
|
|
||||||
user = "dominik";
|
|
||||||
home = "/home/${user}";
|
|
||||||
npmPrefix = "${home}/.npm-global";
|
|
||||||
node = pkgs.nodejs; # or pkgs.nodejs_20
|
|
||||||
in {
|
|
||||||
home-manager.users.dominik = { lib, pkgs, ... }: {
|
|
||||||
home.packages = with pkgs; [
|
|
||||||
node
|
|
||||||
gnutar # provides `tar`
|
|
||||||
gzip # provides `gzip` used by tar
|
|
||||||
unzip
|
|
||||||
python314 # useful for codex model use
|
|
||||||
jq # useful for JSON processing
|
|
||||||
];
|
|
||||||
|
|
||||||
# Ensure ~/.npmrc with a user prefix (no sudo needed)
|
|
||||||
home.file.".npmrc"= {
|
|
||||||
text = ''
|
|
||||||
prefix=${npmPrefix}
|
|
||||||
'';
|
|
||||||
force = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
# Ensure the npm bin dir is on PATH for all shells
|
|
||||||
home.sessionPath = [
|
|
||||||
"${npmPrefix}/bin"
|
|
||||||
];
|
|
||||||
|
|
||||||
# Nice-to-have: visible variables in the shell
|
|
||||||
home.sessionVariables = {
|
|
||||||
NPM_CONFIG_PREFIX = npmPrefix;
|
|
||||||
};
|
|
||||||
|
|
||||||
# Auto-install @openai/codex if it's not already there
|
|
||||||
# (idempotent on each `home-manager switch`)
|
|
||||||
home.activation.installCodexCli = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
|
|
||||||
export PATH=${node}/bin:${pkgs.gnutar}/bin:${pkgs.gzip}/bin:${pkgs.unzip}/bin:${pkgs.curl}/bin:$PATH
|
|
||||||
mkdir -p ${npmPrefix}
|
|
||||||
if ! command -v codex >/dev/null 2>&1; then
|
|
||||||
echo "Installing @openai/codex globally..."
|
|
||||||
# --global uses prefix from ~/.npmrc; PATH has node for postinstall
|
|
||||||
${node}/bin/npm install -g @openai/codex
|
|
||||||
fi
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -79,10 +79,6 @@ let
|
||||||
"media.ffmpeg.vaapi-drm-display.enabled" = true;
|
"media.ffmpeg.vaapi-drm-display.enabled" = true;
|
||||||
"gfx.webrender.all" = true;
|
"gfx.webrender.all" = true;
|
||||||
"xpinstall.signatures.required" = false;
|
"xpinstall.signatures.required" = false;
|
||||||
"layers.acceleration.disabled" = false;
|
|
||||||
"gfx.webrender.force-disabled" = false;
|
|
||||||
"gfx.webrender.software" = false;
|
|
||||||
"gfx.webrender.compositor" = true;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
# firefoxUserChrome = ''
|
# firefoxUserChrome = ''
|
||||||
|
|
@ -151,9 +147,6 @@ let
|
||||||
persistHome = "/home/dominik";
|
persistHome = "/home/dominik";
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
imports = [
|
|
||||||
./codex-cli.nix
|
|
||||||
];
|
|
||||||
|
|
||||||
sops.secrets.openai_api_key = {
|
sops.secrets.openai_api_key = {
|
||||||
owner = "dominik";
|
owner = "dominik";
|
||||||
|
|
@ -449,32 +442,6 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
"office@scana11y.com" = {
|
|
||||||
realName = "Dominik Polakovics";
|
|
||||||
address = "office@scana11y.com";
|
|
||||||
userName = "office@scana11y.com";
|
|
||||||
imap = {
|
|
||||||
host = "imap.cloonar.com";
|
|
||||||
port = 993;
|
|
||||||
};
|
|
||||||
smtp = {
|
|
||||||
host = "mail.cloonar.com";
|
|
||||||
port = 587;
|
|
||||||
tls = {
|
|
||||||
enable = true;
|
|
||||||
useStartTls = true;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
thunderbird = {
|
|
||||||
enable = true;
|
|
||||||
profiles = [ "cloonar" "work" ];
|
|
||||||
settings = id: {
|
|
||||||
"mail.identity.id_${id}.reply_on_top" = 1;
|
|
||||||
"mail.identity.id_${id}.sig_bottom" = false;
|
|
||||||
"mail.identity.id_${id}.htmlSigFormat" = true;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
"dominik.polakovics@epicenter.works" = {
|
"dominik.polakovics@epicenter.works" = {
|
||||||
realName = "Dominik Polakovics";
|
realName = "Dominik Polakovics";
|
||||||
address = "dominik.polakovics@epicenter.works";
|
address = "dominik.polakovics@epicenter.works";
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,6 @@
|
||||||
# comment out for first build, so ssh key and config is present
|
# comment out for first build, so ssh key and config is present
|
||||||
# otherwise the build will fail
|
# otherwise the build will fail
|
||||||
./modules/sa-core.nix
|
./modules/sa-core.nix
|
||||||
./modules/scana11y.nix
|
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,123 +1,48 @@
|
||||||
{ config, lib, pkgs, ... }:
|
{ config, pkgs, ... }:
|
||||||
|
|
||||||
with lib;
|
|
||||||
|
|
||||||
let
|
|
||||||
cfg = config.services.sa-core;
|
|
||||||
|
|
||||||
instanceOpts = { name, ... }:
|
|
||||||
{
|
|
||||||
options = {
|
|
||||||
domain = mkOption {
|
|
||||||
type = types.nullOr types.str;
|
|
||||||
default = null;
|
|
||||||
description = lib.mdDoc ''
|
|
||||||
Domain of the website to scan. Defaults to attribute name in instances.
|
|
||||||
'';
|
|
||||||
example = "example.org";
|
|
||||||
};
|
|
||||||
|
|
||||||
email = mkOption {
|
|
||||||
type = types.str;
|
|
||||||
default = "office@scana11y.com";
|
|
||||||
description = lib.mdDoc ''
|
|
||||||
Email where to send scan reports.
|
|
||||||
'';
|
|
||||||
example = "example.org";
|
|
||||||
};
|
|
||||||
|
|
||||||
maxPages = mkOption {
|
|
||||||
type = types.int;
|
|
||||||
default = 100;
|
|
||||||
description = lib.mdDoc ''
|
|
||||||
Maximum number of pages to scan.
|
|
||||||
'';
|
|
||||||
example = "100";
|
|
||||||
};
|
|
||||||
|
|
||||||
timerConfig = mkOption {
|
|
||||||
type = types.attrs;
|
|
||||||
default = {
|
|
||||||
OnCalendar = "monthly";
|
|
||||||
Persistent = true;
|
|
||||||
RandomizedDelaySec = "1h"; # spread load a bit
|
|
||||||
};
|
|
||||||
description = lib.mdDoc ''
|
|
||||||
Configuration for the systemd timer.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
in
|
|
||||||
{
|
{
|
||||||
options.services.sa-core = {
|
virtualisation = {
|
||||||
instances = mkOption {
|
docker.enable = true;
|
||||||
type = types.attrsOf (types.submodule instanceOpts);
|
};
|
||||||
default = {};
|
|
||||||
description = lib.mdDoc "Define ScanA11y instances here.";
|
users.users.scana11y_com.extraGroups = [ "docker" ];
|
||||||
example = literalExpression ''
|
|
||||||
{
|
systemd.services."scana11y-wohnservice-wien.at" = {
|
||||||
"example.org" = {
|
description = "ScanA11y wohnservice-wien.at";
|
||||||
domain = "example.org";
|
wants = [ "docker.service" ];
|
||||||
email = "test@example.org";
|
after = [ "docker.service" "network-online.target" ];
|
||||||
};
|
serviceConfig = {
|
||||||
}
|
Type = "oneshot";
|
||||||
'';
|
User = "scana11y_com";
|
||||||
|
};
|
||||||
|
|
||||||
|
path = [ pkgs.docker pkgs.wkhtmltopdf ];
|
||||||
|
|
||||||
|
script = ''
|
||||||
|
exec ${pkgs.sa-core}/bin/sa-core scan \
|
||||||
|
-domain=wohnservice-wien.at \
|
||||||
|
-depth=3 \
|
||||||
|
-max-pages=100 \
|
||||||
|
-image=cloonar/sa-core:v0.1.3 \
|
||||||
|
-output=/var/www/scana11y.com/reports \
|
||||||
|
-wkhtmltopdf=${pkgs.wkhtmltopdf}/bin/wkhtmltopdf \
|
||||||
|
-email-server=imap.cloonar.com \
|
||||||
|
-email-username=office@scana11y.com \
|
||||||
|
-email-password-file=${config.sops.secrets.sa-core-mailpw.path} \
|
||||||
|
-email-sender=office@scana11y.com \
|
||||||
|
-email-recipient=dominik.polakovics@cloonar.com \
|
||||||
|
-keep 6 \
|
||||||
|
-webroot=https://scana11y.com/reports
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
systemd.timers."scana11y-wohnservice-wien.at" = {
|
||||||
|
wantedBy = [ "timers.target" ];
|
||||||
|
timerConfig = {
|
||||||
|
OnCalendar = "monthly";
|
||||||
|
Persistent = true;
|
||||||
|
RandomizedDelaySec = "1h"; # spread load a bit
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = {
|
sops.secrets.sa-core-mailpw.owner = "scana11y_com"; # written as root at activation
|
||||||
virtualisation = {
|
|
||||||
docker.enable = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
systemd.timers = mapAttrs' (instance: instanceOpts:
|
|
||||||
let
|
|
||||||
domain = if instanceOpts.domain != null then instanceOpts.domain else instance;
|
|
||||||
in
|
|
||||||
nameValuePair ("sa-core-" + domain) {
|
|
||||||
wantedBy = [ "timers.target" ];
|
|
||||||
timerConfig = instanceOpts.timerConfig;
|
|
||||||
}
|
|
||||||
) cfg.instances;
|
|
||||||
|
|
||||||
systemd.services = mapAttrs' (instance: instanceOpts:
|
|
||||||
let
|
|
||||||
domain = if instanceOpts.domain != null then instanceOpts.domain else instance;
|
|
||||||
maxPages = if instanceOpts.maxPages != null then toString instanceOpts.maxPages else "100";
|
|
||||||
in
|
|
||||||
nameValuePair ("sa-core-" + domain) {
|
|
||||||
description = "ScanA11y ${domain}";
|
|
||||||
wants = [ "docker.service" ];
|
|
||||||
after = [ "docker.service" "network-online.target" ];
|
|
||||||
serviceConfig = {
|
|
||||||
Type = "oneshot";
|
|
||||||
User = "scana11y_com";
|
|
||||||
Group= "nginx";
|
|
||||||
SupplementaryGroups = "docker";
|
|
||||||
};
|
|
||||||
|
|
||||||
path = [ pkgs.docker pkgs.wkhtmltopdf ];
|
|
||||||
|
|
||||||
script = ''
|
|
||||||
exec ${pkgs.sa-core}/bin/sa-core scan \
|
|
||||||
-domain=${domain} \
|
|
||||||
-depth=3 \
|
|
||||||
-max-pages=${maxPages} \
|
|
||||||
-image=cloonar/sa-core:v0.1.3 \
|
|
||||||
-output=/var/www/scana11y.com/public/reports \
|
|
||||||
-wkhtmltopdf=${pkgs.wkhtmltopdf}/bin/wkhtmltopdf \
|
|
||||||
-email-server=imap.cloonar.com \
|
|
||||||
-email-username=office@scana11y.com \
|
|
||||||
-email-password-file=${config.sops.secrets.sa-core-mailpw.path} \
|
|
||||||
-email-sender=office@scana11y.com \
|
|
||||||
-email-recipient=${instanceOpts.email} \
|
|
||||||
-keep 6 \
|
|
||||||
-webroot=https://scana11y.com/reports
|
|
||||||
'';
|
|
||||||
}
|
|
||||||
) cfg.instances;
|
|
||||||
|
|
||||||
sops.secrets.sa-core-mailpw.owner = "scana11y_com";
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
{ config, pkgs, ... }:
|
|
||||||
{
|
|
||||||
services.sa-core.instances = {
|
|
||||||
"wohnservice-wien.at" = {
|
|
||||||
email = "dominik.polakovics@cloonar.com";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -2,13 +2,13 @@
|
||||||
let
|
let
|
||||||
saRepoSrc = builtins.fetchGit {
|
saRepoSrc = builtins.fetchGit {
|
||||||
url = "ssh://gitea@git.cloonar.com/ScanA11y/sa-core.git";
|
url = "ssh://gitea@git.cloonar.com/ScanA11y/sa-core.git";
|
||||||
rev = "0d33fdb79b62c270d230ad307341ae107be96600";
|
rev = "daf955c2dffb5d27593746274c33e6e3043c8227";
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
|
|
||||||
buildGoModule rec {
|
buildGoModule rec {
|
||||||
pname = "sa-core";
|
pname = "sa-core";
|
||||||
version = "0.3.2";
|
version = "0.1.0";
|
||||||
|
|
||||||
src = saRepoSrc;
|
src = saRepoSrc;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ in {
|
||||||
enableACME = true;
|
enableACME = true;
|
||||||
acmeRoot = "/var/lib/acme/acme-challenge";
|
acmeRoot = "/var/lib/acme/acme-challenge";
|
||||||
|
|
||||||
root = "${dataDir}/public";
|
root = "${dataDir}";
|
||||||
|
|
||||||
locations."/favicon.ico".extraConfig = ''
|
locations."/favicon.ico".extraConfig = ''
|
||||||
log_not_found off;
|
log_not_found off;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue