mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
Deprecate event decorators (#5822)
This commit is contained in:
parent
2cbed9cd96
commit
4398b8b5c6
@ -1,5 +1,6 @@
|
|||||||
"""Event Decorators for custom components."""
|
"""Event Decorators for custom components."""
|
||||||
import functools
|
import functools
|
||||||
|
import logging
|
||||||
|
|
||||||
# pylint: disable=unused-import
|
# pylint: disable=unused-import
|
||||||
from typing import Optional # NOQA
|
from typing import Optional # NOQA
|
||||||
@ -8,10 +9,14 @@ from homeassistant.core import HomeAssistant # NOQA
|
|||||||
from homeassistant.helpers import event
|
from homeassistant.helpers import event
|
||||||
|
|
||||||
HASS = None # type: Optional[HomeAssistant]
|
HASS = None # type: Optional[HomeAssistant]
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
_MSG = 'Event decorators are deprecated. Support will be removed in 0.40.'
|
||||||
|
|
||||||
|
|
||||||
def track_state_change(entity_ids, from_state=None, to_state=None):
|
def track_state_change(entity_ids, from_state=None, to_state=None):
|
||||||
"""Decorator factory to track state changes for entity id."""
|
"""Decorator factory to track state changes for entity id."""
|
||||||
|
_LOGGER.warning(_MSG)
|
||||||
|
|
||||||
def track_state_change_decorator(action):
|
def track_state_change_decorator(action):
|
||||||
"""Decorator to track state changes."""
|
"""Decorator to track state changes."""
|
||||||
event.track_state_change(HASS, entity_ids,
|
event.track_state_change(HASS, entity_ids,
|
||||||
@ -24,6 +29,8 @@ def track_state_change(entity_ids, from_state=None, to_state=None):
|
|||||||
|
|
||||||
def track_sunrise(offset=None):
|
def track_sunrise(offset=None):
|
||||||
"""Decorator factory to track sunrise events."""
|
"""Decorator factory to track sunrise events."""
|
||||||
|
_LOGGER.warning(_MSG)
|
||||||
|
|
||||||
def track_sunrise_decorator(action):
|
def track_sunrise_decorator(action):
|
||||||
"""Decorator to track sunrise events."""
|
"""Decorator to track sunrise events."""
|
||||||
event.track_sunrise(HASS,
|
event.track_sunrise(HASS,
|
||||||
@ -36,6 +43,8 @@ def track_sunrise(offset=None):
|
|||||||
|
|
||||||
def track_sunset(offset=None):
|
def track_sunset(offset=None):
|
||||||
"""Decorator factory to track sunset events."""
|
"""Decorator factory to track sunset events."""
|
||||||
|
_LOGGER.warning(_MSG)
|
||||||
|
|
||||||
def track_sunset_decorator(action):
|
def track_sunset_decorator(action):
|
||||||
"""Decorator to track sunset events."""
|
"""Decorator to track sunset events."""
|
||||||
event.track_sunset(HASS,
|
event.track_sunset(HASS,
|
||||||
@ -49,6 +58,8 @@ def track_sunset(offset=None):
|
|||||||
def track_time_change(year=None, month=None, day=None, hour=None, minute=None,
|
def track_time_change(year=None, month=None, day=None, hour=None, minute=None,
|
||||||
second=None):
|
second=None):
|
||||||
"""Decorator factory to track time changes."""
|
"""Decorator factory to track time changes."""
|
||||||
|
_LOGGER.warning(_MSG)
|
||||||
|
|
||||||
def track_time_change_decorator(action):
|
def track_time_change_decorator(action):
|
||||||
"""Decorator to track time changes."""
|
"""Decorator to track time changes."""
|
||||||
event.track_time_change(HASS,
|
event.track_time_change(HASS,
|
||||||
@ -62,6 +73,8 @@ def track_time_change(year=None, month=None, day=None, hour=None, minute=None,
|
|||||||
def track_utc_time_change(year=None, month=None, day=None, hour=None,
|
def track_utc_time_change(year=None, month=None, day=None, hour=None,
|
||||||
minute=None, second=None):
|
minute=None, second=None):
|
||||||
"""Decorator factory to track time changes."""
|
"""Decorator factory to track time changes."""
|
||||||
|
_LOGGER.warning(_MSG)
|
||||||
|
|
||||||
def track_utc_time_change_decorator(action):
|
def track_utc_time_change_decorator(action):
|
||||||
"""Decorator to track time changes."""
|
"""Decorator to track time changes."""
|
||||||
event.track_utc_time_change(HASS,
|
event.track_utc_time_change(HASS,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user