Rename Light to LightEntity (#34593)

This commit is contained in:
Erik Montnemery 2020-04-26 18:49:41 +02:00 committed by GitHub
parent 8402363568
commit e4333a7a44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
93 changed files with 248 additions and 191 deletions

View File

@ -10,7 +10,7 @@ from homeassistant.components.light import (
SUPPORT_BRIGHTNESS, SUPPORT_BRIGHTNESS,
SUPPORT_COLOR, SUPPORT_COLOR,
SUPPORT_COLOR_TEMP, SUPPORT_COLOR_TEMP,
Light, LightEntity,
) )
from homeassistant.util.color import ( from homeassistant.util.color import (
color_temperature_kelvin_to_mired, color_temperature_kelvin_to_mired,
@ -33,7 +33,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
async_add_entities(entities) async_add_entities(entities)
class AbodeLight(AbodeDevice, Light): class AbodeLight(AbodeDevice, LightEntity):
"""Representation of an Abode light.""" """Representation of an Abode light."""
def turn_on(self, **kwargs): def turn_on(self, **kwargs):

View File

@ -7,7 +7,7 @@ from homeassistant.components.light import (
ATTR_BRIGHTNESS, ATTR_BRIGHTNESS,
PLATFORM_SCHEMA, PLATFORM_SCHEMA,
SUPPORT_BRIGHTNESS, SUPPORT_BRIGHTNESS,
Light, LightEntity,
) )
from homeassistant.const import CONF_NAME from homeassistant.const import CONF_NAME
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
@ -43,7 +43,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities([AdsLight(ads_hub, ads_var_enable, ads_var_brightness, name)]) add_entities([AdsLight(ads_hub, ads_var_enable, ads_var_brightness, name)])
class AdsLight(AdsEntity, Light): class AdsLight(AdsEntity, LightEntity):
"""Representation of ADS light.""" """Representation of ADS light."""
def __init__(self, ads_hub, ads_var_enable, ads_var_brightness, name): def __init__(self, ads_hub, ads_var_enable, ads_var_brightness, name):

View File

@ -8,7 +8,7 @@ from homeassistant.components.light import (
ATTR_HS_COLOR, ATTR_HS_COLOR,
SUPPORT_BRIGHTNESS, SUPPORT_BRIGHTNESS,
SUPPORT_COLOR, SUPPORT_COLOR,
Light, LightEntity,
) )
from homeassistant.exceptions import PlatformNotReady from homeassistant.exceptions import PlatformNotReady
import homeassistant.util.color as color_util import homeassistant.util.color as color_util
@ -31,7 +31,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities(AveaLight(bulb) for bulb in nearby_bulbs) add_entities(AveaLight(bulb) for bulb in nearby_bulbs)
class AveaLight(Light): class AveaLight(LightEntity):
"""Representation of an Avea.""" """Representation of an Avea."""
def __init__(self, light): def __init__(self, light):

View File

@ -9,7 +9,7 @@ from homeassistant.components.light import (
ATTR_BRIGHTNESS, ATTR_BRIGHTNESS,
PLATFORM_SCHEMA, PLATFORM_SCHEMA,
SUPPORT_BRIGHTNESS, SUPPORT_BRIGHTNESS,
Light, LightEntity,
) )
from homeassistant.const import ( from homeassistant.const import (
CONF_API_KEY, CONF_API_KEY,
@ -66,7 +66,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities(lights) add_entities(lights)
class AvionLight(Light): class AvionLight(LightEntity):
"""Representation of an Avion light.""" """Representation of an Avion light."""
def __init__(self, device): def __init__(self, device):

View File

@ -10,7 +10,7 @@ from homeassistant.components.light import (
PLATFORM_SCHEMA, PLATFORM_SCHEMA,
SUPPORT_BRIGHTNESS, SUPPORT_BRIGHTNESS,
SUPPORT_COLOR, SUPPORT_COLOR,
Light, LightEntity,
) )
from homeassistant.const import CONF_NAME from homeassistant.const import CONF_NAME
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
@ -43,7 +43,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities([BlinkStickLight(stick, name)], True) add_entities([BlinkStickLight(stick, name)], True)
class BlinkStickLight(Light): class BlinkStickLight(LightEntity):
"""Representation of a BlinkStick light.""" """Representation of a BlinkStick light."""
def __init__(self, stick, name): def __init__(self, stick, name):

View File

@ -10,7 +10,7 @@ from homeassistant.components.light import (
PLATFORM_SCHEMA, PLATFORM_SCHEMA,
SUPPORT_BRIGHTNESS, SUPPORT_BRIGHTNESS,
SUPPORT_COLOR, SUPPORT_COLOR,
Light, LightEntity,
) )
from homeassistant.const import CONF_NAME from homeassistant.const import CONF_NAME
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
@ -42,7 +42,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
) )
class BlinktLight(Light): class BlinktLight(LightEntity):
"""Representation of a Blinkt! Light.""" """Representation of a Blinkt! Light."""
def __init__(self, blinkt, name, index): def __init__(self, blinkt, name, index):

View File

@ -15,7 +15,7 @@ from homeassistant.components.light import (
SUPPORT_EFFECT, SUPPORT_EFFECT,
SUPPORT_FLASH, SUPPORT_FLASH,
SUPPORT_TRANSITION, SUPPORT_TRANSITION,
Light, LightEntity,
) )
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.dispatcher import async_dispatcher_connect
@ -82,7 +82,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
async_add_group(gateway.api.groups.values()) async_add_group(gateway.api.groups.values())
class DeconzLight(DeconzDevice, Light): class DeconzLight(DeconzDevice, LightEntity):
"""Representation of a deCONZ light.""" """Representation of a deCONZ light."""
def __init__(self, device, gateway): def __init__(self, device, gateway):

View File

@ -12,7 +12,7 @@ from homeassistant.components.light import (
ATTR_BRIGHTNESS, ATTR_BRIGHTNESS,
PLATFORM_SCHEMA, PLATFORM_SCHEMA,
SUPPORT_BRIGHTNESS, SUPPORT_BRIGHTNESS,
Light, LightEntity,
) )
from homeassistant.const import CONF_API_KEY, CONF_DEVICES, CONF_NAME from homeassistant.const import CONF_API_KEY, CONF_DEVICES, CONF_NAME
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
@ -84,7 +84,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities(lights) add_entities(lights)
class DecoraLight(Light): class DecoraLight(LightEntity):
"""Representation of an Decora light.""" """Representation of an Decora light."""
def __init__(self, device): def __init__(self, device):

View File

@ -15,7 +15,7 @@ from homeassistant.components.light import (
PLATFORM_SCHEMA, PLATFORM_SCHEMA,
SUPPORT_BRIGHTNESS, SUPPORT_BRIGHTNESS,
SUPPORT_TRANSITION, SUPPORT_TRANSITION,
Light, LightEntity,
) )
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME, EVENT_HOMEASSISTANT_STOP from homeassistant.const import CONF_PASSWORD, CONF_USERNAME, EVENT_HOMEASSISTANT_STOP
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
@ -80,7 +80,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
hass.bus.listen(EVENT_HOMEASSISTANT_STOP, logout) hass.bus.listen(EVENT_HOMEASSISTANT_STOP, logout)
class DecoraWifiLight(Light): class DecoraWifiLight(LightEntity):
"""Representation of a Decora WiFi switch.""" """Representation of a Decora WiFi switch."""
def __init__(self, switch): def __init__(self, switch):

View File

