mirror of
https://github.com/esphome/esphome.git
synced 2024-11-27 09:18:00 +01:00
Fix for OTA mode not activating in safe_mode when OTA section has an on_xxxx action (#7796)
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
parent
ea424b0699
commit
1c1f3f7c55
2 changed files with 5 additions and 4 deletions
|
@ -1,10 +1,9 @@
|
|||
import logging
|
||||
|
||||
import esphome.codegen as cg
|
||||
import esphome.config_validation as cv
|
||||
import esphome.final_validate as fv
|
||||
from esphome.components.ota import BASE_OTA_SCHEMA, ota_to_code, OTAComponent
|
||||
from esphome.components.ota import BASE_OTA_SCHEMA, OTAComponent, ota_to_code
|
||||
from esphome.config_helpers import merge_config
|
||||
import esphome.config_validation as cv
|
||||
from esphome.const import (
|
||||
CONF_ESPHOME,
|
||||
CONF_ID,
|
||||
|
@ -18,6 +17,7 @@ from esphome.const import (
|
|||
CONF_VERSION,
|
||||
)
|
||||
from esphome.core import coroutine_with_priority
|
||||
import esphome.final_validate as fv
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@ -124,7 +124,6 @@ FINAL_VALIDATE_SCHEMA = ota_esphome_final_validate
|
|||
@coroutine_with_priority(52.0)
|
||||
async def to_code(config):
|
||||
var = cg.new_Pvariable(config[CONF_ID])
|
||||
await ota_to_code(var, config)
|
||||
cg.add(var.set_port(config[CONF_PORT]))
|
||||
if CONF_PASSWORD in config:
|
||||
cg.add(var.set_auth_password(config[CONF_PASSWORD]))
|
||||
|
@ -132,3 +131,4 @@ async def to_code(config):
|
|||
cg.add_define("USE_OTA_VERSION", config[CONF_VERSION])
|
||||
|
||||
await cg.register_component(var, config)
|
||||
await ota_to_code(var, config)
|
||||
|
|
|
@ -92,6 +92,7 @@ async def to_code(config):
|
|||
|
||||
|
||||
async def ota_to_code(var, config):
|
||||
await cg.past_safe_mode()
|
||||
use_state_callback = False
|
||||
for conf in config.get(CONF_ON_STATE_CHANGE, []):
|
||||
trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var)
|
||||
|
|
Loading…
Reference in a new issue