mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Migrate components to use EntityComponent
This commit is contained in:
parent
a9324ba9d4
commit
bbfd97e2b8
@ -52,7 +52,7 @@ import logging
|
|||||||
import os
|
import os
|
||||||
import csv
|
import csv
|
||||||
|
|
||||||
from homeassistant.helpers.device_component import DeviceComponent
|
from homeassistant.helpers.entity_component import EntityComponent
|
||||||
|
|
||||||
import homeassistant.util as util
|
import homeassistant.util as util
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
@ -140,7 +140,7 @@ def turn_off(hass, entity_id=None, transition=None):
|
|||||||
def setup(hass, config):
|
def setup(hass, config):
|
||||||
""" Exposes light control via statemachine and services. """
|
""" Exposes light control via statemachine and services. """
|
||||||
|
|
||||||
component = DeviceComponent(
|
component = EntityComponent(
|
||||||
_LOGGER, DOMAIN, hass, SCAN_INTERVAL, DISCOVERY_PLATFORMS,
|
_LOGGER, DOMAIN, hass, SCAN_INTERVAL, DISCOVERY_PLATFORMS,
|
||||||
GROUP_NAME_ALL_LIGHTS)
|
GROUP_NAME_ALL_LIGHTS)
|
||||||
component.setup(config)
|
component.setup(config)
|
||||||
|
@ -8,7 +8,7 @@ import logging
|
|||||||
|
|
||||||
from homeassistant.components import discovery
|
from homeassistant.components import discovery
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
from homeassistant.helpers.device_component import DeviceComponent
|
from homeassistant.helpers.entity_component import EntityComponent
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_ENTITY_ID, SERVICE_TURN_OFF, SERVICE_VOLUME_UP,
|
ATTR_ENTITY_ID, SERVICE_TURN_OFF, SERVICE_VOLUME_UP,
|
||||||
SERVICE_VOLUME_DOWN, SERVICE_MEDIA_PLAY_PAUSE, SERVICE_MEDIA_PLAY,
|
SERVICE_VOLUME_DOWN, SERVICE_MEDIA_PLAY_PAUSE, SERVICE_MEDIA_PLAY,
|
||||||
@ -126,7 +126,7 @@ SERVICE_TO_METHOD = {
|
|||||||
|
|
||||||
def setup(hass, config):
|
def setup(hass, config):
|
||||||
""" Track states and offer events for media_players. """
|
""" Track states and offer events for media_players. """
|
||||||
component = DeviceComponent(
|
component = EntityComponent(
|
||||||
logging.getLogger(__name__), DOMAIN, hass, SCAN_INTERVAL,
|
logging.getLogger(__name__), DOMAIN, hass, SCAN_INTERVAL,
|
||||||
DISCOVERY_PLATFORMS)
|
DISCOVERY_PLATFORMS)
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ from collections import namedtuple
|
|||||||
|
|
||||||
from homeassistant import State
|
from homeassistant import State
|
||||||
from homeassistant.helpers.entity import ToggleEntity
|
from homeassistant.helpers.entity import ToggleEntity
|
||||||
from homeassistant.helpers.device_component import DeviceComponent
|
from homeassistant.helpers.entity_component import EntityComponent
|
||||||
from homeassistant.helpers.state import reproduce_state
|
from homeassistant.helpers.state import reproduce_state
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_ENTITY_ID, STATE_OFF, STATE_ON, SERVICE_TURN_ON, SERVICE_TURN_OFF)
|
ATTR_ENTITY_ID, STATE_OFF, STATE_ON, SERVICE_TURN_ON, SERVICE_TURN_OFF)
|
||||||
@ -46,7 +46,7 @@ def setup(hass, config):
|
|||||||
logger.error('Scene config should be a list of scenes')
|
logger.error('Scene config should be a list of scenes')
|
||||||
return False
|
return False
|
||||||
|
|
||||||
component = DeviceComponent(logger, DOMAIN, hass)
|
component = EntityComponent(logger, DOMAIN, hass)
|
||||||
|
|
||||||
component.add_entities(Scene(hass, _process_config(scene_config))
|
component.add_entities(Scene(hass, _process_config(scene_config))
|
||||||
for scene_config in scene_configs)
|
for scene_config in scene_configs)
|
||||||
|
@ -5,7 +5,7 @@ Component to interface with various sensors that can be monitored.
|
|||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from homeassistant.helpers.device_component import DeviceComponent
|
from homeassistant.helpers.entity_component import EntityComponent
|
||||||
from homeassistant.components import wink, zwave
|
from homeassistant.components import wink, zwave
|
||||||
|
|
||||||
DOMAIN = 'sensor'
|
DOMAIN = 'sensor'
|
||||||
@ -23,7 +23,7 @@ DISCOVERY_PLATFORMS = {
|
|||||||
|
|
||||||
def setup(hass, config):
|
def setup(hass, config):
|
||||||
""" Track states and offer events for sensors. """
|
""" Track states and offer events for sensors. """
|
||||||
component = DeviceComponent(
|
component = EntityComponent(
|
||||||
logging.getLogger(__name__), DOMAIN, hass, SCAN_INTERVAL,
|
logging.getLogger(__name__), DOMAIN, hass, SCAN_INTERVAL,
|
||||||
DISCOVERY_PLATFORMS)
|
DISCOVERY_PLATFORMS)
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ Component to interface with various switches that can be controlled remotely.
|
|||||||
import logging
|
import logging
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
|
||||||
from homeassistant.helpers.device_component import DeviceComponent
|
from homeassistant.helpers.entity_component import EntityComponent
|
||||||
|
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
STATE_ON, SERVICE_TURN_ON, SERVICE_TURN_OFF, ATTR_ENTITY_ID)
|
STATE_ON, SERVICE_TURN_ON, SERVICE_TURN_OFF, ATTR_ENTITY_ID)
|
||||||
@ -58,7 +58,7 @@ def turn_off(hass, entity_id=None):
|
|||||||
|
|
||||||
def setup(hass, config):
|
def setup(hass, config):
|
||||||
""" Track states and offer events for switches. """
|
""" Track states and offer events for switches. """
|
||||||
component = DeviceComponent(
|
component = EntityComponent(
|
||||||
_LOGGER, DOMAIN, hass, SCAN_INTERVAL, DISCOVERY_PLATFORMS,
|
_LOGGER, DOMAIN, hass, SCAN_INTERVAL, DISCOVERY_PLATFORMS,
|
||||||
GROUP_NAME_ALL_SWITCHES)
|
GROUP_NAME_ALL_SWITCHES)
|
||||||
component.setup(config)
|
component.setup(config)
|
||||||
|
@ -6,7 +6,7 @@ Provides functionality to interact with thermostats.
|
|||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from homeassistant.helpers.device_component import DeviceComponent
|
from homeassistant.helpers.entity_component import EntityComponent
|
||||||
|
|
||||||
import homeassistant.util as util
|
import homeassistant.util as util
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
@ -52,7 +52,7 @@ def set_temperature(hass, temperature, entity_id=None):
|
|||||||
|
|
||||||
def setup(hass, config):
|
def setup(hass, config):
|
||||||
""" Setup thermostats. """
|
""" Setup thermostats. """
|
||||||
component = DeviceComponent(_LOGGER, DOMAIN, hass, SCAN_INTERVAL)
|
component = EntityComponent(_LOGGER, DOMAIN, hass, SCAN_INTERVAL)
|
||||||
component.setup(config)
|
component.setup(config)
|
||||||
|
|
||||||
def thermostat_service(service):
|
def thermostat_service(service):
|
||||||
|
@ -7,7 +7,7 @@ Helper method for writing tests.
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
import homeassistant as ha
|
import homeassistant as ha
|
||||||
from homeassistant.helpers.device import ToggleDevice
|
from homeassistant.helpers.entity import ToggleEntity
|
||||||
from homeassistant.const import STATE_ON, STATE_OFF, DEVICE_DEFAULT_NAME
|
from homeassistant.const import STATE_ON, STATE_OFF, DEVICE_DEFAULT_NAME
|
||||||
|
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ class MockModule(object):
|
|||||||
self.setup = lambda hass, config: False if setup is None else setup
|
self.setup = lambda hass, config: False if setup is None else setup
|
||||||
|
|
||||||
|
|
||||||
class MockToggleDevice(ToggleDevice):
|
class MockToggleDevice(ToggleEntity):
|
||||||
""" Provides a mock toggle device. """
|
""" Provides a mock toggle device. """
|
||||||
def __init__(self, name, state):
|
def __init__(self, name, state):
|
||||||
self._name = name or DEVICE_DEFAULT_NAME
|
self._name = name or DEVICE_DEFAULT_NAME
|
||||||
|
Loading…
x
Reference in New Issue
Block a user