@ -12,7 +12,7 @@ from homeassistant.components.light import (
SUPPORT_COLOR_TEMP, SUPPORT_COLOR_TEMP,
SUPPORT_EFFECT, SUPPORT_EFFECT,
SUPPORT_WHITE_VALUE, SUPPORT_WHITE_VALUE,
Light, LightEntity,
) )
from . import DOMAIN from . import DOMAIN
@ -57,7 +57,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
await async_setup_platform(hass, {}, async_add_entities) await async_setup_platform(hass, {}, async_add_entities)
class DemoLight(Light): class DemoLight(LightEntity):
"""Representation of a demo light.""" """Representation of a demo light."""
def __init__( def __init__(

View File

@ -1,7 +1,7 @@
"""Support for Dynalite channels as lights.""" """Support for Dynalite channels as lights."""
from typing import Callable from typing import Callable
from homeassistant.components.light import SUPPORT_BRIGHTNESS, Light from homeassistant.components.light import SUPPORT_BRIGHTNESS, LightEntity
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
@ -18,7 +18,7 @@ async def async_setup_entry(
) )
class DynaliteLight(DynaliteBase, Light): class DynaliteLight(DynaliteBase, LightEntity):
"""Representation of a Dynalite Channel as a Home Assistant Light.""" """Representation of a Dynalite Channel as a Home Assistant Light."""
@property @property

View File

@ -10,7 +10,7 @@ from homeassistant.components.light import (
ATTR_COLOR_TEMP, ATTR_COLOR_TEMP,
SUPPORT_BRIGHTNESS, SUPPORT_BRIGHTNESS,
SUPPORT_COLOR_TEMP, SUPPORT_COLOR_TEMP,
Light, LightEntity,
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ATTR_NAME from homeassistant.const import ATTR_NAME
@ -45,7 +45,7 @@ async def async_setup_entry(
async_add_entities([ElgatoLight(entry.entry_id, elgato, info)], True) async_add_entities([ElgatoLight(entry.entry_id, elgato, info)], True)
class ElgatoLight(Light): class ElgatoLight(LightEntity):
"""Defines a Elgato Key Light.""" """Defines a Elgato Key Light."""
def __init__( def __init__(

View File

@ -1,6 +1,10 @@
"""Support for control of ElkM1 lighting (X10, UPB, etc).""" """Support for control of ElkM1 lighting (X10, UPB, etc)."""
from homeassistant.components.light import ATTR_BRIGHTNESS, SUPPORT_BRIGHTNESS, Light from homeassistant.components.light import (
ATTR_BRIGHTNESS,
SUPPORT_BRIGHTNESS,
LightEntity,
)
from . import ElkEntity, create_elk_entities from . import ElkEntity, create_elk_entities
from .const import DOMAIN from .const import DOMAIN
@ -15,7 +19,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
async_add_entities(entities, True) async_add_entities(entities, True)
class ElkLight(ElkEntity, Light): class ElkLight(ElkEntity, LightEntity):
"""Representation of an Elk lighting device.""" """Representation of an Elk lighting device."""
def __init__(self, element, elk, elk_data): def __init__(self, element, elk, elk_data):

View File

@ -9,7 +9,7 @@ from homeassistant.components.light import (
ATTR_BRIGHTNESS, ATTR_BRIGHTNESS,
PLATFORM_SCHEMA, PLATFORM_SCHEMA,
SUPPORT_BRIGHTNESS, SUPPORT_BRIGHTNESS,
Light, LightEntity,
) )
from homeassistant.const import CONF_ID, CONF_NAME from homeassistant.const import CONF_ID, CONF_NAME
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
@ -39,7 +39,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities([EnOceanLight(sender_id, dev_id, dev_name)]) add_entities([EnOceanLight(sender_id, dev_id, dev_name)])
class EnOceanLight(enocean.EnOceanDevice, Light): class EnOceanLight(enocean.EnOceanDevice, LightEntity):
"""Representation of an EnOcean light source.""" """Representation of an EnOcean light source."""
def __init__(self, sender_id, dev_id, dev_name): def __init__(self, sender_id, dev_id, dev_name):

View File

@ -21,7 +21,7 @@ from homeassistant.components.light import (
SUPPORT_FLASH, SUPPORT_FLASH,
SUPPORT_TRANSITION, SUPPORT_TRANSITION,
SUPPORT_WHITE_VALUE, SUPPORT_WHITE_VALUE,
Light, LightEntity,
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.helpers.typing import HomeAssistantType from homeassistant.helpers.typing import HomeAssistantType
@ -50,7 +50,7 @@ async def async_setup_entry(
) )
class EsphomeLight(EsphomeEntity, Light): class EsphomeLight(EsphomeEntity, LightEntity):
"""A switch implementation for ESPHome.""" """A switch implementation for ESPHome."""
@property @property

View File

@ -10,7 +10,7 @@ from homeassistant.components.light import (
SUPPORT_BRIGHTNESS, SUPPORT_BRIGHTNESS,
SUPPORT_COLOR, SUPPORT_COLOR,
SUPPORT_COLOR_TEMP, SUPPORT_COLOR_TEMP,
Light, LightEntity,
) )
import homeassistant.util.color as color_util import homeassistant.util.color as color_util
from homeassistant.util.color import ( from homeassistant.util.color import (
@ -31,7 +31,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities([EufyLight(discovery_info)], True) add_entities([EufyLight(discovery_info)], True)
class EufyLight(Light): class EufyLight(LightEntity):
"""Representation of a Eufy light.""" """Representation of a Eufy light."""
def __init__(self, device): def __init__(self, device):

View File

@ -14,7 +14,7 @@ from homeassistant.components.light import (
SUPPORT_BRIGHTNESS, SUPPORT_BRIGHTNESS,
SUPPORT_COLOR, SUPPORT_COLOR,
SUPPORT_EFFECT, SUPPORT_EFFECT,
Light, LightEntity,
) )
from homeassistant.const import CONF_HOSTS from homeassistant.const import CONF_HOSTS
from homeassistant.exceptions import PlatformNotReady from homeassistant.exceptions import PlatformNotReady
@ -65,7 +65,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
async_add_entities(lights) async_add_entities(lights)
class EverLightsLight(Light): class EverLightsLight(LightEntity):
"""Representation of a Flux light.""" """Representation of a Flux light."""
def __init__(self, api, channel, status, effects): def __init__(self, api, channel, status, effects):

View File

@ -11,7 +11,7 @@ from homeassistant.components.light import (
SUPPORT_BRIGHTNESS, SUPPORT_BRIGHTNESS,
SUPPORT_COLOR, SUPPORT_COLOR,
SUPPORT_WHITE_VALUE, SUPPORT_WHITE_VALUE,
Light, LightEntity,
) )
from homeassistant.const import CONF_WHITE_VALUE from homeassistant.const import CONF_WHITE_VALUE
import homeassistant.util.color as color_util import homeassistant.util.color as color_util
@ -48,7 +48,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
) )
class FibaroLight(FibaroDevice, Light): class FibaroLight(FibaroDevice, LightEntity):
"""Representation of a Fibaro Light, including dimmable.""" """Representation of a Fibaro Light, including dimmable."""
def __init__(self, fibaro_device): def __init__(self, fibaro_device):

View File

@ -19,7 +19,7 @@ from homeassistant.components.light import (
SUPPORT_COLOR_TEMP, SUPPORT_COLOR_TEMP,
SUPPORT_EFFECT, SUPPORT_EFFECT,
SUPPORT_WHITE_VALUE, SUPPORT_WHITE_VALUE,
Light, LightEntity,
) )
from homeassistant.const import ATTR_MODE, CONF_DEVICES, CONF_NAME, CONF_PROTOCOL from homeassistant.const import ATTR_MODE, CONF_DEVICES, CONF_NAME, CONF_PROTOCOL
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
@ -176,7 +176,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities(lights, True) add_entities(lights, True)
class FluxLight(Light): class FluxLight(LightEntity):
"""Representation of a Flux light.""" """Representation of a Flux light."""
def __init__(self, device): def __init__(self, device):

View File

@ -9,7 +9,7 @@ from homeassistant.components.light import (
ATTR_BRIGHTNESS, ATTR_BRIGHTNESS,
PLATFORM_SCHEMA, PLATFORM_SCHEMA,
SUPPORT_BRIGHTNESS, SUPPORT_BRIGHTNESS,
Light, LightEntity,
) )
from homeassistant.const import CONF_DEVICES, CONF_HOST, CONF_NAME, CONF_PORT from homeassistant.const import CONF_DEVICES, CONF_HOST, CONF_NAME, CONF_PORT
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
@ -64,7 +64,7 @@ def to_hass_level(level):
return int((level * 255) / 100) return int((level * 255) / 100)
class FutureNowLight(Light): class FutureNowLight(LightEntity):
"""Representation of an FutureNow light.""" """Representation of an FutureNow light."""
def __init__(self, device): def __init__(self, device):

View File

@ -10,7 +10,7 @@ from homeassistant.components.light import (
ATTR_BRIGHTNESS, ATTR_BRIGHTNESS,
PLATFORM_SCHEMA, PLATFORM_SCHEMA,
SUPPORT_BRIGHTNESS, SUPPORT_BRIGHTNESS,
Light, LightEntity,
) )
from homeassistant.const import CONF_HOST from homeassistant.const import CONF_HOST
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
@ -54,7 +54,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
) )
class GreenwaveLight(Light): class GreenwaveLight(LightEntity):
"""Representation of an Greenwave Reality Light.""" """Representation of an Greenwave Reality Light."""
def __init__(self, light, host, token, gatewaydata): def __init__(self, light, host, token, gatewaydata):

View File

@ -76,7 +76,7 @@ async def async_setup_platform(
) )
class LightGroup(light.Light): class LightGroup(light.LightEntity):
"""Representation of a light group.""" """Representation of a light group."""
def __init__(self, name: str, entity_ids: List[str]) -> None: def __init__(self, name: str, entity_ids: List[str]) -> None:

View File

@ -6,7 +6,7 @@ from homeassistant.components.light import (
SUPPORT_BRIGHTNESS, SUPPORT_BRIGHTNESS,
SUPPORT_COLOR, SUPPORT_COLOR,
SUPPORT_COLOR_TEMP, SUPPORT_COLOR_TEMP,
Light, LightEntity,
) )
import homeassistant.util.color as color_util import homeassistant.util.color as color_util
@ -25,7 +25,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities(devs) add_entities(devs)
class HiveDeviceLight(HiveEntity, Light): class HiveDeviceLight(HiveEntity, LightEntity):
"""Hive Active Light Device.""" """Hive Active Light Device."""
def __init__(self, hive_session, hive_device): def __init__(self, hive_session, hive_device):

View File

@ -10,7 +10,7 @@ from homeassistant.components.light import (
SUPPORT_BRIGHTNESS, SUPPORT_BRIGHTNESS,
SUPPORT_COLOR, SUPPORT_COLOR,
SUPPORT_COLOR_TEMP, SUPPORT_COLOR_TEMP,
Light, LightEntity,
) )
from homeassistant.core import callback from homeassistant.core import callback
@ -35,7 +35,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
conn.add_listener(async_add_service) conn.add_listener(async_add_service)
class HomeKitLight(HomeKitEntity, Light): class HomeKitLight(HomeKitEntity, LightEntity):
"""Representation of a Homekit light.""" """Representation of a Homekit light."""
def get_characteristic_types(self): def get_characteristic_types(self):

View File

@ -11,7 +11,7 @@ from homeassistant.components.light import (
SUPPORT_COLOR, SUPPORT_COLOR,
SUPPORT_COLOR_TEMP, SUPPORT_COLOR_TEMP,
SUPPORT_EFFECT, SUPPORT_EFFECT,
Light, LightEntity,
) )
from .const import ATTR_DISCOVER_DEVICES from .const import ATTR_DISCOVER_DEVICES
@ -35,7 +35,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities(devices, True) add_entities(devices, True)
class HMLight(HMDevice, Light): class HMLight(HMDevice, LightEntity):
"""Representation of a Homematic light.""" """Representation of a Homematic light."""
@property @property

View File

