mirror of
https://github.com/esphome/esphome.git
synced 2026-05-28 04:55:48 +08:00
[wifi] Sync output_power with PHY max TX power to prevent brownout (#14118)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import logging
|
import logging
|
||||||
|
import math
|
||||||
|
|
||||||
from esphome import automation
|
from esphome import automation
|
||||||
from esphome.automation import Condition
|
from esphome.automation import Condition
|
||||||
@@ -493,6 +494,13 @@ async def to_code(config):
|
|||||||
cg.add(var.set_passive_scan(True))
|
cg.add(var.set_passive_scan(True))
|
||||||
if CONF_OUTPUT_POWER in config:
|
if CONF_OUTPUT_POWER in config:
|
||||||
cg.add(var.set_output_power(config[CONF_OUTPUT_POWER]))
|
cg.add(var.set_output_power(config[CONF_OUTPUT_POWER]))
|
||||||
|
if CORE.is_esp32:
|
||||||
|
# Set PHY max TX power to match output_power so calibration also uses
|
||||||
|
# reduced power. This prevents brownout during PHY init on marginal
|
||||||
|
# power supplies, which is critical for OTA updates with rollback enabled.
|
||||||
|
# Kconfig range is 10-20, ESPHome allows 8.5-20.5
|
||||||
|
phy_tx_power = max(10, min(20, math.ceil(config[CONF_OUTPUT_POWER])))
|
||||||
|
add_idf_sdkconfig_option("CONFIG_ESP_PHY_MAX_WIFI_TX_POWER", phy_tx_power)
|
||||||
# enable_on_boot defaults to true in C++ - only set if false
|
# enable_on_boot defaults to true in C++ - only set if false
|
||||||
if not config[CONF_ENABLE_ON_BOOT]:
|
if not config[CONF_ENABLE_ON_BOOT]:
|
||||||
cg.add(var.set_enable_on_boot(False))
|
cg.add(var.set_enable_on_boot(False))
|
||||||
|
|||||||
Reference in New Issue
Block a user