1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-03 20:02:22 +01:00

Disallow power_save_mode NONE if used together with BLE (#1950)

This commit is contained in:
Otto Winter
2021-06-22 10:53:10 +02:00
committed by GitHub
parent 3dfff2930a
commit bfca3f242a
4 changed files with 66 additions and 15 deletions

View File

@@ -148,7 +148,41 @@ def final_validate(config):
)
FINAL_VALIDATE_SCHEMA = cv.Schema(final_validate)
def final_validate_power_esp32_ble(value):
if not CORE.is_esp32:
return
if value != "NONE":
# WiFi should be in modem sleep (!=NONE) with BLE coexistence
# https://docs.espressif.com/projects/esp-idf/en/v3.3.5/api-guides/wifi.html#station-sleep
return
framework_version = fv.get_arduino_framework_version()
if framework_version not in (None, "dev") and framework_version < "1.0.5":
# Only frameworks 1.0.5+ impacted
return
full = fv.full_config.get()
for conflicting in [
"esp32_ble",
"esp32_ble_beacon",
"esp32_ble_server",
"esp32_ble_tracker",
]:
if conflicting in full:
raise cv.Invalid(
f"power_save_mode NONE is incompatible with {conflicting}. "
f"Please remove the power save mode. See also "
f"https://github.com/esphome/issues/issues/2141#issuecomment-865688582"
)
FINAL_VALIDATE_SCHEMA = cv.All(
cv.Schema(
{
cv.Optional(CONF_POWER_SAVE_MODE): final_validate_power_esp32_ble,
},
extra=cv.ALLOW_EXTRA,
),
final_validate,
)
def _validate(config):