@ -21,7 +21,7 @@ from homeassistant.components.light import (
SUPPORT_BRIGHTNESS, SUPPORT_BRIGHTNESS,
SUPPORT_COLOR, SUPPORT_COLOR,
SUPPORT_TRANSITION, SUPPORT_TRANSITION,
Light, LightEntity,
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.helpers.typing import HomeAssistantType from homeassistant.helpers.typing import HomeAssistantType
@ -64,7 +64,7 @@ async def async_setup_entry(
async_add_entities(entities) async_add_entities(entities)
class HomematicipLight(HomematicipGenericDevice, Light): class HomematicipLight(HomematicipGenericDevice, LightEntity):
"""Representation of a HomematicIP Cloud light device.""" """Representation of a HomematicIP Cloud light device."""
def __init__(self, hap: HomematicipHAP, device) -> None: def __init__(self, hap: HomematicipHAP, device) -> None:
@ -110,7 +110,7 @@ class HomematicipLightMeasuring(HomematicipLight):
return state_attr return state_attr
class HomematicipDimmer(HomematicipGenericDevice, Light): class HomematicipDimmer(HomematicipGenericDevice, LightEntity):
"""Representation of HomematicIP Cloud dimmer light device.""" """Representation of HomematicIP Cloud dimmer light device."""
def __init__(self, hap: HomematicipHAP, device) -> None: def __init__(self, hap: HomematicipHAP, device) -> None:
@ -144,7 +144,7 @@ class HomematicipDimmer(HomematicipGenericDevice, Light):
await self._device.set_dim_level(0) await self._device.set_dim_level(0)
class HomematicipNotificationLight(HomematicipGenericDevice, Light): class HomematicipNotificationLight(HomematicipGenericDevice, LightEntity):
"""Representation of HomematicIP Cloud dimmer light device.""" """Representation of HomematicIP Cloud dimmer light device."""
def __init__(self, hap: HomematicipHAP, device, channel: int) -> None: def __init__(self, hap: HomematicipHAP, device, channel: int) -> None:

View File

@ -3,7 +3,11 @@ import logging
from pyhomeworks.pyhomeworks import HW_LIGHT_CHANGED from pyhomeworks.pyhomeworks import HW_LIGHT_CHANGED
from homeassistant.components.light import ATTR_BRIGHTNESS, SUPPORT_BRIGHTNESS, Light from homeassistant.components.light import (
ATTR_BRIGHTNESS,
SUPPORT_BRIGHTNESS,
LightEntity,
)
from homeassistant.const import CONF_NAME from homeassistant.const import CONF_NAME
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.dispatcher import async_dispatcher_connect
@ -28,7 +32,7 @@ def setup_platform(hass, config, add_entities, discover_info=None):
add_entities(devs, True) add_entities(devs, True)
class HomeworksLight(HomeworksDevice, Light): class HomeworksLight(HomeworksDevice, LightEntity):
"""Homeworks Light.""" """Homeworks Light."""
def __init__(self, controller, addr, name, rate): def __init__(self, controller, addr, name, rate):

View File

@ -24,7 +24,7 @@ from homeassistant.components.light import (
SUPPORT_EFFECT, SUPPORT_EFFECT,
SUPPORT_FLASH, SUPPORT_FLASH,
SUPPORT_TRANSITION, SUPPORT_TRANSITION,
Light, LightEntity,
) )
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.exceptions import PlatformNotReady from homeassistant.exceptions import PlatformNotReady
@ -194,7 +194,7 @@ def hass_to_hue_brightness(value):
return max(1, round((value / 255) * 254)) return max(1, round((value / 255) * 254))
class HueLight(Light): class HueLight(LightEntity):
"""Representation of a Hue light.""" """Representation of a Hue light."""
def __init__(self, coordinator, bridge, is_group, light, supported_features): def __init__(self, coordinator, bridge, is_group, light, supported_features):

View File

@ -13,7 +13,7 @@ from homeassistant.components.light import (
SUPPORT_BRIGHTNESS, SUPPORT_BRIGHTNESS,
SUPPORT_COLOR, SUPPORT_COLOR,
SUPPORT_EFFECT, SUPPORT_EFFECT,
Light, LightEntity,
) )
from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PORT from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PORT
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
@ -103,7 +103,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities([device]) add_entities([device])
class Hyperion(Light): class Hyperion(LightEntity):
"""Representation of a Hyperion remote.""" """Representation of a Hyperion remote."""
def __init__( def __init__(

View File

@ -9,7 +9,7 @@ from homeassistant.components.light import (
DOMAIN, DOMAIN,
SUPPORT_BRIGHTNESS, SUPPORT_BRIGHTNESS,
SUPPORT_EFFECT, SUPPORT_EFFECT,
Light, LightEntity,
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.helpers.typing import HomeAssistantType from homeassistant.helpers.typing import HomeAssistantType
@ -32,7 +32,7 @@ async def async_setup_entry(
async_add_entities(devs, True) async_add_entities(devs, True)
class HassAqualinkLight(AqualinkEntity, Light): class HassAqualinkLight(AqualinkEntity, LightEntity):
"""Representation of a light.""" """Representation of a light."""
@property @property

View File

@ -15,7 +15,7 @@ from homeassistant.components.light import (
SUPPORT_COLOR, SUPPORT_COLOR,
SUPPORT_COLOR_TEMP, SUPPORT_COLOR_TEMP,
SUPPORT_EFFECT, SUPPORT_EFFECT,
Light, LightEntity,
) )
from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PORT from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PORT
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
@ -43,7 +43,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities([IGloLamp(name, host, port)], True) add_entities([IGloLamp(name, host, port)], True)
class IGloLamp(Light): class IGloLamp(LightEntity):
"""Representation of an iGlo light.""" """Representation of an iGlo light."""
def __init__(self, name, host, port): def __init__(self, name, host, port):

View File

@ -1,7 +1,11 @@
"""Support for IHC lights.""" """Support for IHC lights."""
import logging import logging
from homeassistant.components.light import ATTR_BRIGHTNESS, SUPPORT_BRIGHTNESS, Light from homeassistant.components.light import (
ATTR_BRIGHTNESS,
SUPPORT_BRIGHTNESS,
LightEntity,
)
from . import IHC_CONTROLLER, IHC_INFO from . import IHC_CONTROLLER, IHC_INFO
from .const import CONF_DIMMABLE, CONF_OFF_ID, CONF_ON_ID from .const import CONF_DIMMABLE, CONF_OFF_ID, CONF_ON_ID
@ -35,7 +39,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities(devices) add_entities(devices)
class IhcLight(IHCDevice, Light): class IhcLight(IHCDevice, LightEntity):
"""Representation of a IHC light. """Representation of a IHC light.
For dimmable lights, the associated IHC resource should be a light For dimmable lights, the associated IHC resource should be a light

View File

@ -1,7 +1,11 @@
"""Support for Insteon lights via PowerLinc Modem.""" """Support for Insteon lights via PowerLinc Modem."""
import logging import logging
from homeassistant.components.light import ATTR_BRIGHTNESS, SUPPORT_BRIGHTNESS, Light from homeassistant.components.light import (
ATTR_BRIGHTNESS,
SUPPORT_BRIGHTNESS,
LightEntity,
)
from .insteon_entity import InsteonEntity from .insteon_entity import InsteonEntity
@ -29,7 +33,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
async_add_entities([new_entity]) async_add_entities([new_entity])
class InsteonDimmerDevice(InsteonEntity, Light): class InsteonDimmerDevice(InsteonEntity, LightEntity):
"""A Class for an Insteon device.""" """A Class for an Insteon device."""
@property @property

View File

@ -2,7 +2,7 @@
import logging import logging
from typing import Callable from typing import Callable
from homeassistant.components.light import DOMAIN, SUPPORT_BRIGHTNESS, Light from homeassistant.components.light import DOMAIN, SUPPORT_BRIGHTNESS, LightEntity
from homeassistant.helpers.typing import ConfigType from homeassistant.helpers.typing import ConfigType
from . import ISY994_NODES, ISYDevice from . import ISY994_NODES, ISYDevice
@ -21,7 +21,7 @@ def setup_platform(
add_entities(devices) add_entities(devices)
class ISYLightDevice(ISYDevice, Light): class ISYLightDevice(ISYDevice, LightEntity):
"""Representation of an ISY994 light device.""" """Representation of an ISY994 light device."""
def __init__(self, node) -> None: def __init__(self, node) -> None:

View File

@ -14,7 +14,7 @@ from homeassistant.components.light import (
SUPPORT_COLOR, SUPPORT_COLOR,
SUPPORT_COLOR_TEMP, SUPPORT_COLOR_TEMP,
SUPPORT_WHITE_VALUE, SUPPORT_WHITE_VALUE,
Light, LightEntity,
) )
from homeassistant.const import CONF_ADDRESS, CONF_NAME from homeassistant.const import CONF_ADDRESS, CONF_NAME
from homeassistant.core import callback from homeassistant.core import callback
@ -132,7 +132,7 @@ def async_add_entities_config(hass, config, async_add_entities):
async_add_entities([KNXLight(light)]) async_add_entities([KNXLight(light)])
class KNXLight(Light): class KNXLight(LightEntity):
"""Representation of a KNX light.""" """Representation of a KNX light."""
def __init__(self, device): def __init__(self, device):

View File

@ -6,7 +6,7 @@ from homeassistant.components.light import (
ATTR_TRANSITION, ATTR_TRANSITION,
SUPPORT_BRIGHTNESS, SUPPORT_BRIGHTNESS,
SUPPORT_TRANSITION, SUPPORT_TRANSITION,
Light, LightEntity,
) )
from homeassistant.const import CONF_ADDRESS from homeassistant.const import CONF_ADDRESS
@ -47,7 +47,7 @@ async def async_setup_platform(
async_add_entities(devices) async_add_entities(devices)
class LcnOutputLight(LcnDevice, Light): class LcnOutputLight(LcnDevice, LightEntity):
"""Representation of a LCN light for output ports.""" """Representation of a LCN light for output ports."""
def __init__(self, config, address_connection): def __init__(self, config, address_connection):
@ -135,7 +135,7 @@ class LcnOutputLight(LcnDevice, Light):
self.async_write_ha_state() self.async_write_ha_state()
class LcnRelayLight(LcnDevice, Light): class LcnRelayLight(LcnDevice, LightEntity):
"""Representation of a LCN light for relay ports.""" """Representation of a LCN light for relay ports."""
def __init__(self, config, address_connection): def __init__(self, config, address_connection):

View File

@ -32,7 +32,7 @@ from homeassistant.components.light import (
SUPPORT_TRANSITION, SUPPORT_TRANSITION,
VALID_BRIGHTNESS, VALID_BRIGHTNESS,
VALID_BRIGHTNESS_PCT, VALID_BRIGHTNESS_PCT,
Light, LightEntity,
preprocess_turn_on_alternatives, preprocess_turn_on_alternatives,
) )
from homeassistant.const import ATTR_ENTITY_ID, ATTR_MODE, EVENT_HOMEASSISTANT_STOP from homeassistant.const import ATTR_ENTITY_ID, ATTR_MODE, EVENT_HOMEASSISTANT_STOP
@ -438,7 +438,7 @@ def convert_16_to_8(value):
return value >> 8 return value >> 8
class LIFXLight(Light): class LIFXLight(LightEntity):
"""Representation of a LIFX light.""" """Representation of a LIFX light."""
def __init__(self, bulb, effects_conductor): def __init__(self, bulb, effects_conductor):

View File

@ -19,7 +19,7 @@ from homeassistant.components.light import (
SUPPORT_COLOR, SUPPORT_COLOR,
SUPPORT_COLOR_TEMP, SUPPORT_COLOR_TEMP,
SUPPORT_TRANSITION, SUPPORT_TRANSITION,
Light, LightEntity,
) )
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.event import track_time_change from homeassistant.helpers.event import track_time_change
@ -137,7 +137,7 @@ class LIFX:
self._liffylights.probe(address) self._liffylights.probe(address)
class LIFXLight(Light): class LIFXLight(LightEntity):
"""Representation of a LIFX light.""" """Representation of a LIFX light."""
def __init__(self, liffy, ipaddr, name, power, hue, saturation, brightness, kelvin): def __init__(self, liffy, ipaddr, name, power, hue, saturation, brightness, kelvin):

View File

@ -332,7 +332,7 @@ class Profiles:
return None return None
class Light(ToggleEntity): class LightEntity(ToggleEntity):
"""Representation of a light.""" """Representation of a light."""
@property @property
@ -428,3 +428,14 @@ class Light(ToggleEntity):
def supported_features(self): def supported_features(self):
"""Flag supported features.""" """Flag supported features."""
return 0 return 0
class Light(LightEntity):
"""Representation of a light (for backwards compatibility)."""
def __init_subclass__(cls, **kwargs):
"""Print deprecation warning."""
super().__init_subclass__(**kwargs)
_LOGGER.warning(
"Light is deprecated, modify %s to extend LightEntity", cls.__name__,
)

View File

@ -1,5 +1,9 @@
"""Support for LightwaveRF lights.""" """Support for LightwaveRF lights."""
from homeassistant.components.light import ATTR_BRIGHTNESS, SUPPORT_BRIGHTNESS, Light from homeassistant.components.light import (
ATTR_BRIGHTNESS,
SUPPORT_BRIGHTNESS,
LightEntity,
)
from homeassistant.const import CONF_NAME from homeassistant.const import CONF_NAME
from . import LIGHTWAVE_LINK from . import LIGHTWAVE_LINK
@ -22,7 +26,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
async_add_entities(lights) async_add_entities(lights)
class LWRFLight(Light): class LWRFLight(LightEntity):
"""Representation of a LightWaveRF light.""" """Representation of a LightWaveRF light."""
def __init__(self, name, device_id, lwlink): def __init__(self, name, device_id, lwlink):

View File

@ -28,7 +28,7 @@ from homeassistant.components.light import (
SUPPORT_EFFECT, SUPPORT_EFFECT,
SUPPORT_FLASH, SUPPORT_FLASH,
SUPPORT_TRANSITION, SUPPORT_TRANSITION,
Light, LightEntity,
) )
from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PORT, CONF_TYPE, STATE_ON from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PORT, CONF_TYPE, STATE_ON
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
@ -200,7 +200,7 @@ def state(new_state):
return decorator return decorator
class LimitlessLEDGroup(Light, RestoreEntity): class LimitlessLEDGroup(LightEntity, RestoreEntity):
"""Representation of a LimitessLED group.""" """Representation of a LimitessLED group."""
def __init__(self, group, config): def __init__(self, group, config):

