mirror of
https://github.com/esphome/esphome.git
synced 2025-10-12 14:53:49 +01:00
add-black (#1593)
* Add black Update pre commit Update pre commit add empty line * Format with black
This commit is contained in:
committed by
GitHub
parent
2b60b0f1fa
commit
69879920eb
@@ -5,25 +5,28 @@ from esphome.core import CORE
|
||||
from esphome.const import CONF_ID, CONF_SERVERS
|
||||
|
||||
|
||||
DEPENDENCIES = ['network']
|
||||
sntp_ns = cg.esphome_ns.namespace('sntp')
|
||||
SNTPComponent = sntp_ns.class_('SNTPComponent', time_.RealTimeClock)
|
||||
DEPENDENCIES = ["network"]
|
||||
sntp_ns = cg.esphome_ns.namespace("sntp")
|
||||
SNTPComponent = sntp_ns.class_("SNTPComponent", time_.RealTimeClock)
|
||||
|
||||
|
||||
DEFAULT_SERVERS = ["0.pool.ntp.org", "1.pool.ntp.org", "2.pool.ntp.org"]
|
||||
|
||||
CONFIG_SCHEMA = time_.TIME_SCHEMA.extend({
|
||||
cv.GenerateID(): cv.declare_id(SNTPComponent),
|
||||
cv.Optional(CONF_SERVERS, default=DEFAULT_SERVERS):
|
||||
cv.All(cv.ensure_list(cv.domain), cv.Length(min=1, max=3)),
|
||||
}).extend(cv.COMPONENT_SCHEMA)
|
||||
CONFIG_SCHEMA = time_.TIME_SCHEMA.extend(
|
||||
{
|
||||
cv.GenerateID(): cv.declare_id(SNTPComponent),
|
||||
cv.Optional(CONF_SERVERS, default=DEFAULT_SERVERS): cv.All(
|
||||
cv.ensure_list(cv.domain), cv.Length(min=1, max=3)
|
||||
),
|
||||
}
|
||||
).extend(cv.COMPONENT_SCHEMA)
|
||||
|
||||
|
||||
def to_code(config):
|
||||
var = cg.new_Pvariable(config[CONF_ID])
|
||||
|
||||
servers = config[CONF_SERVERS]
|
||||
servers += [''] * (3 - len(servers))
|
||||
servers += [""] * (3 - len(servers))
|
||||
cg.add(var.set_servers(*servers))
|
||||
|
||||
yield cg.register_component(var, config)
|
||||
@@ -31,4 +34,4 @@ def to_code(config):
|
||||
|
||||
if CORE.is_esp8266 and len(servers) > 1:
|
||||
# We need LwIP features enabled to get 3 SNTP servers (not just one)
|
||||
cg.add_build_flag('-DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY')
|
||||
cg.add_build_flag("-DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY")
|
||||
|
Reference in New Issue
Block a user