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

Add climate support (#502)

## Description:


**Related issue (if applicable):** fixes <link to issue>

**Pull request in [esphome-docs](https://github.com/esphome/esphome-docs) with documentation (if applicable):** esphome/esphome-docs#<esphome-docs PR number goes here>
**Pull request in [esphome-core](https://github.com/esphome/esphome-core) with C++ framework changes (if applicable):** esphome/esphome-core#<esphome-core PR number goes here>

## Checklist:
  - [ ] The code change is tested and works locally.
  - [ ] Tests have been added to verify that the new code works (under `tests/` folder).

If user exposed functionality or configuration variables are added/changed:
  - [ ] Documentation added/updated in [esphomedocs](https://github.com/OttoWinter/esphomedocs).
This commit is contained in:
Otto Winter
2019-04-08 21:30:21 +02:00
committed by GitHub
parent 7fd5634a51
commit 526a414743
4 changed files with 208 additions and 12 deletions

View File

@@ -420,7 +420,7 @@ METRIC_SUFFIXES = {
def float_with_unit(quantity, regex_suffix):
pattern = re.compile(ur"^([-+]?[0-9]*\.?[0-9]*)\s*(\w*?)" + regex_suffix + ur"$", re.UNICODE)
pattern = re.compile(r"^([-+]?[0-9]*\.?[0-9]*)\s*(\w*?)" + regex_suffix + r"$", re.UNICODE)
def validator(value):
match = pattern.match(string(value))
@@ -438,21 +438,22 @@ def float_with_unit(quantity, regex_suffix):
return validator
frequency = float_with_unit("frequency", ur"(Hz|HZ|hz)?")
resistance = float_with_unit("resistance", ur"(Ω|Ω|ohm|Ohm|OHM)?")
current = float_with_unit("current", ur"(a|A|amp|Amp|amps|Amps|ampere|Ampere)?")
voltage = float_with_unit("voltage", ur"(v|V|volt|Volts)?")
distance = float_with_unit("distance", ur"(m)")
framerate = float_with_unit("framerate", ur"(FPS|fps|Fps|FpS|Hz)")
_temperature_c = float_with_unit("temperature", ur"(°C|° C|°|C)?")
_temperature_k = float_with_unit("temperature", ur"(° K|° K|K)?")
_temperature_f = float_with_unit("temperature", ur"(°F|° F|F)?")
frequency = float_with_unit("frequency", u"(Hz|HZ|hz)?")
resistance = float_with_unit("resistance", u"(Ω|Ω|ohm|Ohm|OHM)?")
current = float_with_unit("current", u"(a|A|amp|Amp|amps|Amps|ampere|Ampere)?")
voltage = float_with_unit("voltage", u"(v|V|volt|Volts)?")
distance = float_with_unit("distance", u"(m)")
framerate = float_with_unit("framerate", u"(FPS|fps|Fps|FpS|Hz)")
_temperature_c = float_with_unit("temperature", u"(°C|° C|°|C)?")
_temperature_k = float_with_unit("temperature", u"(° K|° K|K)?")
_temperature_f = float_with_unit("temperature", u"(°F|° F|F)?")
if IS_PY2:
# Override voluptuous invalid to unicode for py2
def _vol_invalid_unicode(self):
path = u' @ data[%s]' % u']['.join(map(repr, self.path)) \
if self.path else ''
# pylint: disable=no-member
output = Exception.__unicode__(self)
if self.error_type:
output += u' for ' + self.error_type
@@ -482,8 +483,8 @@ def temperature(value):
raise orig_err
_color_temperature_mireds = float_with_unit('Color Temperature', ur'(mireds|Mireds)')
_color_temperature_kelvin = float_with_unit('Color Temperature', ur'(K|Kelvin)')
_color_temperature_mireds = float_with_unit('Color Temperature', r'(mireds|Mireds)')
_color_temperature_kelvin = float_with_unit('Color Temperature', r'(K|Kelvin)')
def color_temperature(value):