View File

@ -2,7 +2,11 @@
import logging import logging
from homeassistant.components import litejet from homeassistant.components import litejet
from homeassistant.components.light import ATTR_BRIGHTNESS, SUPPORT_BRIGHTNESS, Light from homeassistant.components.light import (
ATTR_BRIGHTNESS,
SUPPORT_BRIGHTNESS,
LightEntity,
)
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -21,7 +25,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities(devices, True) add_entities(devices, True)
class LiteJetLight(Light): class LiteJetLight(LightEntity):
"""Representation of a single LiteJet light.""" """Representation of a single LiteJet light."""
def __init__(self, hass, lj, i, name): def __init__(self, hass, lj, i, name):

View File

@ -1,7 +1,11 @@
"""Support for Lutron lights.""" """Support for Lutron lights."""
import logging import logging
from homeassistant.components.light import ATTR_BRIGHTNESS, SUPPORT_BRIGHTNESS, Light from homeassistant.components.light import (
ATTR_BRIGHTNESS,
SUPPORT_BRIGHTNESS,
LightEntity,
)
from . import LUTRON_CONTROLLER, LUTRON_DEVICES, LutronDevice from . import LUTRON_CONTROLLER, LUTRON_DEVICES, LutronDevice
@ -28,7 +32,7 @@ def to_hass_level(level):
return int((level * 255) / 100) return int((level * 255) / 100)
class LutronLight(LutronDevice, Light): class LutronLight(LutronDevice, LightEntity):
"""Representation of a Lutron Light, including dimmable.""" """Representation of a Lutron Light, including dimmable."""
def __init__(self, area_name, lutron_device, controller): def __init__(self, area_name, lutron_device, controller):

View File

@ -5,7 +5,7 @@ from homeassistant.components.light import (
ATTR_BRIGHTNESS, ATTR_BRIGHTNESS,
DOMAIN, DOMAIN,
SUPPORT_BRIGHTNESS, SUPPORT_BRIGHTNESS,
Light, LightEntity,
) )
from . import LUTRON_CASETA_SMARTBRIDGE, LutronCasetaDevice from . import LUTRON_CASETA_SMARTBRIDGE, LutronCasetaDevice
@ -35,7 +35,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
async_add_entities(entities, True) async_add_entities(entities, True)
class LutronCasetaLight(LutronCasetaDevice, Light): class LutronCasetaLight(LutronCasetaDevice, LightEntity):
"""Representation of a Lutron Light, including dimmable.""" """Representation of a Lutron Light, including dimmable."""
@property @property

View File

@ -15,7 +15,7 @@ from homeassistant.components.light import (
SUPPORT_COLOR, SUPPORT_COLOR,
SUPPORT_EFFECT, SUPPORT_EFFECT,
SUPPORT_TRANSITION, SUPPORT_TRANSITION,
Light, LightEntity,
) )
from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PORT from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PORT
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
@ -47,7 +47,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities([LW12WiFi(name, lw12_light)]) add_entities([LW12WiFi(name, lw12_light)])
class LW12WiFi(Light): class LW12WiFi(LightEntity):
"""LW-12 WiFi LED Controller.""" """LW-12 WiFi LED Controller."""
def __init__(self, name, lw12_light): def __init__(self, name, lw12_light):

View File

@ -8,7 +8,7 @@ from homeassistant.components.light import (
ATTR_BRIGHTNESS, ATTR_BRIGHTNESS,
PLATFORM_SCHEMA, PLATFORM_SCHEMA,
SUPPORT_BRIGHTNESS, SUPPORT_BRIGHTNESS,
Light, LightEntity,
) )
from homeassistant.const import CONF_ADDRESS, CONF_DEVICES, CONF_NAME, CONF_PLATFORM from homeassistant.const import CONF_ADDRESS, CONF_DEVICES, CONF_NAME, CONF_PLATFORM
from homeassistant.helpers import config_validation as cv from homeassistant.helpers import config_validation as cv
@ -44,7 +44,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
return True return True
class MochadLight(Light): class MochadLight(LightEntity):
"""Representation of a X10 dimmer over Mochad.""" """Representation of a X10 dimmer over Mochad."""
def __init__(self, hass, ctrl, dev): def __init__(self, hass, ctrl, dev):

View File

