mirror of
https://github.com/esphome/esphome.git
synced 2025-10-30 06:33:51 +00:00
Add wifi output_power setting (#853)
* Add wifi output_power setting
See also:
- https://github.com/esphome/feature-requests/issues/471#issuecomment-552350467
- https://github.com/esp8266/Arduino/issues/6366
- https://github.com/esp8266/Arduino/issues/6471
- 849f8cf920/code/espurna/config/general.h (L593-L599)
- https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/network/esp_wifi.html#_CPPv425esp_wifi_set_max_tx_power6int8_t
* Lint
This commit is contained in:
@@ -110,6 +110,7 @@ def validate(config):
|
||||
return config
|
||||
|
||||
|
||||
CONF_OUTPUT_POWER = 'output_power'
|
||||
CONFIG_SCHEMA = cv.All(cv.Schema({
|
||||
cv.GenerateID(): cv.declare_id(WiFiComponent),
|
||||
cv.Optional(CONF_NETWORKS): cv.ensure_list(WIFI_NETWORK_STA),
|
||||
@@ -125,6 +126,7 @@ CONFIG_SCHEMA = cv.All(cv.Schema({
|
||||
cv.enum(WIFI_POWER_SAVE_MODES, upper=True),
|
||||
cv.Optional(CONF_FAST_CONNECT, default=False): cv.boolean,
|
||||
cv.Optional(CONF_USE_ADDRESS): cv.string_strict,
|
||||
cv.Optional(CONF_OUTPUT_POWER): cv.All(cv.decibel, cv.float_range(min=10.0, max=20.5)),
|
||||
|
||||
cv.Optional('hostname'): cv.invalid("The hostname option has been removed in 1.11.0"),
|
||||
}), validate)
|
||||
@@ -186,6 +188,8 @@ def to_code(config):
|
||||
cg.add(var.set_reboot_timeout(config[CONF_REBOOT_TIMEOUT]))
|
||||
cg.add(var.set_power_save_mode(config[CONF_POWER_SAVE_MODE]))
|
||||
cg.add(var.set_fast_connect(config[CONF_FAST_CONNECT]))
|
||||
if CONF_OUTPUT_POWER in config:
|
||||
cg.add(var.set_output_power(config[CONF_OUTPUT_POWER]))
|
||||
|
||||
if CORE.is_esp8266:
|
||||
cg.add_library('ESP8266WiFi', None)
|
||||
|
||||
Reference in New Issue
Block a user