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

Implement send_first_at for exponential_moving_average (#3240)

This commit is contained in:
EdJoPaTo
2022-02-21 01:13:06 +01:00
committed by GitHub
parent 771162bfb1
commit 69633826bb
4 changed files with 20 additions and 7 deletions

View File

@@ -408,18 +408,30 @@ async def sliding_window_moving_average_filter_to_code(config, filter_id):
)
@FILTER_REGISTRY.register(
"exponential_moving_average",
ExponentialMovingAverageFilter,
EXPONENTIAL_AVERAGE_SCHEMA = cv.All(
cv.Schema(
{
cv.Optional(CONF_ALPHA, default=0.1): cv.positive_float,
cv.Optional(CONF_SEND_EVERY, default=15): cv.positive_not_null_int,
cv.Optional(CONF_SEND_FIRST_AT, default=1): cv.positive_not_null_int,
}
),
validate_send_first_at,
)
@FILTER_REGISTRY.register(
"exponential_moving_average",
ExponentialMovingAverageFilter,
EXPONENTIAL_AVERAGE_SCHEMA,
)
async def exponential_moving_average_filter_to_code(config, filter_id):
return cg.new_Pvariable(filter_id, config[CONF_ALPHA], config[CONF_SEND_EVERY])
return cg.new_Pvariable(
filter_id,
config[CONF_ALPHA],
config[CONF_SEND_EVERY],
config[CONF_SEND_FIRST_AT],
)
@FILTER_REGISTRY.register(