Update components to use Entity instead of Device

This commit is contained in:
Paulus Schoutsen 2015-03-21 19:16:13 -07:00
parent d3f0210b1a
commit a9324ba9d4
19 changed files with 38 additions and 37 deletions

View File

@ -1,7 +1,7 @@
""" Provides demo lights. """
import random
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.components.light import ATTR_BRIGHTNESS, ATTR_XY_COLOR
@ -22,7 +22,7 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
])
class DemoLight(ToggleDevice):
class DemoLight(ToggleEntity):
""" Provides a demo switch. """
def __init__(self, name, state, xy=None, brightness=180):
self._name = name or DEVICE_DEFAULT_NAME

View File

@ -6,7 +6,7 @@ from urllib.parse import urlparse
from homeassistant.loader import get_component
import homeassistant.util as util
from homeassistant.helpers.device import ToggleDevice
from homeassistant.helpers.entity import ToggleEntity
from homeassistant.const import CONF_HOST
from homeassistant.components.light import (
ATTR_BRIGHTNESS, ATTR_XY_COLOR, ATTR_TRANSITION,
@ -131,7 +131,7 @@ def request_configuration(host, hass, add_devices_callback):
)
class HueLight(ToggleDevice):
class HueLight(ToggleEntity):
""" Represents a Hue light """
def __init__(self, light_id, info, bridge, update_lights):

View File

