mirror of
https://github.com/dlitz/esphome-configs-dlitz.git
synced 2026-04-15 22:03:26 -06:00
36 lines
1.2 KiB
YAML
36 lines
1.2 KiB
YAML
substitutions:
|
|
ota_password: !secret fallback_ota_password
|
|
ota_new_password: ""
|
|
ota_update_password: 0
|
|
|
|
esphome:
|
|
on_boot:
|
|
- lambda: |-
|
|
#define OTA_UPDATE_PASSWORD ${ota_update_password}
|
|
#if !(OTA_UPDATE_PASSWORD == 0 || OTA_UPDATE_PASSWORD == 1)
|
|
# error ota_update_password must be 0 or 1
|
|
#endif
|
|
#ifdef USE_OTA_PASSWORD
|
|
const bool ota_update_password = bool(OTA_UPDATE_PASSWORD);
|
|
const std::string ota_new_password = "${ota_new_password}";
|
|
if (ota_update_password) {
|
|
if (ota_new_password.empty()) {
|
|
ESP_LOGI("ota_update_password", "Setting blank OTA password");
|
|
} else {
|
|
ESP_LOGI("ota_update_password", "Setting new OTA password");
|
|
}
|
|
id(ota_id).set_auth_password(ota_new_password);
|
|
} else {
|
|
ESP_LOGI("ota_update_password", "No new OTA password");
|
|
}
|
|
#elif OTA_UPDATE_PASSWORD == 1
|
|
# error Cannot set new OTA password - not compiled with OTA support (hint: set a dummy ota_password)
|
|
#else
|
|
# warning No OTA password set.
|
|
#endif
|
|
|
|
ota:
|
|
- id: !extend ota_id
|
|
platform: esphome
|
|
password: "${ota_password or ota_new_password}"
|