@ -15,7 +15,7 @@ from homeassistant.components.light import (
SUPPORT_COLOR_TEMP, SUPPORT_COLOR_TEMP,
SUPPORT_EFFECT, SUPPORT_EFFECT,
SUPPORT_WHITE_VALUE, SUPPORT_WHITE_VALUE,
Light, LightEntity,
) )
from homeassistant.components.mqtt import ( from homeassistant.components.mqtt import (
CONF_COMMAND_TOPIC, CONF_COMMAND_TOPIC,
@ -86,7 +86,7 @@ CONF_WHITE_VALUE_TEMPLATE = "white_value_template"
CONF_ON_COMMAND_TYPE = "on_command_type" CONF_ON_COMMAND_TYPE = "on_command_type"
DEFAULT_BRIGHTNESS_SCALE = 255 DEFAULT_BRIGHTNESS_SCALE = 255
DEFAULT_NAME = "MQTT Light" DEFAULT_NAME = "MQTT LightEntity"
DEFAULT_OPTIMISTIC = False DEFAULT_OPTIMISTIC = False
DEFAULT_PAYLOAD_OFF = "OFF" DEFAULT_PAYLOAD_OFF = "OFF"
DEFAULT_PAYLOAD_ON = "ON" DEFAULT_PAYLOAD_ON = "ON"
@ -160,7 +160,7 @@ class MqttLight(
MqttAvailability, MqttAvailability,
MqttDiscoveryUpdate, MqttDiscoveryUpdate,
MqttEntityDeviceInfo, MqttEntityDeviceInfo,
Light, LightEntity,
RestoreEntity, RestoreEntity,
): ):
"""Representation of a MQTT light.""" """Representation of a MQTT light."""

View File

@ -22,7 +22,7 @@ from homeassistant.components.light import (
SUPPORT_FLASH, SUPPORT_FLASH,
SUPPORT_TRANSITION, SUPPORT_TRANSITION,
SUPPORT_WHITE_VALUE, SUPPORT_WHITE_VALUE,
Light, LightEntity,
) )
from homeassistant.components.mqtt import ( from homeassistant.components.mqtt import (
CONF_COMMAND_TOPIC, CONF_COMMAND_TOPIC,
@ -131,7 +131,7 @@ class MqttLightJson(
MqttAvailability, MqttAvailability,
MqttDiscoveryUpdate, MqttDiscoveryUpdate,
MqttEntityDeviceInfo, MqttEntityDeviceInfo,
Light, LightEntity,
RestoreEntity, RestoreEntity,
): ):
"""Representation of a MQTT JSON light.""" """Representation of a MQTT JSON light."""

View File

@ -19,7 +19,7 @@ from homeassistant.components.light import (
SUPPORT_FLASH, SUPPORT_FLASH,
SUPPORT_TRANSITION, SUPPORT_TRANSITION,
SUPPORT_WHITE_VALUE, SUPPORT_WHITE_VALUE,
Light, LightEntity,
) )
from homeassistant.components.mqtt import ( from homeassistant.components.mqtt import (
CONF_COMMAND_TOPIC, CONF_COMMAND_TOPIC,
@ -105,7 +105,7 @@ class MqttTemplate(
MqttAvailability, MqttAvailability,
MqttDiscoveryUpdate, MqttDiscoveryUpdate,
MqttEntityDeviceInfo, MqttEntityDeviceInfo,
Light, LightEntity,
RestoreEntity, RestoreEntity,
): ):
"""Representation of a MQTT Template light.""" """Representation of a MQTT Template light."""

View File

@ -8,7 +8,7 @@ from homeassistant.components.light import (
SUPPORT_BRIGHTNESS, SUPPORT_BRIGHTNESS,
SUPPORT_COLOR, SUPPORT_COLOR,
SUPPORT_WHITE_VALUE, SUPPORT_WHITE_VALUE,
Light, LightEntity,
) )
from homeassistant.const import STATE_OFF, STATE_ON from homeassistant.const import STATE_OFF, STATE_ON
from homeassistant.core import callback from homeassistant.core import callback
@ -34,7 +34,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
) )
class MySensorsLight(mysensors.device.MySensorsEntity, Light): class MySensorsLight(mysensors.device.MySensorsEntity, LightEntity):
"""Representation of a MySensors Light child node.""" """Representation of a MySensors Light child node."""
def __init__(self, *args): def __init__(self, *args):

View File

@ -14,7 +14,7 @@ from homeassistant.components.light import (
SUPPORT_COLOR, SUPPORT_COLOR,
SUPPORT_EFFECT, SUPPORT_EFFECT,
SUPPORT_FLASH, SUPPORT_FLASH,
Light, LightEntity,
) )
from homeassistant.const import CONF_HOST, CONF_MAC, CONF_NAME from homeassistant.const import CONF_HOST, CONF_MAC, CONF_NAME
from homeassistant.exceptions import PlatformNotReady from homeassistant.exceptions import PlatformNotReady
@ -59,7 +59,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
async_add_entities([MyStromLight(bulb, name, mac)], True) async_add_entities([MyStromLight(bulb, name, mac)], True)
class MyStromLight(Light): class MyStromLight(LightEntity):
"""Representation of the myStrom WiFi bulb.""" """Representation of the myStrom WiFi bulb."""
def __init__(self, bulb, name, mac): def __init__(self, bulb, name, mac):

View File

@ -16,7 +16,7 @@ from homeassistant.components.light import (
SUPPORT_COLOR_TEMP, SUPPORT_COLOR_TEMP,
SUPPORT_EFFECT, SUPPORT_EFFECT,
SUPPORT_TRANSITION, SUPPORT_TRANSITION,
Light, LightEntity,
) )
from homeassistant.const import CONF_HOST, CONF_NAME, CONF_TOKEN from homeassistant.const import CONF_HOST, CONF_NAME, CONF_TOKEN
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
@ -103,7 +103,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities([NanoleafLight(nanoleaf_light, name)], True) add_entities([NanoleafLight(nanoleaf_light, name)], True)
class NanoleafLight(Light): class NanoleafLight(LightEntity):
"""Representation of a Nanoleaf Light.""" """Representation of a Nanoleaf Light."""
def __init__(self, light, name): def __init__(self, light, name):

View File

@ -6,7 +6,7 @@ import nikohomecontrol
import voluptuous as vol import voluptuous as vol
# Import the device class from the component that you want to support # Import the device class from the component that you want to support
from homeassistant.components.light import ATTR_BRIGHTNESS, PLATFORM_SCHEMA, Light from homeassistant.components.light import ATTR_BRIGHTNESS, PLATFORM_SCHEMA, LightEntity
from homeassistant.const import CONF_HOST from homeassistant.const import CONF_HOST
from homeassistant.exceptions import PlatformNotReady from homeassistant.exceptions import PlatformNotReady
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
@ -38,7 +38,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
) )
class NikoHomeControlLight(Light): class NikoHomeControlLight(LightEntity):
"""Representation of an Niko Light.""" """Representation of an Niko Light."""
def __init__(self, light, data): def __init__(self, light, data):

View File

@ -10,7 +10,7 @@ from homeassistant.components.light import (
PLATFORM_SCHEMA, PLATFORM_SCHEMA,
SUPPORT_BRIGHTNESS, SUPPORT_BRIGHTNESS,
SUPPORT_COLOR_TEMP, SUPPORT_COLOR_TEMP,
Light, LightEntity,
) )
from homeassistant.const import CONF_HOST, CONF_NAME from homeassistant.const import CONF_HOST, CONF_NAME
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
@ -42,7 +42,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
_LOGGER.debug("Init light %s %s", host, entity.unique_id) _LOGGER.debug("Init light %s %s", host, entity.unique_id)
class OppleLight(Light): class OppleLight(LightEntity):
"""Opple light device.""" """Opple light device."""
def __init__(self, name, host): def __init__(self, name, host):

View File

@ -18,7 +18,7 @@ from homeassistant.components.light import (
SUPPORT_COLOR_TEMP, SUPPORT_COLOR_TEMP,
SUPPORT_EFFECT, SUPPORT_EFFECT,
SUPPORT_TRANSITION, SUPPORT_TRANSITION,
Light, LightEntity,
) )
from homeassistant.const import CONF_HOST from homeassistant.const import CONF_HOST
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
@ -168,7 +168,7 @@ def setup_bridge(bridge, add_entities, config):
update_groups() update_groups()
class Luminary(Light): class Luminary(LightEntity):
"""Representation of Luminary Lights and Groups.""" """Representation of Luminary Lights and Groups."""
def __init__(self, luminary, update_func, changed): def __init__(self, luminary, update_func, changed):

View File

@ -11,7 +11,7 @@ from homeassistant.components.light import (
PLATFORM_SCHEMA, PLATFORM_SCHEMA,
SUPPORT_BRIGHTNESS, SUPPORT_BRIGHTNESS,
SUPPORT_COLOR, SUPPORT_COLOR,
Light, LightEntity,
) )
from homeassistant.const import CONF_NAME from homeassistant.const import CONF_NAME
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
@ -39,7 +39,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities([PiglowLight(name)]) add_entities([PiglowLight(name)])
class PiglowLight(Light): class PiglowLight(LightEntity):
"""Representation of an Piglow Light.""" """Representation of an Piglow Light."""
def __init__(self, name): def __init__(self, name):

View File

@ -7,7 +7,7 @@ from homeassistant.components.light import (
ATTR_BRIGHTNESS, ATTR_BRIGHTNESS,
PLATFORM_SCHEMA, PLATFORM_SCHEMA,
SUPPORT_BRIGHTNESS, SUPPORT_BRIGHTNESS,
Light, LightEntity,
) )
from homeassistant.const import CONF_LIGHTS from homeassistant.const import CONF_LIGHTS
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
@ -40,7 +40,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities(devices) add_entities(devices)
class PilightLight(PilightBaseDevice, Light): class PilightLight(PilightBaseDevice, LightEntity):
"""Representation of a Pilight switch.""" """Representation of a Pilight switch."""
def __init__(self, hass, name, config): def __init__(self, hass, name, config):

View File

@ -4,7 +4,7 @@ from homeassistant.components.light import (
ATTR_HS_COLOR, ATTR_HS_COLOR,
SUPPORT_BRIGHTNESS, SUPPORT_BRIGHTNESS,
SUPPORT_COLOR, SUPPORT_COLOR,
Light, LightEntity,
) )
import homeassistant.util.color as color_util import homeassistant.util.color as color_util
@ -32,7 +32,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
async_add_entities(entities) async_add_entities(entities)
class PlumLight(Light): class PlumLight(LightEntity):
"""Representation of a Plum Lightpad dimmer.""" """Representation of a Plum Lightpad dimmer."""
def __init__(self, load): def __init__(self, load):
@ -88,7 +88,7 @@ class PlumLight(Light):
await self._load.turn_off() await self._load.turn_off()
class GlowRing(Light): class GlowRing(LightEntity):
"""Representation of a Plum Lightpad dimmer glow ring.""" """Representation of a Plum Lightpad dimmer glow ring."""
def __init__(self, lightpad): def __init__(self, lightpad):

View File

