1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-30 22:53:59 +00:00

Fix docker build

This commit is contained in:
Otto Winter
2018-08-26 11:26:14 +02:00
parent 1576e1847e
commit 74c70509c2
19 changed files with 1086 additions and 28 deletions

View File

@@ -6,13 +6,13 @@ from esphomeyaml.helpers import App, Pvariable, add, esphomelib_ns, RawExpressio
ESP_PLATFORMS = [ESP_PLATFORM_ESP32]
ESP32BLETracker = esphomelib_ns.ESP32BLETracker
ESP32BLEBeacon = esphomelib_ns.ESP32BLEBeacon
CONF_MAJOR = 'major'
CONF_MINOR = 'minor'
CONFIG_SCHEMA = vol.Schema({
cv.GenerateID(): cv.declare_variable_id(ESP32BLETracker),
cv.GenerateID(): cv.declare_variable_id(ESP32BLEBeacon),
vol.Required(CONF_TYPE): vol.All(vol.Upper, cv.one_of('IBEACON')),
vol.Required(CONF_UUID): cv.uuid,
vol.Optional(CONF_MAJOR): cv.uint16_t,

View File

@@ -18,7 +18,7 @@ PLATFORM_SCHEMA = cv.nameable(light.LIGHT_PLATFORM_SCHEMA.extend({
vol.Optional(CONF_GAMMA_CORRECT): cv.positive_float,
vol.Optional(CONF_DEFAULT_TRANSITION_LENGTH): cv.positive_time_period_milliseconds,
vol.Optional(CONF_EFFECTS): light.validate_effects(light.RGB_EFFECTS),
vol.Optional(CONF_EFFECTS): light.validate_effects(light.MONOCHROMATIC_EFFECTS),
}), validate_cold_white_colder)

View File

@@ -8,7 +8,7 @@ from esphomeyaml.const import CONF_BIRTH_MESSAGE, CONF_BROKER, CONF_CLIENT_ID, C
CONF_DISCOVERY_PREFIX, CONF_DISCOVERY_RETAIN, CONF_ID, CONF_KEEPALIVE, CONF_LOG_TOPIC, \
CONF_ON_MESSAGE, CONF_PASSWORD, CONF_PAYLOAD, CONF_PORT, CONF_QOS, CONF_RETAIN, \
CONF_SSL_FINGERPRINTS, CONF_TOPIC, CONF_TOPIC_PREFIX, CONF_TRIGGER_ID, CONF_USERNAME, \
CONF_WILL_MESSAGE, CONF_REBOOT_TIMEOUT
CONF_WILL_MESSAGE, CONF_REBOOT_TIMEOUT, CONF_SHUTDOWN_MESSAGE
from esphomeyaml.helpers import App, ArrayInitializer, Pvariable, RawExpression, \
StructInitializer, \
TemplateArguments, add, esphomelib_ns, optional, std_string
@@ -66,6 +66,7 @@ CONFIG_SCHEMA = vol.Schema({
vol.Optional(CONF_DISCOVERY_PREFIX): cv.publish_topic,
vol.Optional(CONF_BIRTH_MESSAGE): MQTT_MESSAGE_SCHEMA,
vol.Optional(CONF_WILL_MESSAGE): MQTT_MESSAGE_SCHEMA,
vol.Optional(CONF_SHUTDOWN_MESSAGE): MQTT_MESSAGE_SCHEMA,
vol.Optional(CONF_TOPIC_PREFIX): cv.publish_topic,
vol.Optional(CONF_LOG_TOPIC): MQTT_MESSAGE_TEMPLATE_SCHEMA,
vol.Optional(CONF_SSL_FINGERPRINTS): vol.All(cv.only_on_esp8266,
@@ -117,6 +118,12 @@ def to_code(config):
add(mqtt.disable_last_will())
else:
add(mqtt.set_last_will(exp_mqtt_message(will_message)))
if CONF_SHUTDOWN_MESSAGE in config:
shutdown_message = config[CONF_SHUTDOWN_MESSAGE]
if not shutdown_message:
add(mqtt.disable_shutdown_message())
else:
add(mqtt.set_shutdown_message(exp_mqtt_message(shutdown_message)))
if CONF_CLIENT_ID in config:
add(mqtt.set_client_id(config[CONF_CLIENT_ID]))
if CONF_LOG_TOPIC in config:

View File

@@ -43,10 +43,10 @@ def to_code(config):
conf = config[CONF_VOLTAGE]
sensor.register_sensor(hlw.make_voltage_sensor(conf[CONF_NAME]), conf)
if CONF_CURRENT in config:
conf = config[CONF_VOLTAGE]
conf = config[CONF_CURRENT]
sensor.register_sensor(hlw.make_current_sensor(conf[CONF_NAME]), conf)
if CONF_POWER in config:
conf = config[CONF_VOLTAGE]
conf = config[CONF_POWER]
sensor.register_sensor(hlw.make_power_sensor(conf[CONF_NAME]), conf)
if CONF_CURRENT_RESISTOR in config:
add(hlw.set_current_resistor(config[CONF_CURRENT_RESISTOR]))

View File

@@ -33,7 +33,7 @@ def validate_range(value):
value = cv.string(value)
if value.endswith(u'µT') or value.endswith('uT'):
value = value[:-2]
return cv.one_of(*HMC5883L_RANGES)(value)
return cv.one_of(*HMC5883L_RANGES)(int(value))
PLATFORM_SCHEMA = vol.All(sensor.PLATFORM_SCHEMA.extend({

View File

@@ -38,7 +38,7 @@ def to_code(config):
make = variable(config[CONF_MAKE_ID], rhs)
if CONF_GAIN in config:
add(make.Phx711.set_gain(GAINS[CONF_GAIN]))
add(make.Phx711.set_gain(GAINS[config[CONF_GAIN]]))
sensor.setup_sensor(make.Phx711, make.Pmqtt, config)

View File

@@ -48,10 +48,34 @@ def _tz_dst_str(dt):
def detect_tz():
try:
import tzlocal
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)")
tz = tzlocal.get_localzone()
try:
tz = tzlocal.get_localzone()
except pytz.exceptions.UnknownTimeZoneError:
_LOGGER.warning("Could not auto-detect timezone. Using UTC...")
return 'UTC'
def _dst(dt, is_dst):
try:
return tz.dst(dt, is_dst=is_dst)
except TypeError: # stupid pytz...
return tz.dst(dt)
def _tzname(dt, is_dst):
try:
return tz.tzname(dt, is_dst=is_dst)
except TypeError: # stupid pytz...
return tz.tzname(dt)
def _utcoffset(dt, is_dst):
try:
return tz.utcoffset(dt, is_dst=is_dst)
except TypeError: # stupid pytz...
return tz.utcoffset(dt)
dst_begins = None
dst_tzname = None
dst_utcoffset = None
@@ -64,17 +88,17 @@ def detect_tz():
dt = datetime.datetime(year=this_year, month=1, day=1)
last_dst = None
while dt.year == this_year:
current_dst = tz.dst(dt, is_dst=not last_dst)
current_dst = _dst(dt, not last_dst)
is_dst = bool(current_dst)
if is_dst != last_dst:
if is_dst:
dst_begins = dt
dst_tzname = tz.tzname(dt, is_dst=True)
dst_utcoffset = tz.utcoffset(dt, is_dst=True)
dst_tzname = _tzname(dt, True)
dst_utcoffset = _utcoffset(dt, True)
else:
dst_ends = dt + hour
norm_tzname = tz.tzname(dt, is_dst=False)
norm_utcoffset = tz.utcoffset(dt, is_dst=False)
norm_tzname = _tzname(dt, False)
norm_utcoffset = _utcoffset(dt, False)
last_dst = is_dst
dt += hour