Home Assistant Unofficial Reference 2024.12.1
significant_change.py
Go to the documentation of this file.
1 """Helper to test significant Remote state changes."""
2 
3 from __future__ import annotations
4 
5 from typing import Any
6 
7 from homeassistant.core import HomeAssistant, callback
8 
9 from . import ATTR_CURRENT_ACTIVITY
10 
11 
12 @callback
14  hass: HomeAssistant,
15  old_state: str,
16  old_attrs: dict,
17  new_state: str,
18  new_attrs: dict,
19  **kwargs: Any,
20 ) -> bool | None:
21  """Test if state significantly changed."""
22  if old_state != new_state:
23  return True
24 
25  if old_attrs.get(ATTR_CURRENT_ACTIVITY) != new_attrs.get(ATTR_CURRENT_ACTIVITY):
26  return True
27 
28  return False
bool|None async_check_significant_change(HomeAssistant hass, str old_state, dict old_attrs, str new_state, dict new_attrs, **Any kwargs)