@ -1,5 +1,5 @@
"""Support for Qwikswitch Relays and Dimmers.""" """Support for Qwikswitch Relays and Dimmers."""
from homeassistant.components.light import SUPPORT_BRIGHTNESS, Light from homeassistant.components.light import SUPPORT_BRIGHTNESS, LightEntity
from . import DOMAIN as QWIKSWITCH, QSToggleEntity from . import DOMAIN as QWIKSWITCH, QSToggleEntity
@ -14,7 +14,7 @@ async def async_setup_platform(hass, _, add_entities, discovery_info=None):
add_entities(devs) add_entities(devs)
class QSLight(QSToggleEntity, Light): class QSLight(QSToggleEntity, LightEntity):
"""Light based on a Qwikswitch relay/dimmer module.""" """Light based on a Qwikswitch relay/dimmer module."""
@property @property

View File

@ -7,7 +7,7 @@ from homeassistant.components.light import (
ATTR_BRIGHTNESS, ATTR_BRIGHTNESS,
PLATFORM_SCHEMA, PLATFORM_SCHEMA,
SUPPORT_BRIGHTNESS, SUPPORT_BRIGHTNESS,
Light, LightEntity,
) )
from homeassistant.const import CONF_NAME, CONF_TYPE from homeassistant.const import CONF_NAME, CONF_TYPE
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
@ -159,11 +159,11 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
hass.data[DATA_DEVICE_REGISTER][EVENT_KEY_COMMAND] = add_new_device hass.data[DATA_DEVICE_REGISTER][EVENT_KEY_COMMAND] = add_new_device
class RflinkLight(SwitchableRflinkDevice, Light): class RflinkLight(SwitchableRflinkDevice, LightEntity):
"""Representation of a Rflink light.""" """Representation of a Rflink light."""
class DimmableRflinkLight(SwitchableRflinkDevice, Light): class DimmableRflinkLight(SwitchableRflinkDevice, LightEntity):
"""Rflink light device that support dimming.""" """Rflink light device that support dimming."""
_brightness = 255 _brightness = 255
@ -208,7 +208,7 @@ class DimmableRflinkLight(SwitchableRflinkDevice, Light):
return SUPPORT_BRIGHTNESS return SUPPORT_BRIGHTNESS
class HybridRflinkLight(SwitchableRflinkDevice, Light): class HybridRflinkLight(SwitchableRflinkDevice, LightEntity):
"""Rflink light device that sends out both dim and on/off commands. """Rflink light device that sends out both dim and on/off commands.
Used for protocols which support lights that are not exclusively on/off Used for protocols which support lights that are not exclusively on/off
@ -271,7 +271,7 @@ class HybridRflinkLight(SwitchableRflinkDevice, Light):
return SUPPORT_BRIGHTNESS return SUPPORT_BRIGHTNESS
class ToggleRflinkLight(SwitchableRflinkDevice, Light): class ToggleRflinkLight(SwitchableRflinkDevice, LightEntity):
"""Rflink light device which sends out only 'on' commands. """Rflink light device which sends out only 'on' commands.
Some switches like for example Livolo light switches use the Some switches like for example Livolo light switches use the

View File

@ -8,7 +8,7 @@ from homeassistant.components.light import (
ATTR_BRIGHTNESS, ATTR_BRIGHTNESS,
PLATFORM_SCHEMA, PLATFORM_SCHEMA,
SUPPORT_BRIGHTNESS, SUPPORT_BRIGHTNESS,
Light, LightEntity,
) )
from homeassistant.const import CONF_NAME, STATE_ON from homeassistant.const import CONF_NAME, STATE_ON
from homeassistant.helpers import config_validation as cv from homeassistant.helpers import config_validation as cv
@ -73,7 +73,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
RECEIVED_EVT_SUBSCRIBERS.append(light_update) RECEIVED_EVT_SUBSCRIBERS.append(light_update)
class RfxtrxLight(RfxtrxDevice, Light, RestoreEntity): class RfxtrxLight(RfxtrxDevice, LightEntity, RestoreEntity):
"""Representation of a RFXtrx light.""" """Representation of a RFXtrx light."""
async def async_added_to_hass(self): async def async_added_to_hass(self):

View File

@ -4,7 +4,7 @@ import logging
import requests import requests
from homeassistant.components.light import Light from homeassistant.components.light import LightEntity
from homeassistant.core import callback from homeassistant.core import callback
import homeassistant.util.dt as dt_util import homeassistant.util.dt as dt_util
@ -38,7 +38,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
async_add_entities(lights) async_add_entities(lights)
class RingLight(RingEntityMixin, Light): class RingLight(RingEntityMixin, LightEntity):
"""Creates a switch to turn the ring cameras light on and off.""" """Creates a switch to turn the ring cameras light on and off."""
def __init__(self, config_entry_id, device): def __init__(self, config_entry_id, device):

View File

@ -4,7 +4,7 @@ import logging
from scsgate.tasks import ToggleStatusTask from scsgate.tasks import ToggleStatusTask
import voluptuous as vol import voluptuous as vol
from homeassistant.components.light import PLATFORM_SCHEMA, Light from homeassistant.components.light import PLATFORM_SCHEMA, LightEntity
from homeassistant.const import ATTR_ENTITY_ID, ATTR_STATE, CONF_DEVICES, CONF_NAME from homeassistant.const import ATTR_ENTITY_ID, ATTR_STATE, CONF_DEVICES, CONF_NAME
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
@ -43,7 +43,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
scsgate.add_devices_to_register(lights) scsgate.add_devices_to_register(lights)
class SCSGateLight(Light): class SCSGateLight(LightEntity):
"""Representation of a SCSGate light.""" """Representation of a SCSGate light."""
def __init__(self, scs_id, name, logger, scsgate): def __init__(self, scs_id, name, logger, scsgate):

View File

@ -10,7 +10,7 @@ from homeassistant.components.light import (
PLATFORM_SCHEMA, PLATFORM_SCHEMA,
SUPPORT_BRIGHTNESS, SUPPORT_BRIGHTNESS,
SUPPORT_COLOR, SUPPORT_COLOR,
Light, LightEntity,
) )
from homeassistant.const import CONF_NAME from homeassistant.const import CONF_NAME
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
@ -37,7 +37,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities([SenseHatLight(sensehat, name)]) add_entities([SenseHatLight(sensehat, name)])
class SenseHatLight(Light): class SenseHatLight(LightEntity):
"""Representation of an Sense Hat Light.""" """Representation of an Sense Hat Light."""
def __init__(self, sensehat, name): def __init__(self, sensehat, name):

View File

@ -3,7 +3,7 @@ import logging
import aiohttp import aiohttp
from homeassistant.components.light import SUPPORT_BRIGHTNESS, Light from homeassistant.components.light import SUPPORT_BRIGHTNESS, LightEntity
from homeassistant.const import CONF_HOST from homeassistant.const import CONF_HOST
from homeassistant.exceptions import PlatformNotReady from homeassistant.exceptions import PlatformNotReady
@ -26,7 +26,7 @@ async def async_setup_platform(hass, config, add_entities, discovery_info=None):
add_entities([SisyphusLight(table_holder.name, table)], update_before_add=True) add_entities([SisyphusLight(table_holder.name, table)], update_before_add=True)
class SisyphusLight(Light): class SisyphusLight(LightEntity):
"""Representation of a Sisyphus table as a light.""" """Representation of a Sisyphus table as a light."""
def __init__(self, name, table): def __init__(self, name, table):

View File

@ -6,7 +6,7 @@ from homeassistant.components.light import (
ATTR_HS_COLOR, ATTR_HS_COLOR,
SUPPORT_BRIGHTNESS, SUPPORT_BRIGHTNESS,
SUPPORT_COLOR, SUPPORT_COLOR,
Light, LightEntity,
) )
import homeassistant.util.color as color_util import homeassistant.util.color as color_util
@ -36,7 +36,7 @@ def _to_hass_level(level):
return int((level * 255) / 100) return int((level * 255) / 100)
class SkybellLight(SkybellDevice, Light): class SkybellLight(SkybellDevice, LightEntity):
"""A binary sensor implementation for Skybell devices.""" """A binary sensor implementation for Skybell devices."""
def __init__(self, device): def __init__(self, device):

View File

@ -5,7 +5,7 @@ import logging
import pysmarthab import pysmarthab
from requests.exceptions import Timeout from requests.exceptions import Timeout
from homeassistant.components.light import Light from homeassistant.components.light import LightEntity
from . import DATA_HUB, DOMAIN from . import DATA_HUB, DOMAIN
@ -29,7 +29,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities(entities, True) add_entities(entities, True)
class SmartHabLight(Light): class SmartHabLight(LightEntity):
"""Representation of a SmartHab Light.""" """Representation of a SmartHab Light."""
def __init__(self, light): def __init__(self, light):

View File

@ -13,7 +13,7 @@ from homeassistant.components.light import (
SUPPORT_COLOR, SUPPORT_COLOR,
SUPPORT_COLOR_TEMP, SUPPORT_COLOR_TEMP,
SUPPORT_TRANSITION, SUPPORT_TRANSITION,
Light, LightEntity,
) )
import homeassistant.util.color as color_util import homeassistant.util.color as color_util
@ -61,7 +61,7 @@ def convert_scale(value, value_scale, target_scale, round_digits=4):
return round(value * target_scale / value_scale, round_digits) return round(value * target_scale / value_scale, round_digits)
class SmartThingsLight(SmartThingsEntity, Light): class SmartThingsLight(SmartThingsEntity, LightEntity):
"""Define a SmartThings Light.""" """Define a SmartThings Light."""
def __init__(self, device): def __init__(self, device):

View File

