Functions | |
| list[tuple[float, State]] | _entity_history_to_float_and_state (Iterable[State] entity_history) |
| bool | _equivalent_units (set[str|None] units) |
| list[State] | _get_sensor_states (HomeAssistant hass) |
| set[str|None] | _get_units (list[tuple[float, State]] fstates) |
| bool | _is_numeric (State state) |
| str|None | _last_reset_as_utc_isoformat (Any last_reset_s, str entity_id) |
| tuple[str|None, list[tuple[float, State]]] | _normalize_states (HomeAssistant hass, dict[str, tuple[int, StatisticMetaData]] old_metadatas, list[tuple[float, State]] fstates, str entity_id) |
| str | _suggest_report_issue (HomeAssistant hass, str entity_id) |
| float | _time_weighted_average (list[tuple[float, State]] fstates, datetime.datetime start, datetime.datetime end) |
| str|None | _timestamp_to_isoformat_or_none (float|None timestamp) |
| None | _update_issues (Callable[[str, str, dict[str, Any]], None] report_issue, list[State] sensor_states, dict[str, tuple[int, StatisticMetaData]] metadatas) |
| dict[str, set[str]] | _wanted_statistics (list[State] sensor_states) |
| statistics.PlatformCompiledStatistics | compile_statistics (HomeAssistant hass, Session session, datetime.datetime start, datetime.datetime end) |
| dict | list_statistic_ids (HomeAssistant hass, list[str]|tuple[str]|None statistic_ids=None, str|None statistic_type=None) |
| bool | reset_detected (HomeAssistant hass, str entity_id, float fstate, float|None previous_fstate, State state) |
| None | update_statistics_issues (HomeAssistant hass, Session session) |
| dict[str, list[statistics.ValidationIssue]] | validate_statistics (HomeAssistant hass) |
| None | warn_dip (HomeAssistant hass, str entity_id, State state, float previous_fstate) |
| None | warn_negative (HomeAssistant hass, str entity_id, State state) |
Variables | |
| _LOGGER = logging.getLogger(__name__) | |
| dictionary | DEFAULT_STATISTICS |
| dictionary | EQUIVALENT_UNITS |
| string | LINK_DEV_STATISTICS = "https://my.home-assistant.io/redirect/developer_statistics" |
Statistics helper for sensor.
|
private |
Return a list of (float, state) tuples for the given entity.
Definition at line 165 of file recorder.py.
|
private |
Return True if the units are equivalent.
Definition at line 154 of file recorder.py.
|
private |
Get the current state of all sensors for which to compile statistics.
Definition at line 83 of file recorder.py.
|
private |
Return a set of all units.
Definition at line 149 of file recorder.py.
|
private |
Return if the state is numeric.
Definition at line 183 of file recorder.py.
|
private |
Parse last_reset and convert it to UTC.
Definition at line 382 of file recorder.py.
|
private |
Normalize units.
Definition at line 191 of file recorder.py.
|
private |
Suggest to report an issue.
Definition at line 286 of file recorder.py.
|
private |
Calculate a time weighted average. The average is calculated by weighting the states by duration in seconds between state changes. Note: there's no interpolation of values between state changes.
Definition at line 102 of file recorder.py.
|
private |
Convert a timestamp to ISO format or return None.
Definition at line 398 of file recorder.py.
|
private |
Update repair issues.
Definition at line 687 of file recorder.py.
|
private |
Prepare a dict with wanted statistics for entities.
Definition at line 374 of file recorder.py.
| statistics.PlatformCompiledStatistics homeassistant.components.sensor.recorder.compile_statistics | ( | HomeAssistant | hass, |
| Session | session, | ||
| datetime.datetime | start, | ||
| datetime.datetime | end | ||
| ) |
Compile statistics for all entities during start-end.
Definition at line 405 of file recorder.py.
| dict homeassistant.components.sensor.recorder.list_statistic_ids | ( | HomeAssistant | hass, |
| list[str] | tuple[str] | None | statistic_ids = None, |
||
| str | None | statistic_type = None |
||
| ) |
Return all or filtered statistic_ids and meta data.
Definition at line 646 of file recorder.py.
| bool homeassistant.components.sensor.recorder.reset_detected | ( | HomeAssistant | hass, |
| str | entity_id, | ||
| float | fstate, | ||
| float | None | previous_fstate, | ||
| State | state | ||
| ) |
Test if a total_increasing sensor has been reset.
Definition at line 353 of file recorder.py.
| None homeassistant.components.sensor.recorder.update_statistics_issues | ( | HomeAssistant | hass, |
| Session | session | ||
| ) |
Validate statistics.
Definition at line 741 of file recorder.py.
| dict[str, list[statistics.ValidationIssue]] homeassistant.components.sensor.recorder.validate_statistics | ( | HomeAssistant | hass | ) |
Validate statistics.
Definition at line 798 of file recorder.py.
| None homeassistant.components.sensor.recorder.warn_dip | ( | HomeAssistant | hass, |
| str | entity_id, | ||
| State | state, | ||
| float | previous_fstate | ||
| ) |
Log a warning once if a sensor with state_class_total has a decreasing value. The log will be suppressed until two dips have been seen to prevent warning due to rounding issues with databases storing the state as a single precision float, which was fixed in recorder DB version 20.
Definition at line 295 of file recorder.py.
| None homeassistant.components.sensor.recorder.warn_negative | ( | HomeAssistant | hass, |
| str | entity_id, | ||
| State | state | ||
| ) |
Log a warning once if a sensor with state_class_total has a negative value.
Definition at line 332 of file recorder.py.
|
private |
Definition at line 53 of file recorder.py.
| dictionary homeassistant.components.sensor.recorder.DEFAULT_STATISTICS |
Definition at line 55 of file recorder.py.
| dictionary homeassistant.components.sensor.recorder.EQUIVALENT_UNITS |
Definition at line 61 of file recorder.py.
| string homeassistant.components.sensor.recorder.LINK_DEV_STATISTICS = "https://my.home-assistant.io/redirect/developer_statistics" |
Definition at line 80 of file recorder.py.