1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-06 05:12:21 +01:00

Add ESP32 Camera (#475)

* Add ESP32 Camera

* Fixes

* Updates

* Fix substitutions not working for non-ASCII

* Update docker base image to 1.3.0
This commit is contained in:
Otto Winter
2019-03-13 16:40:09 +01:00
committed by GitHub
parent c4ada8c9f0
commit f3ec83fe31
9 changed files with 213 additions and 8 deletions

View File

@@ -28,6 +28,7 @@ port = vol.All(vol.Coerce(int), vol.Range(min=1, max=65535))
float_ = vol.Coerce(float)
positive_float = vol.All(float_, vol.Range(min=0))
zero_to_one_float = vol.All(float_, vol.Range(min=0, max=1))
negative_one_to_one_float = vol.All(float_, vol.Range(min=-1, max=1))
positive_int = vol.All(vol.Coerce(int), vol.Range(min=0))
positive_not_null_int = vol.All(vol.Coerce(int), vol.Range(min=0, min_included=False))
@@ -442,6 +443,7 @@ resistance = float_with_unit("resistance", r"(Ω|Ω|ohm|Ohm|OHM)?")
current = float_with_unit("current", r"(a|A|amp|Amp|amps|Amps|ampere|Ampere)?")
voltage = float_with_unit("voltage", r"(v|V|volt|Volts)?")
distance = float_with_unit("distance", r"(m)")
framerate = float_with_unit("framerate", r"(FPS|fps|Fps|FpS|Hz)")
def validate_bytes(value):
@@ -606,6 +608,11 @@ i2c_address = hex_uint8_t
def percentage(value):
value = possibly_negative_percentage(value)
return zero_to_one_float(value)
def possibly_negative_percentage(value):
has_percent_sign = isinstance(value, string_types) and value.endswith('%')
if has_percent_sign:
value = float(value[:-1].rstrip()) / 100.0
@@ -614,7 +621,12 @@ def percentage(value):
if not has_percent_sign:
msg += " Please put a percent sign after the number!"
raise vol.Invalid(msg)
return zero_to_one_float(value)
if value < -1:
msg = "Percentage must not be smaller than -100%."
if not has_percent_sign:
msg += " Please put a percent sign after the number!"
raise vol.Invalid(msg)
return negative_one_to_one_float(value)
def percentage_int(value):