Merge branch 'dev' into rc

This commit is contained in:
Otto Winter
2019-01-06 19:38:23 +01:00
parent 1ad65516cf
commit 4046a16d85
227 changed files with 11196 additions and 3511 deletions
+10 -8
View File
@@ -8,8 +8,10 @@ import esphomeyaml.config_validation as cv
from esphomeyaml import automation
from esphomeyaml.const import CONF_CRON, CONF_DAYS_OF_MONTH, CONF_DAYS_OF_WEEK, CONF_HOURS, \
CONF_MINUTES, CONF_MONTHS, CONF_ON_TIME, CONF_SECONDS, CONF_TIMEZONE, CONF_TRIGGER_ID
from esphomeyaml.helpers import App, NoArg, Pvariable, add, add_job, esphomelib_ns, \
ArrayInitializer, Component, Trigger
from esphomeyaml.core import CORE
from esphomeyaml.cpp_generator import add, Pvariable, ArrayInitializer
from esphomeyaml.cpp_types import esphomelib_ns, Component, NoArg, Trigger, App
from esphomeyaml.py_compat import string_types
_LOGGER = logging.getLogger(__name__)
@@ -29,9 +31,9 @@ def _tz_timedelta(td):
offset_second = int(abs(td.total_seconds())) % 60
if offset_hour == 0 and offset_minute == 0 and offset_second == 0:
return '0'
elif offset_minute == 0 and offset_second == 0:
if offset_minute == 0 and offset_second == 0:
return '{}'.format(offset_hour)
elif offset_second == 0:
if offset_second == 0:
return '{}:{}'.format(offset_hour, offset_minute)
return '{}:{}:{}'.format(offset_hour, offset_minute, offset_second)
@@ -118,7 +120,7 @@ def detect_tz():
import pytz
except ImportError:
raise vol.Invalid("No timezone specified and 'tzlocal' not installed. To automatically "
"detect the timezone please install tzlocal (pip2 install tzlocal)")
"detect the timezone please install tzlocal (pip install tzlocal)")
try:
tz = tzlocal.get_localzone()
except pytz.exceptions.UnknownTimeZoneError:
@@ -130,7 +132,7 @@ def detect_tz():
def _parse_cron_int(value, special_mapping, message):
special_mapping = special_mapping or {}
if isinstance(value, (str, unicode)) and value in special_mapping:
if isinstance(value, string_types) and value in special_mapping:
return special_mapping[value]
try:
return int(value)
@@ -139,7 +141,7 @@ def _parse_cron_int(value, special_mapping, message):
def _parse_cron_part(part, min_value, max_value, special_mapping):
if part == '*' or part == '?':
if part in ('*', '?'):
return set(x for x in range(min_value, max_value + 1))
if '/' in part:
data = part.split('/')
@@ -297,7 +299,7 @@ def setup_time_core_(time_var, config):
def setup_time(time_var, config):
add_job(setup_time_core_, time_var, config)
CORE.add_job(setup_time_core_, time_var, config)
BUILD_FLAGS = '-DUSE_TIME'
@@ -0,0 +1,25 @@
from esphomeyaml.components import time as time_
import esphomeyaml.config_validation as cv
from esphomeyaml.const import CONF_ID
from esphomeyaml.cpp_generator import Pvariable
from esphomeyaml.cpp_helpers import setup_component
from esphomeyaml.cpp_types import App
DEPENDENCIES = ['api']
HomeAssistantTime = time_.time_ns.class_('HomeAssistantTime', time_.RealTimeClockComponent)
PLATFORM_SCHEMA = time_.TIME_PLATFORM_SCHEMA.extend({
cv.GenerateID(): cv.declare_variable_id(HomeAssistantTime),
}).extend(cv.COMPONENT_SCHEMA.schema)
def to_code(config):
rhs = App.make_homeassistant_time_component()
ha_time = Pvariable(config[CONF_ID], rhs)
time_.setup_time(ha_time, config)
setup_component(ha_time, config)
BUILD_FLAGS = '-DUSE_HOMEASSISTANT_TIME'
+9 -6
View File
@@ -1,16 +1,17 @@
import voluptuous as vol
import esphomeyaml.config_validation as cv
from esphomeyaml.components import time as time_
from esphomeyaml.const import CONF_ID, CONF_LAMBDA, CONF_SERVERS
from esphomeyaml.helpers import App, Pvariable, add, setup_component
import esphomeyaml.config_validation as cv
from esphomeyaml.const import CONF_ID, CONF_SERVERS
from esphomeyaml.cpp_generator import Pvariable, add
from esphomeyaml.cpp_helpers import setup_component
from esphomeyaml.cpp_types import App
SNTPComponent = time_.time_ns.class_('SNTPComponent', time_.RealTimeClockComponent)
PLATFORM_SCHEMA = time_.TIME_PLATFORM_SCHEMA.extend({
cv.GenerateID(): cv.declare_variable_id(SNTPComponent),
vol.Optional(CONF_SERVERS): vol.All(cv.ensure_list, [cv.string], vol.Length(max=3)),
vol.Optional(CONF_LAMBDA): cv.lambda_,
vol.Optional(CONF_SERVERS): vol.All(cv.ensure_list(cv.domain), vol.Length(min=1, max=3)),
}).extend(cv.COMPONENT_SCHEMA.schema)
@@ -18,7 +19,9 @@ def to_code(config):
rhs = App.make_sntp_component()
sntp = Pvariable(config[CONF_ID], rhs)
if CONF_SERVERS in config:
add(sntp.set_servers(*config[CONF_SERVERS]))
servers = config[CONF_SERVERS]
servers += [''] * (3 - len(servers))
add(sntp.set_servers(*servers))
time_.setup_time(sntp, config)
setup_component(sntp, config)