@ -5,7 +5,7 @@ from typing import Callable, Optional, Sequence, cast
import voluptuous as vol import voluptuous as vol
from homeassistant.components import switch from homeassistant.components import switch
from homeassistant.components.light import PLATFORM_SCHEMA, Light from homeassistant.components.light import PLATFORM_SCHEMA, LightEntity
from homeassistant.const import ( from homeassistant.const import (
ATTR_ENTITY_ID, ATTR_ENTITY_ID,
CONF_ENTITY_ID, CONF_ENTITY_ID,
@ -49,7 +49,7 @@ async def async_setup_platform(
) )
class LightSwitch(Light): class LightSwitch(LightEntity):
"""Represents a Switch as a Light.""" """Represents a Switch as a Light."""
def __init__(self, name: str, switch_entity_id: str) -> None: def __init__(self, name: str, switch_entity_id: str) -> None:

View File

@ -2,7 +2,11 @@
import logging import logging
from homeassistant.components import light, tellduslive from homeassistant.components import light, tellduslive
from homeassistant.components.light import ATTR_BRIGHTNESS, SUPPORT_BRIGHTNESS, Light from homeassistant.components.light import (
ATTR_BRIGHTNESS,
SUPPORT_BRIGHTNESS,
LightEntity,
)
from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.dispatcher import async_dispatcher_connect
from .entry import TelldusLiveEntity from .entry import TelldusLiveEntity
@ -25,7 +29,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
) )
class TelldusLiveLight(TelldusLiveEntity, Light): class TelldusLiveLight(TelldusLiveEntity, LightEntity):
"""Representation of a Tellstick Net light.""" """Representation of a Tellstick Net light."""
def __init__(self, client, device_id): def __init__(self, client, device_id):

View File

@ -1,5 +1,9 @@
"""Support for Tellstick lights.""" """Support for Tellstick lights."""
from homeassistant.components.light import ATTR_BRIGHTNESS, SUPPORT_BRIGHTNESS, Light from homeassistant.components.light import (
ATTR_BRIGHTNESS,
SUPPORT_BRIGHTNESS,
LightEntity,
)
from . import ( from . import (
ATTR_DISCOVER_CONFIG, ATTR_DISCOVER_CONFIG,
@ -30,7 +34,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
) )
class TellstickLight(TellstickDevice, Light): class TellstickLight(TellstickDevice, LightEntity):
"""Representation of a Tellstick light.""" """Representation of a Tellstick light."""
def __init__(self, tellcore_device, signal_repetitions): def __init__(self, tellcore_device, signal_repetitions):

View File

@ -13,7 +13,7 @@ from homeassistant.components.light import (
SUPPORT_COLOR, SUPPORT_COLOR,
SUPPORT_COLOR_TEMP, SUPPORT_COLOR_TEMP,
SUPPORT_WHITE_VALUE, SUPPORT_WHITE_VALUE,
Light, LightEntity,
) )
from homeassistant.const import ( from homeassistant.const import (
CONF_ENTITY_ID, CONF_ENTITY_ID,
@ -146,7 +146,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
async_add_entities(lights) async_add_entities(lights)
class LightTemplate(Light): class LightTemplate(LightEntity):
"""Representation of a templated Light, including dimmable.""" """Representation of a templated Light, including dimmable."""
def __init__( def __init__(

View File

@ -10,7 +10,7 @@ from homeassistant.components.light import (
PLATFORM_SCHEMA, PLATFORM_SCHEMA,
SUPPORT_BRIGHTNESS, SUPPORT_BRIGHTNESS,
SUPPORT_COLOR, SUPPORT_COLOR,
Light, LightEntity,
) )
from homeassistant.const import CONF_DEVICES, CONF_NAME, CONF_PASSWORD from homeassistant.const import CONF_DEVICES, CONF_NAME, CONF_PASSWORD
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
@ -44,7 +44,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities(lights) add_entities(lights)
class TikteckLight(Light): class TikteckLight(LightEntity):
"""Representation of a Tikteck light.""" """Representation of a Tikteck light."""
def __init__(self, device): def __init__(self, device):

View File

@ -13,7 +13,7 @@ from homeassistant.components.light import (
SUPPORT_BRIGHTNESS, SUPPORT_BRIGHTNESS,
SUPPORT_COLOR, SUPPORT_COLOR,
SUPPORT_COLOR_TEMP, SUPPORT_COLOR_TEMP,
Light, LightEntity,
) )
from homeassistant.exceptions import HomeAssistantError from homeassistant.exceptions import HomeAssistantError
import homeassistant.helpers.device_registry as dr import homeassistant.helpers.device_registry as dr
@ -120,7 +120,7 @@ class LightFeatures(NamedTuple):
has_emeter: bool has_emeter: bool
class TPLinkSmartBulb(Light): class TPLinkSmartBulb(LightEntity):
"""Representation of a TPLink Smart Bulb.""" """Representation of a TPLink Smart Bulb."""
def __init__(self, smartbulb: SmartBulb) -> None: def __init__(self, smartbulb: SmartBulb) -> None:

View File

@ -9,7 +9,7 @@ from homeassistant.components.light import (
SUPPORT_BRIGHTNESS, SUPPORT_BRIGHTNESS,
SUPPORT_COLOR, SUPPORT_COLOR,
SUPPORT_COLOR_TEMP, SUPPORT_COLOR_TEMP,
Light, LightEntity,
) )
import homeassistant.util.color as color_util import homeassistant.util.color as color_util
@ -49,7 +49,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
async_add_entities(TradfriGroup(group, api, gateway_id) for group in groups) async_add_entities(TradfriGroup(group, api, gateway_id) for group in groups)
class TradfriGroup(TradfriBaseClass, Light): class TradfriGroup(TradfriBaseClass, LightEntity):
"""The platform class for light groups required by hass.""" """The platform class for light groups required by hass."""
def __init__(self, device, api, gateway_id): def __init__(self, device, api, gateway_id):
@ -106,7 +106,7 @@ class TradfriGroup(TradfriBaseClass, Light):
await self._api(self._device.set_state(1)) await self._api(self._device.set_state(1))
class TradfriLight(TradfriBaseDevice, Light): class TradfriLight(TradfriBaseDevice, LightEntity):
"""The platform class required by Home Assistant.""" """The platform class required by Home Assistant."""
def __init__(self, device, api, gateway_id): def __init__(self, device, api, gateway_id):

View File

@ -7,7 +7,7 @@ from homeassistant.components.light import (
SUPPORT_BRIGHTNESS, SUPPORT_BRIGHTNESS,
SUPPORT_COLOR, SUPPORT_COLOR,
SUPPORT_COLOR_TEMP, SUPPORT_COLOR_TEMP,
Light, LightEntity,
) )
from homeassistant.util import color as colorutil from homeassistant.util import color as colorutil
@ -31,7 +31,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities(devices) add_entities(devices)
class TuyaLight(TuyaDevice, Light): class TuyaLight(TuyaDevice, LightEntity):
"""Tuya light device.""" """Tuya light device."""
def __init__(self, tuya): def __init__(self, tuya):

View File

@ -8,7 +8,7 @@ from homeassistant.components.light import (
ATTR_BRIGHTNESS, ATTR_BRIGHTNESS,
PLATFORM_SCHEMA, PLATFORM_SCHEMA,
SUPPORT_BRIGHTNESS, SUPPORT_BRIGHTNESS,
Light, LightEntity,
) )
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_PORT, CONF_USERNAME from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_PORT, CONF_USERNAME
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
@ -46,7 +46,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities(UnifiLedLight(light, api) for light in api.getlights()) add_entities(UnifiLedLight(light, api) for light in api.getlights())
class UnifiLedLight(Light): class UnifiLedLight(LightEntity):
"""Representation of an unifiled Light.""" """Representation of an unifiled Light."""
def __init__(self, light, api): def __init__(self, light, api):

View File

@ -12,7 +12,7 @@ from homeassistant.components.light import (
SUPPORT_BRIGHTNESS, SUPPORT_BRIGHTNESS,
SUPPORT_FLASH, SUPPORT_FLASH,
SUPPORT_TRANSITION, SUPPORT_TRANSITION,
Light, LightEntity,
) )
from . import VelbusEntity from . import VelbusEntity
@ -32,7 +32,7 @@ async def async_setup_entry(hass, entry, async_add_entities):
async_add_entities(entities) async_add_entities(entities)
class VelbusLight(VelbusEntity, Light): class VelbusLight(VelbusEntity, LightEntity):
"""Representation of a Velbus light.""" """Representation of a Velbus light."""
@property @property

View File

@ -9,7 +9,7 @@ from homeassistant.components.light import (
ENTITY_ID_FORMAT, ENTITY_ID_FORMAT,
SUPPORT_BRIGHTNESS, SUPPORT_BRIGHTNESS,
SUPPORT_COLOR, SUPPORT_COLOR,
Light, LightEntity,
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
@ -37,7 +37,7 @@ async def async_setup_entry(
) )
class VeraLight(VeraDevice, Light): class VeraLight(VeraDevice, LightEntity):
"""Representation of a Vera Light, including dimmable.""" """Representation of a Vera Light, including dimmable."""
def __init__(self, vera_device, controller): def __init__(self, vera_device, controller):

View File

@ -15,7 +15,7 @@ from homeassistant.components.light import (
SUPPORT_COLOR, SUPPORT_COLOR,
SUPPORT_COLOR_TEMP, SUPPORT_COLOR_TEMP,
SUPPORT_TRANSITION, SUPPORT_TRANSITION,
Light, LightEntity,
) )
from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.dispatcher import async_dispatcher_connect
import homeassistant.util.color as color_util import homeassistant.util.color as color_util
@ -76,7 +76,7 @@ def setup_bridge(hass, bridge, async_add_entities):
update_lights() update_lights()
class WemoLight(Light): class WemoLight(LightEntity):
"""Representation of a WeMo light.""" """Representation of a WeMo light."""
def __init__(self, device, update_lights): def __init__(self, device, update_lights):
@ -209,7 +209,7 @@ class WemoLight(Light):
await self.hass.async_add_executor_job(self._update, force_update) await self.hass.async_add_executor_job(self._update, force_update)
class WemoDimmer(Light): class WemoDimmer(LightEntity):
"""Representation of a WeMo dimmer.""" """Representation of a WeMo dimmer."""
def __init__(self, device): def __init__(self, device):

View File

