mirror of
https://github.com/home-assistant/core.git
synced 2025-04-22 16:27:56 +00:00
Built-in components no longer use deprecated methods
This commit is contained in:
parent
7870e9a5e2
commit
382c1de981
@ -5,6 +5,7 @@ homeassistant.components.automation.time
|
||||
Offers time listening automation rules.
|
||||
"""
|
||||
from homeassistant.util import convert
|
||||
from homeassistant.helpers.event import track_time_change
|
||||
|
||||
CONF_HOURS = "time_hours"
|
||||
CONF_MINUTES = "time_minutes"
|
||||
@ -21,8 +22,7 @@ def register(hass, config, action):
|
||||
""" Listens for time changes and calls action. """
|
||||
action()
|
||||
|
||||
hass.track_time_change(
|
||||
time_automation_listener,
|
||||
hour=hours, minute=minutes, second=seconds)
|
||||
track_time_change(hass, time_automation_listener,
|
||||
hour=hours, minute=minutes, second=seconds)
|
||||
|
||||
return True
|
||||
|
@ -8,6 +8,7 @@ the state of the sun and devices.
|
||||
import logging
|
||||
from datetime import timedelta
|
||||
|
||||
from homeassistant.helpers.event import track_point_in_time
|
||||
import homeassistant.util.dt as dt_util
|
||||
from homeassistant.const import STATE_HOME, STATE_NOT_HOME
|
||||
from . import light, sun, device_tracker, group
|
||||
@ -91,9 +92,9 @@ def setup(hass, config):
|
||||
|
||||
if start_point:
|
||||
for index, light_id in enumerate(light_ids):
|
||||
hass.track_point_in_time(turn_on(light_id),
|
||||
(start_point +
|
||||
index * LIGHT_TRANSITION_TIME))
|
||||
track_point_in_time(
|
||||
hass, turn_on(light_id),
|
||||
(start_point + index * LIGHT_TRANSITION_TIME))
|
||||
|
||||
# Track every time sun rises so we can schedule a time-based
|
||||
# pre-sun set event
|
||||
|
@ -15,6 +15,7 @@ from homeassistant.helpers import validate_config
|
||||
import homeassistant.util as util
|
||||
import homeassistant.util.dt as dt_util
|
||||
|
||||
from homeassistant.helpers.event import track_utc_time_change
|
||||
from homeassistant.const import (
|
||||
STATE_HOME, STATE_NOT_HOME, ATTR_ENTITY_PICTURE, ATTR_FRIENDLY_NAME,
|
||||
CONF_PLATFORM, DEVICE_DEFAULT_NAME)
|
||||
@ -134,7 +135,7 @@ class DeviceTracker(object):
|
||||
seconds = range(0, 60, seconds)
|
||||
|
||||
_LOGGER.info("Device tracker interval second=%s", seconds)
|
||||
hass.track_utc_time_change(update_device_state, second=seconds)
|
||||
track_utc_time_change(hass, update_device_state, second=seconds)
|
||||
|
||||
hass.services.register(DOMAIN,
|
||||
SERVICE_DEVICE_TRACKER_RELOAD,
|
||||
|
@ -17,6 +17,7 @@ from datetime import timedelta
|
||||
import logging
|
||||
|
||||
import homeassistant.util.dt as dt_util
|
||||
from homeassistant.helpers.event import track_point_in_time
|
||||
from homeassistant.components.scheduler import ServiceEventListener
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
@ -62,7 +63,7 @@ class TimeEventListener(ServiceEventListener):
|
||||
""" Call the execute method """
|
||||
self.execute(hass)
|
||||
|
||||
hass.track_point_in_time(execute, next_time)
|
||||
track_point_in_time(hass, execute, next_time)
|
||||
|
||||
_LOGGER.info(
|
||||
'TimeEventListener scheduled for %s, will call service %s.%s',
|
||||
|
@ -10,6 +10,7 @@ from datetime import timedelta
|
||||
import homeassistant.util.dt as date_util
|
||||
import threading
|
||||
|
||||
from homeassistant.helpers.event import track_point_in_time
|
||||
from homeassistant.util import split_entity_id
|
||||
from homeassistant.const import (
|
||||
STATE_ON, STATE_OFF, SERVICE_TURN_ON, SERVICE_TURN_OFF, EVENT_TIME_CHANGED)
|
||||
@ -111,8 +112,8 @@ class Script(object):
|
||||
elif CONF_DELAY in action:
|
||||
delay = timedelta(**action[CONF_DELAY])
|
||||
point_in_time = date_util.now() + delay
|
||||
self.listener = self.hass.track_point_in_time(
|
||||
self, point_in_time)
|
||||
self.listener = track_point_in_time(
|
||||
self.hass, self, point_in_time)
|
||||
return False
|
||||
return True
|
||||
|
||||
|
@ -25,6 +25,8 @@ import urllib
|
||||
|
||||
import homeassistant.util as util
|
||||
import homeassistant.util.dt as dt_util
|
||||
from homeassistant.helpers.event import (
|
||||
track_point_in_utc_time, track_point_in_time)
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.components.scheduler import ServiceEventListener
|
||||
|
||||
@ -209,8 +211,8 @@ class Sun(Entity):
|
||||
self.update_ha_state()
|
||||
|
||||
# Schedule next update at next_change+1 second so sun state has changed
|
||||
self.hass.track_point_in_utc_time(
|
||||
self.point_in_time_listener,
|
||||
track_point_in_utc_time(
|
||||
self.hass, self.point_in_time_listener,
|
||||
self.next_change + timedelta(seconds=1))
|
||||
|
||||
|
||||
@ -272,7 +274,7 @@ class SunEventListener(ServiceEventListener):
|
||||
""" Call the execute method. """
|
||||
self.execute(hass)
|
||||
|
||||
hass.track_point_in_time(execute, next_time)
|
||||
track_point_in_time(hass, execute, next_time)
|
||||
|
||||
return next_time
|
||||
|
||||
|
@ -7,6 +7,7 @@ Provides helpers for components that manage entities.
|
||||
from homeassistant.bootstrap import prepare_setup_platform
|
||||
from homeassistant.helpers import (
|
||||
generate_entity_id, config_per_platform, extract_entity_ids)
|
||||
from homeassistant.helpers.event import track_utc_time_change
|
||||
from homeassistant.components import group, discovery
|
||||
from homeassistant.const import ATTR_ENTITY_ID
|
||||
|
||||
@ -115,8 +116,8 @@ class EntityComponent(object):
|
||||
|
||||
self.is_polling = True
|
||||
|
||||
self.hass.track_time_change(
|
||||
self._update_entity_states,
|
||||
track_utc_time_change(
|
||||
self.hass, self._update_entity_states,
|
||||
second=range(0, 60, self.scan_interval))
|
||||
|
||||
def _setup_platform(self, platform_type, platform_config,
|
||||
|
Loading…
x
Reference in New Issue
Block a user