mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Remove more deprecated method calls
This commit is contained in:
parent
76f63ee262
commit
e47ac96587
@ -6,6 +6,7 @@ Offers state listening automation rules.
|
|||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from homeassistant.helpers.event import track_state_change
|
||||||
from homeassistant.const import MATCH_ALL
|
from homeassistant.const import MATCH_ALL
|
||||||
|
|
||||||
|
|
||||||
@ -30,7 +31,7 @@ def register(hass, config, action):
|
|||||||
""" Listens for state changes and calls action. """
|
""" Listens for state changes and calls action. """
|
||||||
action()
|
action()
|
||||||
|
|
||||||
hass.states.track_change(
|
track_state_change(
|
||||||
entity_id, state_automation_listener, from_state, to_state)
|
hass, entity_id, state_automation_listener, from_state, to_state)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
@ -8,7 +8,7 @@ the state of the sun and devices.
|
|||||||
import logging
|
import logging
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
|
||||||
from homeassistant.helpers.event import track_point_in_time
|
from homeassistant.helpers.event import track_point_in_time, track_state_change
|
||||||
import homeassistant.util.dt as dt_util
|
import homeassistant.util.dt as dt_util
|
||||||
from homeassistant.const import STATE_HOME, STATE_NOT_HOME
|
from homeassistant.const import STATE_HOME, STATE_NOT_HOME
|
||||||
from . import light, sun, device_tracker, group
|
from . import light, sun, device_tracker, group
|
||||||
@ -98,7 +98,7 @@ def setup(hass, config):
|
|||||||
|
|
||||||
# Track every time sun rises so we can schedule a time-based
|
# Track every time sun rises so we can schedule a time-based
|
||||||
# pre-sun set event
|
# pre-sun set event
|
||||||
hass.states.track_change(sun.ENTITY_ID, schedule_light_on_sun_rise,
|
track_state_change(hass, sun.ENTITY_ID, schedule_light_on_sun_rise,
|
||||||
sun.STATE_BELOW_HORIZON, sun.STATE_ABOVE_HORIZON)
|
sun.STATE_BELOW_HORIZON, sun.STATE_ABOVE_HORIZON)
|
||||||
|
|
||||||
# If the sun is already above horizon
|
# If the sun is already above horizon
|
||||||
@ -158,13 +158,13 @@ def setup(hass, config):
|
|||||||
light.turn_off(hass, light_ids)
|
light.turn_off(hass, light_ids)
|
||||||
|
|
||||||
# Track home coming of each device
|
# Track home coming of each device
|
||||||
hass.states.track_change(
|
track_state_change(
|
||||||
device_entity_ids, check_light_on_dev_state_change,
|
hass, device_entity_ids, check_light_on_dev_state_change,
|
||||||
STATE_NOT_HOME, STATE_HOME)
|
STATE_NOT_HOME, STATE_HOME)
|
||||||
|
|
||||||
# Track when all devices are gone to shut down lights
|
# Track when all devices are gone to shut down lights
|
||||||
hass.states.track_change(
|
track_state_change(
|
||||||
device_group, check_light_on_dev_state_change,
|
hass, device_group, check_light_on_dev_state_change,
|
||||||
STATE_HOME, STATE_NOT_HOME)
|
STATE_HOME, STATE_NOT_HOME)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
@ -7,6 +7,7 @@ Provides functionality to group devices that can be turned on or off.
|
|||||||
|
|
||||||
import homeassistant as ha
|
import homeassistant as ha
|
||||||
from homeassistant.helpers import generate_entity_id
|
from homeassistant.helpers import generate_entity_id
|
||||||
|
from homeassistant.helpers.event import track_state_change
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
import homeassistant.util as util
|
import homeassistant.util as util
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
@ -162,8 +163,8 @@ class Group(Entity):
|
|||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
""" Starts the tracking. """
|
""" Starts the tracking. """
|
||||||
self.hass.states.track_change(
|
track_state_change(
|
||||||
self.tracking, self._state_changed_listener)
|
self.hass, self.tracking, self._state_changed_listener)
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
""" Unregisters the group from Home Assistant. """
|
""" Unregisters the group from Home Assistant. """
|
||||||
|
@ -19,6 +19,7 @@ import logging
|
|||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
from homeassistant import State
|
from homeassistant import State
|
||||||
|
from homeassistant.helpers.event import track_state_change
|
||||||
from homeassistant.helpers.entity import ToggleEntity
|
from homeassistant.helpers.entity import ToggleEntity
|
||||||
from homeassistant.helpers.entity_component import EntityComponent
|
from homeassistant.helpers.entity_component import EntityComponent
|
||||||
from homeassistant.helpers.state import reproduce_state
|
from homeassistant.helpers.state import reproduce_state
|
||||||
@ -104,8 +105,8 @@ class Scene(ToggleEntity):
|
|||||||
self.prev_states = None
|
self.prev_states = None
|
||||||
self.ignore_updates = False
|
self.ignore_updates = False
|
||||||
|
|
||||||
self.hass.states.track_change(
|
track_state_change(
|
||||||
self.entity_ids, self.entity_state_changed)
|
self.hass, self.entity_ids, self.entity_state_changed)
|
||||||
|
|
||||||
self.update()
|
self.update()
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ Provides a simple alarm feature:
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
import homeassistant.loader as loader
|
import homeassistant.loader as loader
|
||||||
|
from homeassistant.helpers.event import track_state_change
|
||||||
from homeassistant.const import STATE_ON, STATE_OFF, STATE_HOME, STATE_NOT_HOME
|
from homeassistant.const import STATE_ON, STATE_OFF, STATE_HOME, STATE_NOT_HOME
|
||||||
|
|
||||||
DOMAIN = "simple_alarm"
|
DOMAIN = "simple_alarm"
|
||||||
@ -83,8 +84,8 @@ def setup(hass, config):
|
|||||||
if not device_tracker.is_on(hass):
|
if not device_tracker.is_on(hass):
|
||||||
unknown_alarm()
|
unknown_alarm()
|
||||||
|
|
||||||
hass.states.track_change(
|
track_state_change(
|
||||||
light.ENTITY_ID_ALL_LIGHTS,
|
hass, light.ENTITY_ID_ALL_LIGHTS,
|
||||||
unknown_alarm_if_lights_on, STATE_OFF, STATE_ON)
|
unknown_alarm_if_lights_on, STATE_OFF, STATE_ON)
|
||||||
|
|
||||||
def ring_known_alarm(entity_id, old_state, new_state):
|
def ring_known_alarm(entity_id, old_state, new_state):
|
||||||
@ -93,8 +94,8 @@ def setup(hass, config):
|
|||||||
known_alarm()
|
known_alarm()
|
||||||
|
|
||||||
# Track home coming of each device
|
# Track home coming of each device
|
||||||
hass.states.track_change(
|
track_state_change(
|
||||||
hass.states.entity_ids(device_tracker.DOMAIN),
|
hass, hass.states.entity_ids(device_tracker.DOMAIN),
|
||||||
ring_known_alarm, STATE_NOT_HOME, STATE_HOME)
|
ring_known_alarm, STATE_NOT_HOME, STATE_HOME)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
@ -63,6 +63,7 @@ import datetime
|
|||||||
import homeassistant.components as core
|
import homeassistant.components as core
|
||||||
|
|
||||||
from homeassistant.components.thermostat import ThermostatDevice
|
from homeassistant.components.thermostat import ThermostatDevice
|
||||||
|
from homeassistant.helpers.event import track_state_change
|
||||||
from homeassistant.const import TEMP_CELCIUS, STATE_ON, STATE_OFF
|
from homeassistant.const import TEMP_CELCIUS, STATE_ON, STATE_OFF
|
||||||
|
|
||||||
TOL_TEMP = 0.3
|
TOL_TEMP = 0.3
|
||||||
@ -105,10 +106,10 @@ class HeatControl(ThermostatDevice):
|
|||||||
self._away = False
|
self._away = False
|
||||||
self._heater_manual_changed = True
|
self._heater_manual_changed = True
|
||||||
|
|
||||||
hass.states.track_change(self.heater_entity_id,
|
track_state_change(hass, self.heater_entity_id,
|
||||||
self._heater_turned_on,
|
self._heater_turned_on,
|
||||||
STATE_OFF, STATE_ON)
|
STATE_OFF, STATE_ON)
|
||||||
hass.states.track_change(self.heater_entity_id,
|
track_state_change(hass, self.heater_entity_id,
|
||||||
self._heater_turned_off,
|
self._heater_turned_off,
|
||||||
STATE_ON, STATE_OFF)
|
STATE_ON, STATE_OFF)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user