mirror of
https://github.com/esphome/esphome.git
synced 2024-12-26 23:41:45 +01:00
Fix filter_out: nan filer (#486)
* Fix filter_out nan filter Fixes https://github.com/esphome/issues/issues/138 * Add test
This commit is contained in:
parent
948adfd28c
commit
4452473735
2 changed files with 4 additions and 0 deletions
|
@ -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_)
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue