mirror of
https://github.com/Electric-Special/ha-core.git
synced 2026-03-21 05:06:13 +01:00
Recorder total_increasing warning clarifications (#157453)
This commit is contained in:
@@ -394,7 +394,7 @@ def _suggest_report_issue(hass: HomeAssistant, entity_id: str) -> str:
|
||||
def warn_dip(
|
||||
hass: HomeAssistant, entity_id: str, state: State, previous_fstate: float
|
||||
) -> None:
|
||||
"""Log a warning once if a sensor with state_class_total has a decreasing value.
|
||||
"""Log a warning once if a sensor with state class TOTAL_INCREASING 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
|
||||
@@ -415,12 +415,13 @@ def warn_dip(
|
||||
return
|
||||
_LOGGER.warning(
|
||||
(
|
||||
"Entity %s %shas state class total_increasing, but its state is not"
|
||||
"Entity %s %shas state class %s, but its state is not"
|
||||
" strictly increasing. Triggered by state %s (previous state: %s) with"
|
||||
" last_updated set to %s. Please %s"
|
||||
),
|
||||
entity_id,
|
||||
f"from integration {domain} " if domain else "",
|
||||
SensorStateClass.TOTAL_INCREASING,
|
||||
state.state,
|
||||
previous_fstate,
|
||||
state.last_updated.isoformat(),
|
||||
@@ -429,7 +430,7 @@ def warn_dip(
|
||||
|
||||
|
||||
def warn_negative(hass: HomeAssistant, entity_id: str, state: State) -> None:
|
||||
"""Log a warning once if a sensor with state_class_total has a negative value."""
|
||||
"""Log a warning once if a sensor with state class TOTAL_INCREASING has a negative value."""
|
||||
if WARN_NEGATIVE not in hass.data:
|
||||
hass.data[WARN_NEGATIVE] = set()
|
||||
if entity_id not in hass.data[WARN_NEGATIVE]:
|
||||
@@ -438,11 +439,12 @@ def warn_negative(hass: HomeAssistant, entity_id: str, state: State) -> None:
|
||||
domain = entity_info["domain"] if entity_info else None
|
||||
_LOGGER.warning(
|
||||
(
|
||||
"Entity %s %shas state class total_increasing, but its state is "
|
||||
"Entity %s %shas state class %s, but its state is "
|
||||
"negative. Triggered by state %s with last_updated set to %s. Please %s"
|
||||
),
|
||||
entity_id,
|
||||
f"from integration {domain} " if domain else "",
|
||||
SensorStateClass.TOTAL_INCREASING,
|
||||
state.state,
|
||||
state.last_updated.isoformat(),
|
||||
_suggest_report_issue(hass, entity_id),
|
||||
|
||||
Reference in New Issue
Block a user