@ -3,7 +3,7 @@ import logging
# pylint: disable=no-name-in-module, import-error
from homeassistant.components.light import ATTR_BRIGHTNESS
from homeassistant.const import ATTR_FRIENDLY_NAME
from homeassistant.helpers.device import ToggleDevice
from homeassistant.helpers.entity import ToggleEntity
import tellcore.constants as tellcore_constants
@ -27,7 +27,7 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
add_devices_callback(lights)
class TellstickLight(ToggleDevice):
class TellstickLight(ToggleEntity):
""" Represents a tellstick light """
last_sent_command_mask = (tellcore_constants.TELLSTICK_TURNON |
tellcore_constants.TELLSTICK_TURNOFF |

View File

@ -7,7 +7,7 @@ Component to interface with various media players
import logging
from homeassistant.components import discovery
from homeassistant.helpers.device import Device
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.device_component import DeviceComponent
from homeassistant.const import (
ATTR_ENTITY_ID, SERVICE_TURN_OFF, SERVICE_VOLUME_UP,
@ -171,7 +171,7 @@ def setup(hass, config):
return True
class MediaPlayerDevice(Device):
class MediaPlayerDevice(Entity):
""" ABC for media player devices. """
def turn_off(self):

View File

@ -19,7 +19,7 @@ import logging
from collections import namedtuple
from homeassistant import State
from homeassistant.helpers.device import ToggleDevice
from homeassistant.helpers.entity import ToggleEntity
from homeassistant.helpers.device_component import DeviceComponent
from homeassistant.helpers.state import reproduce_state
from homeassistant.const import (
@ -93,7 +93,7 @@ def _process_config(scene_config):
return SceneConfig(name, states)
class Scene(ToggleDevice):
class Scene(ToggleEntity):
""" A scene is a group of entities and the states we want them to be. """
def __init__(self, hass, scene_config):

View File

@ -1,5 +1,5 @@
""" Support for Wink sensors. """
from homeassistant.helpers.device import Device
from homeassistant.helpers.entity import Entity
from homeassistant.const import TEMP_CELCIUS, ATTR_BATTERY_LEVEL
@ -12,7 +12,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
])
class DemoSensor(Device):
class DemoSensor(Entity):
""" A Demo sensor. """
def __init__(self, name, state, unit_of_measurement, battery):

View File

@ -52,7 +52,7 @@ list of all available variables
from homeassistant.util import Throttle
from datetime import timedelta
from homeassistant.helpers.device import Device
from homeassistant.helpers.entity import Entity
# pylint: disable=no-name-in-module, import-error
from homeassistant.external.nzbclients.sabnzbd import SabnzbdApi
from homeassistant.external.nzbclients.sabnzbd import SabnzbdApiException
@ -109,7 +109,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
add_devices(dev)
class SabnzbdSensor(Device):
class SabnzbdSensor(Entity):
""" A Sabnzbd sensor """
def __init__(self, sensor_type, sabnzb_client, client_name):

View File

@ -6,7 +6,7 @@ Shows system monitor values such as: disk, memory and processor use
"""
from homeassistant.helpers.device import Device
from homeassistant.helpers.entity import Entity
from homeassistant.const import STATE_ON, STATE_OFF
import psutil
import logging
@ -42,7 +42,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
add_devices(dev)
class SystemMonitorSensor(Device):
class SystemMonitorSensor(Entity):
""" A system monitor sensor """
def __init__(self, sensor_type, argument=''):

View File

@ -30,7 +30,7 @@ import tellcore.telldus as telldus
import tellcore.constants as tellcore_constants
from homeassistant.const import TEMP_CELCIUS
from homeassistant.helpers.device import Device
from homeassistant.helpers.entity import Entity
import homeassistant.util as util
DatatypeDescription = namedtuple("DatatypeDescription", ['name', 'unit'])
@ -93,7 +93,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
add_devices(sensors)
class TellstickSensor(Device):
class TellstickSensor(Entity):
""" Represents a Tellstick sensor. """
def __init__(self, name, sensor, datatype, sensor_info):

View File

@ -50,7 +50,7 @@ import logging
import time
from requests.exceptions import RequestException
from homeassistant.helpers import Device
from homeassistant.helpers.entity import Entity
from homeassistant.const import (
ATTR_BATTERY_LEVEL, ATTR_TRIPPED, ATTR_ARMED, ATTR_LAST_TRIP_TIME)
# pylint: disable=no-name-in-module, import-error
@ -99,7 +99,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
add_devices(get_devices(hass, config))
class VeraSensor(Device):
class VeraSensor(Entity):
""" Represents a Vera Sensor """
def __init__(self, vera_device, extra_data=None):

View File

@ -4,7 +4,7 @@ import logging
# pylint: disable=no-name-in-module, import-error
import homeassistant.external.wink.pywink as pywink
from homeassistant.helpers.device import Device
from homeassistant.helpers.entity import Entity
from homeassistant.const import CONF_ACCESS_TOKEN, STATE_OPEN, STATE_CLOSED
@ -24,7 +24,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
add_devices(WinkSensorDevice(sensor) for sensor in pywink.get_sensors())
class WinkSensorDevice(Device):
class WinkSensorDevice(Entity):
""" represents a wink sensor within home assistant. """
def __init__(self, wink):

View File

@ -9,7 +9,7 @@ from openzwave.network import ZWaveNetwork
from pydispatch import dispatcher
import homeassistant.components.zwave as zwave
from homeassistant.helpers.device import Device
from homeassistant.helpers.entity import Entity
from homeassistant.const import (
ATTR_BATTERY_LEVEL, STATE_ON, STATE_OFF,
TEMP_CELCIUS, TEMP_FAHRENHEIT, ATTR_LOCATION)
@ -33,7 +33,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
add_devices([ZWaveMultilevelSensor(value)])
class ZWaveSensor(Device):
class ZWaveSensor(Entity):
""" Represents a Z-Wave sensor. """
def __init__(self, sensor_value):
self._value = sensor_value

View File

@ -1,5 +1,5 @@
""" Demo platform that has two fake switchces. """
from homeassistant.helpers.device import ToggleDevice
from homeassistant.helpers.entity import ToggleEntity
from homeassistant.const import STATE_ON, STATE_OFF, DEVICE_DEFAULT_NAME
@ -12,7 +12,7 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
])
class DemoSwitch(ToggleDevice):
class DemoSwitch(ToggleEntity):
""" Provides a demo switch. """
def __init__(self, name, state):
self._name = name or DEVICE_DEFAULT_NAME

View File

@ -3,7 +3,7 @@ import logging
from homeassistant.const import ATTR_FRIENDLY_NAME
from homeassistant.helpers.device import ToggleDevice
from homeassistant.helpers.entity import ToggleEntity
import tellcore.constants as tellcore_constants
@ -29,7 +29,7 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
add_devices_callback(switches)
class TellstickSwitchDevice(ToggleDevice):
class TellstickSwitchDevice(ToggleEntity):
""" represents a Tellstick switch within home assistant. """
last_sent_command_mask = (tellcore_constants.TELLSTICK_TURNON |
tellcore_constants.TELLSTICK_TURNOFF)

View File

@ -52,7 +52,7 @@ import logging
import time
from requests.exceptions import RequestException
from homeassistant.helpers import ToggleDevice
from homeassistant.helpers.entity import ToggleEntity
from homeassistant.const import (
ATTR_BATTERY_LEVEL, ATTR_TRIPPED, ATTR_ARMED, ATTR_LAST_TRIP_TIME)
# pylint: disable=no-name-in-module, import-error
@ -100,7 +100,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
add_devices(get_devices(hass, config))
class VeraSwitch(ToggleDevice):
class VeraSwitch(ToggleEntity):
""" Represents a Vera Switch """
def __init__(self, vera_device, extra_data=None):

View File

@ -1,7 +1,7 @@
""" Support for WeMo switchces. """
import logging
from homeassistant.helpers.device import ToggleDevice
from homeassistant.helpers.entity import ToggleEntity
from homeassistant.components.switch import (
ATTR_TODAY_MWH, ATTR_CURRENT_POWER_MWH)
@ -38,7 +38,7 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
if isinstance(switch, pywemo.Switch)])
class WemoSwitch(ToggleDevice):
class WemoSwitch(ToggleEntity):
""" represents a WeMo switch within home assistant. """
def __init__(self, wemo):
self.wemo = wemo

View File

@ -9,7 +9,7 @@ import logging
from homeassistant.helpers.device_component import DeviceComponent
import homeassistant.util as util
from homeassistant.helpers.device import Device
from homeassistant.helpers.entity import Entity
from homeassistant.const import (
ATTR_ENTITY_ID, ATTR_TEMPERATURE, STATE_ON, STATE_OFF)
@ -98,7 +98,7 @@ def setup(hass, config):
return True
class ThermostatDevice(Device):
class ThermostatDevice(Entity):
""" Represents a thermostat within Home Assistant. """
# pylint: disable=no-self-use

View File

@ -8,7 +8,8 @@ import homeassistant.external.wink.pywink as pywink
from homeassistant import bootstrap
from homeassistant.loader import get_component
from homeassistant.helpers import validate_config, ToggleDevice
from homeassistant.helpers import validate_config
from homeassistant.helpers.entity import ToggleEntity
from homeassistant.const import (
EVENT_PLATFORM_DISCOVERED, CONF_ACCESS_TOKEN,
ATTR_SERVICE, ATTR_DISCOVERED, ATTR_FRIENDLY_NAME)
@ -52,7 +53,7 @@ def setup(hass, config):
return True
class WinkToggleDevice(ToggleDevice):
class WinkToggleDevice(ToggleEntity):
""" represents a Wink switch within home assistant. """
def __init__(self, wink):

View File

@ -134,7 +134,7 @@ class EntityComponent(object):
"Please upgrade %s to return new entities using "
"setup_platform. See %s/demo.py for an example.",
platform_name, self.domain)
self.add_devices(platform.get_entities(self.hass, config))
self.add_entities(platform.get_devices(self.hass, config))
else:
# AttributeError if setup_platform does not exist