From 445247373595caa151d2a08c43b6795d7cb7d219 Mon Sep 17 00:00:00 2001 From: Otto Winter Date: Mon, 18 Mar 2019 15:07:20 +0100 Subject: [PATCH 1/3] Fix filter_out: nan filer (#486) * Fix filter_out nan filter Fixes https://github.com/esphome/issues/issues/138 * Add test --- esphome/cpp_generator.py | 3 +++ tests/test1.yaml | 1 + 2 files changed, 4 insertions(+) diff --git a/esphome/cpp_generator.py b/esphome/cpp_generator.py index 5b6f004bb7..f2f2f058ff 100644 --- a/esphome/cpp_generator.py +++ b/esphome/cpp_generator.py @@ -1,4 +1,5 @@ from collections import OrderedDict +import math from esphome.core import CORE, HexInt, Lambda, TimePeriod, TimePeriodMicroseconds, \ TimePeriodMilliseconds, TimePeriodSeconds, TimePeriodMinutes @@ -260,6 +261,8 @@ class FloatLiteral(Literal): self.float_ = value def __str__(self): + if math.isnan(self.float_): + return u"NAN" return u"{:f}f".format(self.float_) diff --git a/tests/test1.yaml b/tests/test1.yaml index 4cd77c1b07..ff75ac29eb 100644 --- a/tests/test1.yaml +++ b/tests/test1.yaml @@ -173,6 +173,7 @@ sensor: - 40.0 -> 45.0 - 100.0 -> 102.5 - filter_out: 42.0 + - filter_out: nan - sliding_window_moving_average: window_size: 15 send_every: 15 From 475aa4879c6d9bda2a8736021bfe26940af51484 Mon Sep 17 00:00:00 2001 From: Otto Winter Date: Wed, 20 Mar 2019 13:10:16 +0100 Subject: [PATCH 2/3] Fix IPAddress in validate (#488) Fixes https://github.com/esphome/issues/issues/141 --- esphome/yaml_util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/yaml_util.py b/esphome/yaml_util.py index a47d6d8122..96132e69fd 100644 --- a/esphome/yaml_util.py +++ b/esphome/yaml_util.py @@ -328,7 +328,7 @@ def represent_odict(dump, tag, mapping, flow_style=None): def represent_secret(value): - return yaml.ScalarNode(tag=u'!secret', value=_SECRET_VALUES[value]) + return yaml.ScalarNode(tag=u'!secret', value=_SECRET_VALUES[text_type(value)]) def unicode_representer(_, uni): From 6ccab2bef9078c8f507ed61706a9a9f2c5046efa Mon Sep 17 00:00:00 2001 From: Otto Winter Date: Wed, 20 Mar 2019 13:11:55 +0100 Subject: [PATCH 3/3] Bump version to v1.12.1 --- esphome/const.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/esphome/const.py b/esphome/const.py index 3d3be081f4..088750b93b 100644 --- a/esphome/const.py +++ b/esphome/const.py @@ -2,10 +2,10 @@ MAJOR_VERSION = 1 MINOR_VERSION = 12 -PATCH_VERSION = '0' +PATCH_VERSION = '1' __short_version__ = '{}.{}'.format(MAJOR_VERSION, MINOR_VERSION) __version__ = '{}.{}'.format(__short_version__, PATCH_VERSION) -ESPHOME_CORE_VERSION = '1.12.0' +ESPHOME_CORE_VERSION = '1.12.1' ESP_PLATFORM_ESP32 = 'ESP32' ESP_PLATFORM_ESP8266 = 'ESP8266'