@ -8,7 +8,7 @@ from homeassistant.components.light import (
SUPPORT_BRIGHTNESS, SUPPORT_BRIGHTNESS,
SUPPORT_COLOR, SUPPORT_COLOR,
SUPPORT_COLOR_TEMP, SUPPORT_COLOR_TEMP,
Light, LightEntity,
) )
from homeassistant.util import color as color_util from homeassistant.util import color as color_util
from homeassistant.util.color import ( from homeassistant.util.color import (
@ -31,7 +31,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities([WinkLight(light, hass)]) add_entities([WinkLight(light, hass)])
class WinkLight(WinkDevice, Light): class WinkLight(WinkDevice, LightEntity):
"""Representation of a Wink light.""" """Representation of a Wink light."""
async def async_added_to_hass(self): async def async_added_to_hass(self):

View File

@ -17,7 +17,7 @@ from homeassistant.components.light import (
SUPPORT_EFFECT, SUPPORT_EFFECT,
SUPPORT_TRANSITION, SUPPORT_TRANSITION,
SUPPORT_WHITE_VALUE, SUPPORT_WHITE_VALUE,
Light, LightEntity,
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.helpers import config_validation as cv, entity_platform from homeassistant.helpers import config_validation as cv, entity_platform
@ -78,7 +78,7 @@ async def async_setup_entry(
async_add_entities(lights, True) async_add_entities(lights, True)
class WLEDLight(Light, WLEDDeviceEntity): class WLEDLight(LightEntity, WLEDDeviceEntity):
"""Defines a WLED light.""" """Defines a WLED light."""
def __init__( def __init__(

View File

@ -8,7 +8,7 @@ from homeassistant.components.light import (
ATTR_BRIGHTNESS, ATTR_BRIGHTNESS,
PLATFORM_SCHEMA, PLATFORM_SCHEMA,
SUPPORT_BRIGHTNESS, SUPPORT_BRIGHTNESS,
Light, LightEntity,
) )
from homeassistant.const import CONF_DEVICES, CONF_ID, CONF_NAME from homeassistant.const import CONF_DEVICES, CONF_ID, CONF_NAME
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
@ -50,7 +50,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities(X10Light(light, is_cm11a) for light in config[CONF_DEVICES]) add_entities(X10Light(light, is_cm11a) for light in config[CONF_DEVICES])
class X10Light(Light): class X10Light(LightEntity):
"""Representation of an X10 Light.""" """Representation of an X10 Light."""
def __init__(self, light, is_cm11a): def __init__(self, light, is_cm11a):

View File

@ -8,7 +8,7 @@ from homeassistant.components.light import (
ATTR_HS_COLOR, ATTR_HS_COLOR,
SUPPORT_BRIGHTNESS, SUPPORT_BRIGHTNESS,
SUPPORT_COLOR, SUPPORT_COLOR,
Light, LightEntity,
) )
import homeassistant.util.color as color_util import homeassistant.util.color as color_util
@ -28,7 +28,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities(devices) add_entities(devices)
class XiaomiGatewayLight(XiaomiDevice, Light): class XiaomiGatewayLight(XiaomiDevice, LightEntity):
"""Representation of a XiaomiGatewayLight.""" """Representation of a XiaomiGatewayLight."""
def __init__(self, device, name, xiaomi_hub): def __init__(self, device, name, xiaomi_hub):

View File

@ -24,7 +24,7 @@ from homeassistant.components.light import (
SUPPORT_BRIGHTNESS, SUPPORT_BRIGHTNESS,
SUPPORT_COLOR, SUPPORT_COLOR,
SUPPORT_COLOR_TEMP, SUPPORT_COLOR_TEMP,
Light, LightEntity,
) )
from homeassistant.const import ATTR_ENTITY_ID, CONF_HOST, CONF_NAME, CONF_TOKEN from homeassistant.const import ATTR_ENTITY_ID, CONF_HOST, CONF_NAME, CONF_TOKEN
from homeassistant.exceptions import PlatformNotReady from homeassistant.exceptions import PlatformNotReady
@ -236,7 +236,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
) )
class XiaomiPhilipsAbstractLight(Light): class XiaomiPhilipsAbstractLight(LightEntity):
"""Representation of a Abstract Xiaomi Philips Light.""" """Representation of a Abstract Xiaomi Philips Light."""
def __init__(self, name, light, model, unique_id): def __init__(self, name, light, model, unique_id):

View File

@ -29,7 +29,7 @@ from homeassistant.components.light import (
SUPPORT_EFFECT, SUPPORT_EFFECT,
SUPPORT_FLASH, SUPPORT_FLASH,
SUPPORT_TRANSITION, SUPPORT_TRANSITION,
Light, LightEntity,
) )
from homeassistant.const import ATTR_ENTITY_ID, ATTR_MODE, CONF_HOST, CONF_NAME from homeassistant.const import ATTR_ENTITY_ID, ATTR_MODE, CONF_HOST, CONF_NAME
from homeassistant.core import callback from homeassistant.core import callback
@ -426,7 +426,7 @@ def setup_services(hass):
) )
class YeelightGenericLight(Light): class YeelightGenericLight(LightEntity):
"""Representation of a Yeelight generic light.""" """Representation of a Yeelight generic light."""
def __init__(self, device, custom_effects=None): def __init__(self, device, custom_effects=None):

View File

@ -10,7 +10,7 @@ from homeassistant.components.light import (
PLATFORM_SCHEMA, PLATFORM_SCHEMA,
SUPPORT_BRIGHTNESS, SUPPORT_BRIGHTNESS,
SUPPORT_COLOR, SUPPORT_COLOR,
Light, LightEntity,
) )
from homeassistant.const import CONF_HOST from homeassistant.const import CONF_HOST
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
@ -36,7 +36,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities(SunflowerBulb(light) for light in hub.get_lights()) add_entities(SunflowerBulb(light) for light in hub.get_lights())
class SunflowerBulb(Light): class SunflowerBulb(LightEntity):
"""Representation of a Yeelight Sunflower Light.""" """Representation of a Yeelight Sunflower Light."""
def __init__(self, light): def __init__(self, light):

View File

@ -12,7 +12,7 @@ from homeassistant.components.light import (
SUPPORT_BRIGHTNESS, SUPPORT_BRIGHTNESS,
SUPPORT_COLOR, SUPPORT_COLOR,
SUPPORT_WHITE_VALUE, SUPPORT_WHITE_VALUE,
Light, LightEntity,
) )
from homeassistant.const import CONF_DEVICES, CONF_NAME from homeassistant.const import CONF_DEVICES, CONF_NAME
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
@ -43,7 +43,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities(lights, True) add_entities(lights, True)
class ZenggeLight(Light): class ZenggeLight(LightEntity):
"""Representation of a Zengge light.""" """Representation of a Zengge light."""
def __init__(self, device): def __init__(self, device):

View File

@ -97,7 +97,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
hass.data[DATA_ZHA][DATA_ZHA_DISPATCHERS].append(unsub) hass.data[DATA_ZHA][DATA_ZHA_DISPATCHERS].append(unsub)
class BaseLight(LogMixin, light.Light): class BaseLight(LogMixin, light.LightEntity):
"""Operations common to all light entities.""" """Operations common to all light entities."""
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):

View File

@ -1,7 +1,7 @@
"""Support for Zigbee lights.""" """Support for Zigbee lights."""
import voluptuous as vol import voluptuous as vol
from homeassistant.components.light import Light from homeassistant.components.light import LightEntity
from . import DOMAIN, PLATFORM_SCHEMA, ZigBeeDigitalOut, ZigBeeDigitalOutConfig from . import DOMAIN, PLATFORM_SCHEMA, ZigBeeDigitalOut, ZigBeeDigitalOutConfig
@ -21,5 +21,5 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities([ZigBeeLight(ZigBeeDigitalOutConfig(config), zigbee_device)]) add_entities([ZigBeeLight(ZigBeeDigitalOutConfig(config), zigbee_device)])
class ZigBeeLight(ZigBeeDigitalOut, Light): class ZigBeeLight(ZigBeeDigitalOut, LightEntity):
"""Use ZigBeeDigitalOut as light.""" """Use ZigBeeDigitalOut as light."""

View File

@ -14,7 +14,7 @@ from homeassistant.components.light import (
SUPPORT_COLOR_TEMP, SUPPORT_COLOR_TEMP,
SUPPORT_TRANSITION, SUPPORT_TRANSITION,
SUPPORT_WHITE_VALUE, SUPPORT_WHITE_VALUE,
Light, LightEntity,
) )
from homeassistant.const import STATE_OFF, STATE_ON from homeassistant.const import STATE_OFF, STATE_ON
from homeassistant.core import callback from homeassistant.core import callback
@ -118,7 +118,7 @@ def ct_to_hs(temp):
return [int(val) for val in colorlist] return [int(val) for val in colorlist]
class ZwaveDimmer(ZWaveDeviceEntity, Light): class ZwaveDimmer(ZWaveDeviceEntity, LightEntity):
"""Representation of a Z-Wave dimmer.""" """Representation of a Z-Wave dimmer."""
def __init__(self, values, refresh, delay): def __init__(self, values, refresh, delay):

View File

@ -548,3 +548,13 @@ async def test_light_brightness_pct_conversion(hass):
_, data = entity.last_call("turn_on") _, data = entity.last_call("turn_on")
assert data["brightness"] == 255, data assert data["brightness"] == 255, data
def test_deprecated_base_class(caplog):
"""Test deprecated base class."""
class CustomLight(light.Light):
pass
CustomLight()
assert "Light is deprecated, modify CustomLight" in caplog.text

View File

@ -3,7 +3,7 @@ Provide a mock light platform.
Call init before using it in your tests to ensure clean test data. Call init before using it in your tests to ensure clean test data.
""" """
from homeassistant.components.light import Light from homeassistant.components.light import LightEntity
from homeassistant.const import STATE_OFF, STATE_ON from homeassistant.const import STATE_OFF, STATE_ON
from tests.common import MockToggleEntity from tests.common import MockToggleEntity
@ -33,7 +33,7 @@ async def async_setup_platform(
async_add_entities_callback(ENTITIES) async_add_entities_callback(ENTITIES)
class MockLight(MockToggleEntity, Light): class MockLight(MockToggleEntity, LightEntity):
"""Mock light class.""" """Mock light class."""
brightness = None brightness = None