Ron Weikamp 43c69c71c2
Add time based integration trigger to Riemann sum integral helper sensor (#110685)
* Schedule max dt for Riemann Integral sensor

* Simplify validation. Dont integrate on change if either old or new state is not numeric.

* Add validation to integration methods. Rollback requirement for both states to be always numeric.

* Use 0 max_dt for disabling time based updates.

* Use docstring instead of pass keyword in abstract methods.

* Use time_period config validation for max_dt

* Use new_state for scheduling max_dt. Only schedule if new state is numeric.

* Use default 0 (None) for max_dt.

* Rename max_dt to max_age.

* Rollback accidental renaming of different file

* Remove unnecessary and nonsensical max value.

* Improve new config description

* Use DurationSelector in config flow

* Rename new config to max_sub_interval

* Simplify by checking once for the integration strategy

* Use positive time period validation of sub interval in platform schema

Co-authored-by: Erik Montnemery <erik@montnemery.com>

* Remove return keyword

Co-authored-by: Erik Montnemery <erik@montnemery.com>

* Simplify scheduling of interval exceeded callback

Co-authored-by: Erik Montnemery <erik@montnemery.com>

* Improve documentation

* Be more clear about when time based integration is disabled.

* Update homeassistant/components/integration/config_flow.py

---------

Co-authored-by: Erik Montnemery <erik@montnemery.com>
2024-05-30 20:40:23 +02:00

16 lines
444 B
Python

"""Constants for the Integration - Riemann sum integral integration."""
DOMAIN = "integration"
CONF_ROUND_DIGITS = "round"
CONF_SOURCE_SENSOR = "source"
CONF_UNIT_OF_MEASUREMENT = "unit"
CONF_UNIT_PREFIX = "unit_prefix"
CONF_UNIT_TIME = "unit_time"
CONF_MAX_SUB_INTERVAL = "max_sub_interval"
METHOD_TRAPEZOIDAL = "trapezoidal"
METHOD_LEFT = "left"
METHOD_RIGHT = "right"
INTEGRATION_METHODS = [METHOD_TRAPEZOIDAL, METHOD_LEFT, METHOD_RIGHT]