1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-15 01:32:19 +01:00

[sensor] A little bit of filter clean-up (#9986)

This commit is contained in:
Keith Burzinski
2025-07-31 21:55:59 -05:00
committed by GitHub
parent 0954a6185c
commit 291215909a
4 changed files with 20 additions and 9 deletions

View File

@@ -599,7 +599,9 @@ async def throttle_filter_to_code(config, filter_id):
TIMEOUT_WITH_PRIORITY_SCHEMA = cv.maybe_simple_value(
{
cv.Required(CONF_TIMEOUT): cv.positive_time_period_milliseconds,
cv.Optional(CONF_VALUE, default="nan"): cv.ensure_list(cv.float_),
cv.Optional(CONF_VALUE, default="nan"): cv.Any(
cv.templatable(cv.float_), [cv.templatable(cv.float_)]
),
},
key=CONF_TIMEOUT,
)
@@ -611,6 +613,8 @@ TIMEOUT_WITH_PRIORITY_SCHEMA = cv.maybe_simple_value(
TIMEOUT_WITH_PRIORITY_SCHEMA,
)
async def throttle_with_priority_filter_to_code(config, filter_id):
if not isinstance(config[CONF_VALUE], list):
config[CONF_VALUE] = [config[CONF_VALUE]]
template_ = [await cg.templatable(x, [], float) for x in config[CONF_VALUE]]
return cg.new_Pvariable(filter_id, config[CONF_TIMEOUT], template_)