feat: esphome updates
This commit is contained in:
@@ -6,4 +6,4 @@ https://github.com/tasmota/mgos32-to-tasmota32/releases
|
||||
In Tasmota make OTA Update to minimal:
|
||||
http://ota.tasmota.com/tasmota/release/tasmota-minimal.bin.gz
|
||||
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
|
||||
docker run --rm -p 6052:6052 -e ESPHOME_DASHBOARD_USE_PING=true -v "${PWD}":/config -it ghcr.io/esphome/esphome:latest
|
||||
|
||||
19
esphome/archive/install.yaml
Normal file
19
esphome/archive/install.yaml
Normal file
@@ -0,0 +1,19 @@
|
||||
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,8 +5,6 @@ substitutions:
|
||||
esphome:
|
||||
name: ${device_name}
|
||||
comment: ${friendly_name}
|
||||
platform: ESP8266
|
||||
board: esp01_1m
|
||||
on_boot:
|
||||
priority: 300
|
||||
then:
|
||||
@@ -24,6 +22,9 @@ esphome:
|
||||
blue: 0%
|
||||
white: 100%
|
||||
|
||||
esp8266:
|
||||
board: esp01_1m
|
||||
|
||||
interval:
|
||||
- interval: 15s
|
||||
then:
|
||||
@@ -37,6 +38,7 @@ interval:
|
||||
|
||||
# Enable Home Assistant API
|
||||
api:
|
||||
batch_delay: 0ms
|
||||
|
||||
ota:
|
||||
platform: esphome
|
||||
|
||||
@@ -5,8 +5,6 @@ substitutions:
|
||||
esphome:
|
||||
name: ${device_name}
|
||||
comment: ${friendly_name}
|
||||
platform: ESP8266
|
||||
board: esp01_1m
|
||||
on_boot:
|
||||
priority: 300
|
||||
then:
|
||||
@@ -24,6 +22,9 @@ esphome:
|
||||
blue: 0%
|
||||
white: 100%
|
||||
|
||||
esp8266:
|
||||
board: esp01_1m
|
||||
|
||||
interval:
|
||||
- interval: 15s
|
||||
then:
|
||||
@@ -37,6 +38,7 @@ interval:
|
||||
|
||||
# Enable Home Assistant API
|
||||
api:
|
||||
batch_delay: 0ms
|
||||
|
||||
ota:
|
||||
platform: esphome
|
||||
|
||||
@@ -5,8 +5,6 @@ substitutions:
|
||||
esphome:
|
||||
name: ${device_name}
|
||||
comment: ${friendly_name}
|
||||
platform: ESP8266
|
||||
board: esp01_1m
|
||||
on_boot:
|
||||
priority: 300
|
||||
then:
|
||||
@@ -24,6 +22,9 @@ esphome:
|
||||
blue: 0%
|
||||
white: 100%
|
||||
|
||||
esp8266:
|
||||
board: esp01_1m
|
||||
|
||||
interval:
|
||||
- interval: 15s
|
||||
then:
|
||||
@@ -37,6 +38,7 @@ interval:
|
||||
|
||||
# Enable Home Assistant API
|
||||
api:
|
||||
batch_delay: 0ms
|
||||
|
||||
ota:
|
||||
platform: esphome
|
||||
|
||||
@@ -5,8 +5,6 @@ substitutions:
|
||||
esphome:
|
||||
name: ${device_name}
|
||||
comment: ${friendly_name}
|
||||
platform: ESP8266
|
||||
board: esp01_1m
|
||||
on_boot:
|
||||
priority: 300
|
||||
then:
|
||||
@@ -24,6 +22,9 @@ esphome:
|
||||
blue: 0%
|
||||
white: 100%
|
||||
|
||||
esp8266:
|
||||
board: esp01_1m
|
||||
|
||||
interval:
|
||||
- interval: 15s
|
||||
then:
|
||||
@@ -37,6 +38,7 @@ interval:
|
||||
|
||||
# Enable Home Assistant API
|
||||
api:
|
||||
batch_delay: 0ms
|
||||
|
||||
ota:
|
||||
platform: esphome
|
||||
|
||||
@@ -5,8 +5,6 @@ substitutions:
|
||||
esphome:
|
||||
name: ${device_name}
|
||||
comment: ${friendly_name}
|
||||
platform: ESP8266
|
||||
board: esp01_1m
|
||||
on_boot:
|
||||
priority: 300
|
||||
then:
|
||||
@@ -24,6 +22,9 @@ esphome:
|
||||
blue: 0%
|
||||
white: 100%
|
||||
|
||||
esp8266:
|
||||
board: esp01_1m
|
||||
|
||||
interval:
|
||||
- interval: 15s
|
||||
then:
|
||||
@@ -37,6 +38,7 @@ interval:
|
||||
|
||||
# Enable Home Assistant API
|
||||
api:
|
||||
batch_delay: 0ms
|
||||
|
||||
ota:
|
||||
platform: esphome
|
||||
|
||||
@@ -5,8 +5,6 @@ substitutions:
|
||||
esphome:
|
||||
name: ${device_name}
|
||||
comment: ${friendly_name}
|
||||
platform: ESP8266
|
||||
board: esp01_1m
|
||||
on_boot:
|
||||
priority: 300
|
||||
then:
|
||||
@@ -24,6 +22,9 @@ esphome:
|
||||
blue: 0%
|
||||
white: 100%
|
||||
|
||||
esp8266:
|
||||
board: esp01_1m
|
||||
|
||||
interval:
|
||||
- interval: 15s
|
||||
then:
|
||||
@@ -37,6 +38,7 @@ interval:
|
||||
|
||||
# Enable Home Assistant API
|
||||
api:
|
||||
batch_delay: 0ms
|
||||
|
||||
ota:
|
||||
platform: esphome
|
||||
|
||||
@@ -5,8 +5,6 @@ substitutions:
|
||||
esphome:
|
||||
name: ${device_name}
|
||||
comment: ${friendly_name}
|
||||
platform: ESP8266
|
||||
board: esp01_1m
|
||||
on_boot:
|
||||
priority: 300
|
||||
then:
|
||||
@@ -24,6 +22,9 @@ esphome:
|
||||
blue: 0%
|
||||
white: 100%
|
||||
|
||||
esp8266:
|
||||
board: esp01_1m
|
||||
|
||||
interval:
|
||||
- interval: 15s
|
||||
then:
|
||||
@@ -37,6 +38,7 @@ interval:
|
||||
|
||||
# Enable Home Assistant API
|
||||
api:
|
||||
batch_delay: 0ms
|
||||
|
||||
ota:
|
||||
platform: esphome
|
||||
|
||||
@@ -5,8 +5,6 @@ substitutions:
|
||||
esphome:
|
||||
name: ${device_name}
|
||||
comment: ${friendly_name}
|
||||
platform: ESP8266
|
||||
board: esp01_1m
|
||||
on_boot:
|
||||
priority: 300
|
||||
then:
|
||||
@@ -24,6 +22,9 @@ esphome:
|
||||
blue: 0%
|
||||
white: 100%
|
||||
|
||||
esp8266:
|
||||
board: esp01_1m
|
||||
|
||||
interval:
|
||||
- interval: 15s
|
||||
then:
|
||||
@@ -37,6 +38,7 @@ interval:
|
||||
|
||||
# Enable Home Assistant API
|
||||
api:
|
||||
batch_delay: 0ms
|
||||
|
||||
ota:
|
||||
platform: esphome
|
||||
|
||||
@@ -56,13 +56,14 @@ 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: false
|
||||
fast_connect: True
|
||||
domain: "${dns_domain}"
|
||||
|
||||
# Your hidden network
|
||||
@@ -84,7 +85,6 @@ wifi:
|
||||
ssid: "${name}_AP"
|
||||
password: "bulb_fallback_pw"
|
||||
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:
|
||||
- platform: status
|
||||
|
||||
@@ -10,7 +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"
|
||||
|
||||
esphome:
|
||||
name: "${name}"
|
||||
@@ -43,7 +42,7 @@ interval:
|
||||
then:
|
||||
- if:
|
||||
condition:
|
||||
api.connected: # check if api connected
|
||||
api.connected:
|
||||
else:
|
||||
- light.turn_on:
|
||||
id: rgbww_light
|
||||
@@ -57,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
|
||||
channel: 1
|
||||
hidden: True
|
||||
hidden: true
|
||||
|
||||
manual_ip:
|
||||
static_ip: 10.42.100.12
|
||||
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
|
||||
@@ -90,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
|
||||
@@ -98,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
|
||||
@@ -153,55 +164,47 @@ 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;
|
||||
seconds %= 3600;
|
||||
int minutes = seconds / 60;
|
||||
seconds = seconds % 60;
|
||||
if ( days > 3650 ) {
|
||||
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 == "";'
|
||||
|
||||
@@ -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}"
|
||||
@@ -54,7 +42,7 @@ interval:
|
||||
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,55 +164,47 @@ 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;
|
||||
seconds %= 3600;
|
||||
int minutes = seconds / 60;
|
||||
seconds = seconds % 60;
|
||||
if ( days > 3650 ) {
|
||||
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 == "";'
|
||||
|
||||
@@ -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}"
|
||||
@@ -54,7 +42,7 @@ interval:
|
||||
then:
|
||||
- if:
|
||||
condition:
|
||||
api.connected: # check if api connected
|
||||
api.connected:
|
||||
else:
|
||||
- light.turn_on:
|
||||
id: rgbww_light
|
||||
@@ -68,21 +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.14
|
||||
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
|
||||
@@ -100,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
|
||||
@@ -108,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
|
||||
@@ -163,55 +164,47 @@ 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;
|
||||
seconds %= 3600;
|
||||
int minutes = seconds / 60;
|
||||
seconds = seconds % 60;
|
||||
if ( days > 3650 ) {
|
||||
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 == "";'
|
||||
|
||||
@@ -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}"
|
||||
@@ -54,7 +42,7 @@ interval:
|
||||
then:
|
||||
- if:
|
||||
condition:
|
||||
api.connected: # check if api connected
|
||||
api.connected:
|
||||
else:
|
||||
- light.turn_on:
|
||||
id: rgbww_light
|
||||
@@ -68,21 +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.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
|
||||
@@ -100,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
|
||||
@@ -108,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
|
||||
@@ -163,55 +164,47 @@ 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;
|
||||
seconds %= 3600;
|
||||
int minutes = seconds / 60;
|
||||
seconds = seconds % 60;
|
||||
if ( days > 3650 ) {
|
||||
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 == "";'
|
||||
|
||||
@@ -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}"
|
||||
@@ -54,7 +42,7 @@ interval:
|
||||
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.16
|
||||
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,55 +164,47 @@ 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;
|
||||
seconds %= 3600;
|
||||
int minutes = seconds / 60;
|
||||
seconds = seconds % 60;
|
||||
if ( days > 3650 ) {
|
||||
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 == "";'
|
||||
|
||||
@@ -5,8 +5,6 @@ substitutions:
|
||||
esphome:
|
||||
name: ${device_name}
|
||||
comment: ${friendly_name}
|
||||
platform: ESP8266
|
||||
board: esp01_1m
|
||||
on_boot:
|
||||
then:
|
||||
- light.turn_on:
|
||||
@@ -20,7 +18,8 @@ esphome:
|
||||
id: my_light
|
||||
color_temperature: 2700 K
|
||||
|
||||
|
||||
esp8266:
|
||||
board: esp01_1m
|
||||
|
||||
interval:
|
||||
- interval: 15s
|
||||
@@ -40,6 +39,7 @@ interval:
|
||||
|
||||
# Enable Home Assistant API
|
||||
api:
|
||||
batch_delay: 0ms
|
||||
|
||||
ota:
|
||||
platform: esphome
|
||||
|
||||
49
hosts/nb/users/codex-cli.nix
Normal file
49
hosts/nb/users/codex-cli.nix
Normal file
@@ -0,0 +1,49 @@
|
||||
{ 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
|
||||
'';
|
||||
};
|
||||
}
|
||||
@@ -147,6 +147,9 @@ let
|
||||
persistHome = "/home/dominik";
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
./codex-cli.nix
|
||||
];
|
||||
|
||||
sops.secrets.openai_api_key = {
|
||||
owner = "dominik";
|
||||
|
||||
Reference in New Issue
Block a user