Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions homeassistant/components/abode/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from homeassistant.components.binary_sensor import (
DEVICE_CLASS_WINDOW,
BinarySensorDevice,
BinarySensorEntity,
)

from . import AbodeDevice
Expand All @@ -30,7 +30,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
async_add_entities(entities)


class AbodeBinarySensor(AbodeDevice, BinarySensorDevice):
class AbodeBinarySensor(AbodeDevice, BinarySensorEntity):
"""A binary sensor implementation for Abode device."""

@property
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/ads/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from homeassistant.components.binary_sensor import (
DEVICE_CLASSES_SCHEMA,
PLATFORM_SCHEMA,
BinarySensorDevice,
BinarySensorEntity,
)
from homeassistant.const import CONF_DEVICE_CLASS, CONF_NAME
import homeassistant.helpers.config_validation as cv
Expand Down Expand Up @@ -37,7 +37,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities([ads_sensor])


class AdsBinarySensor(AdsEntity, BinarySensorDevice):
class AdsBinarySensor(AdsEntity, BinarySensorEntity):
"""Representation of ADS binary sensors."""

def __init__(self, ads_hub, name, ads_var, device_class):
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/alarmdecoder/binary_sensor.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Support for AlarmDecoder zone states- represented as binary sensors."""
import logging

from homeassistant.components.binary_sensor import BinarySensorDevice
from homeassistant.components.binary_sensor import BinarySensorEntity

from . import (
CONF_RELAY_ADDR,
Expand Down Expand Up @@ -53,7 +53,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
return True


class AlarmDecoderBinarySensor(BinarySensorDevice):
class AlarmDecoderBinarySensor(BinarySensorEntity):
"""Representation of an AlarmDecoder binary sensor."""

def __init__(
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/ambient_station/binary_sensor.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Support for Ambient Weather Station binary sensors."""
import logging

from homeassistant.components.binary_sensor import BinarySensorDevice
from homeassistant.components.binary_sensor import BinarySensorEntity
from homeassistant.const import ATTR_NAME
from homeassistant.core import callback

Expand Down Expand Up @@ -54,7 +54,7 @@ async def async_setup_entry(hass, entry, async_add_entities):
async_add_entities(binary_sensor_list, True)


class AmbientWeatherBinarySensor(AmbientWeatherEntity, BinarySensorDevice):
class AmbientWeatherBinarySensor(AmbientWeatherEntity, BinarySensorEntity):
"""Define an Ambient binary sensor."""

@property
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/amcrest/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from homeassistant.components.binary_sensor import (
DEVICE_CLASS_CONNECTIVITY,
DEVICE_CLASS_MOTION,
BinarySensorDevice,
BinarySensorEntity,
)
from homeassistant.const import CONF_BINARY_SENSORS, CONF_NAME
from homeassistant.core import callback
Expand Down Expand Up @@ -63,7 +63,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
)


class AmcrestBinarySensor(BinarySensorDevice):
class AmcrestBinarySensor(BinarySensorEntity):
"""Binary sensor for Amcrest camera."""

def __init__(self, name, device, sensor_type):
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/android_ip_webcam/binary_sensor.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Support for Android IP Webcam binary sensors."""
from homeassistant.components.binary_sensor import BinarySensorDevice
from homeassistant.components.binary_sensor import BinarySensorEntity

from . import CONF_HOST, CONF_NAME, DATA_IP_WEBCAM, KEY_MAP, AndroidIPCamEntity

Expand All @@ -16,7 +16,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
async_add_entities([IPWebcamBinarySensor(name, host, ipcam, "motion_active")], True)


class IPWebcamBinarySensor(AndroidIPCamEntity, BinarySensorDevice):
class IPWebcamBinarySensor(AndroidIPCamEntity, BinarySensorEntity):
"""Representation of an IP Webcam binary sensor."""

def __init__(self, name, host, ipcam, sensor):
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/apcupsd/binary_sensor.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Support for tracking the online status of a UPS."""
import voluptuous as vol

from homeassistant.components.binary_sensor import PLATFORM_SCHEMA, BinarySensorDevice
from homeassistant.components.binary_sensor import PLATFORM_SCHEMA, BinarySensorEntity
from homeassistant.const import CONF_NAME
import homeassistant.helpers.config_validation as cv

Expand All @@ -20,7 +20,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities([OnlineStatus(config, apcups_data)], True)


class OnlineStatus(BinarySensorDevice):
class OnlineStatus(BinarySensorEntity):
"""Representation of an UPS online status."""

def __init__(self, config, data):
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/arest/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from homeassistant.components.binary_sensor import (
DEVICE_CLASSES_SCHEMA,
PLATFORM_SCHEMA,
BinarySensorDevice,
BinarySensorEntity,
)
from homeassistant.const import (
CONF_DEVICE_CLASS,
Expand Down Expand Up @@ -67,7 +67,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
)


class ArestBinarySensor(BinarySensorDevice):
class ArestBinarySensor(BinarySensorEntity):
"""Implement an aREST binary sensor for a pin."""

def __init__(self, arest, resource, name, device_class, pin):
Expand Down
6 changes: 3 additions & 3 deletions homeassistant/components/august/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
DEVICE_CLASS_DOOR,
DEVICE_CLASS_MOTION,
DEVICE_CLASS_OCCUPANCY,
BinarySensorDevice,
BinarySensorEntity,
)
from homeassistant.core import callback
from homeassistant.helpers.event import async_track_point_in_utc_time
Expand Down Expand Up @@ -108,7 +108,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
async_add_entities(devices, True)


class AugustDoorBinarySensor(AugustEntityMixin, BinarySensorDevice):
class AugustDoorBinarySensor(AugustEntityMixin, BinarySensorEntity):
"""Representation of an August Door binary sensor."""

def __init__(self, data, sensor_type, device):
Expand Down Expand Up @@ -155,7 +155,7 @@ def unique_id(self) -> str:
return f"{self._device_id}_open"


class AugustDoorbellBinarySensor(AugustEntityMixin, BinarySensorDevice):
class AugustDoorbellBinarySensor(AugustEntityMixin, BinarySensorEntity):
"""Representation of an August binary sensor."""

def __init__(self, data, sensor_type, device):
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/aurora/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import requests
import voluptuous as vol

from homeassistant.components.binary_sensor import PLATFORM_SCHEMA, BinarySensorDevice
from homeassistant.components.binary_sensor import PLATFORM_SCHEMA, BinarySensorEntity
from homeassistant.const import ATTR_ATTRIBUTION, CONF_NAME
import homeassistant.helpers.config_validation as cv
from homeassistant.util import Throttle
Expand Down Expand Up @@ -54,7 +54,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities([AuroraSensor(aurora_data, name)], True)


class AuroraSensor(BinarySensorDevice):
class AuroraSensor(BinarySensorEntity):
"""Implementation of an aurora sensor."""

def __init__(self, aurora_data, name):
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/axis/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from axis.event_stream import CLASS_INPUT, CLASS_OUTPUT

from homeassistant.components.binary_sensor import BinarySensorDevice
from homeassistant.components.binary_sensor import BinarySensorEntity
from homeassistant.const import CONF_TRIGGER_TIME
from homeassistant.core import callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect
Expand Down Expand Up @@ -32,7 +32,7 @@ def async_add_sensor(event_id):
)


class AxisBinarySensor(AxisEventBase, BinarySensorDevice):
class AxisBinarySensor(AxisEventBase, BinarySensorEntity):
"""Representation of a binary Axis event."""

def __init__(self, event, device):
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/bayesian/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import voluptuous as vol

from homeassistant.components.binary_sensor import PLATFORM_SCHEMA, BinarySensorDevice
from homeassistant.components.binary_sensor import PLATFORM_SCHEMA, BinarySensorEntity
from homeassistant.const import (
CONF_ABOVE,
CONF_BELOW,
Expand Down Expand Up @@ -113,7 +113,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
)


class BayesianBinarySensor(BinarySensorDevice):
class BayesianBinarySensor(BinarySensorEntity):
"""Representation of a Bayesian sensor."""

def __init__(self, name, prior, observations, probability_threshold, device_class):
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/bbb_gpio/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import voluptuous as vol

from homeassistant.components import bbb_gpio
from homeassistant.components.binary_sensor import PLATFORM_SCHEMA, BinarySensorDevice
from homeassistant.components.binary_sensor import PLATFORM_SCHEMA, BinarySensorEntity
from homeassistant.const import CONF_NAME, DEVICE_DEFAULT_NAME
import homeassistant.helpers.config_validation as cv

Expand Down Expand Up @@ -44,7 +44,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities(binary_sensors)


class BBBGPIOBinarySensor(BinarySensorDevice):
class BBBGPIOBinarySensor(BinarySensorEntity):
"""Representation of a binary sensor that uses Beaglebone Black GPIO."""

def __init__(self, pin, params):
Expand Down
17 changes: 16 additions & 1 deletion homeassistant/components/binary_sensor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

# mypy: allow-untyped-defs, no-check-untyped-defs

_LOGGER = logging.getLogger(__name__)

DOMAIN = "binary_sensor"
SCAN_INTERVAL = timedelta(seconds=30)

Expand Down Expand Up @@ -142,7 +144,7 @@ async def async_unload_entry(hass, entry):
return await hass.data[DOMAIN].async_unload_entry(entry)


class BinarySensorDevice(Entity):
class BinarySensorEntity(Entity):
"""Represent a binary sensor."""

@property
Expand All @@ -159,3 +161,16 @@ def state(self):
def device_class(self):
"""Return the class of this device, from component DEVICE_CLASSES."""
return None


class BinarySensorDevice(BinarySensorEntity):
"""Represent a binary sensor (for backwards compatibility)."""

def __new__(cls, *args, **kwargs):
Comment thread
MartinHjelmare marked this conversation as resolved.
Outdated
"""Print deprecation warning."""
instance = BinarySensorEntity.__new__(cls)
_LOGGER.warning(
"BinarySensorDevice is deprecated, modify %s to extend BinarySensorEntity",
instance.__class__.__name__,
)
return instance
4 changes: 2 additions & 2 deletions homeassistant/components/blink/binary_sensor.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Support for Blink system camera control."""
from homeassistant.components.binary_sensor import BinarySensorDevice
from homeassistant.components.binary_sensor import BinarySensorEntity
from homeassistant.const import CONF_MONITORED_CONDITIONS

from . import BINARY_SENSORS, BLINK_DATA
Expand All @@ -18,7 +18,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities(devs, True)


class BlinkBinarySensor(BinarySensorDevice):
class BlinkBinarySensor(BinarySensorEntity):
"""Representation of a Blink binary sensor."""

def __init__(self, data, camera, sensor_type):
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/bloomsky/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import voluptuous as vol

from homeassistant.components.binary_sensor import PLATFORM_SCHEMA, BinarySensorDevice
from homeassistant.components.binary_sensor import PLATFORM_SCHEMA, BinarySensorEntity
from homeassistant.const import CONF_MONITORED_CONDITIONS
import homeassistant.helpers.config_validation as cv

Expand Down Expand Up @@ -33,7 +33,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities([BloomSkySensor(bloomsky, device, variable)], True)


class BloomSkySensor(BinarySensorDevice):
class BloomSkySensor(BinarySensorEntity):
"""Representation of a single binary sensor in a BloomSky device."""

def __init__(self, bs, device, sensor_name):
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/bmw_connected_drive/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from bimmer_connected.state import ChargingState, LockState

from homeassistant.components.binary_sensor import BinarySensorDevice
from homeassistant.components.binary_sensor import BinarySensorEntity
from homeassistant.const import ATTR_ATTRIBUTION, LENGTH_KILOMETERS

from . import DOMAIN as BMW_DOMAIN
Expand Down Expand Up @@ -54,7 +54,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities(devices, True)


class BMWConnectedDriveSensor(BinarySensorDevice):
class BMWConnectedDriveSensor(BinarySensorEntity):
"""Representation of a BMW vehicle binary sensor."""

def __init__(
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/cloud/binary_sensor.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Support for Home Assistant Cloud binary sensors."""
import asyncio

from homeassistant.components.binary_sensor import BinarySensorDevice
from homeassistant.components.binary_sensor import BinarySensorEntity
from homeassistant.helpers.dispatcher import async_dispatcher_connect

from .const import DISPATCHER_REMOTE_UPDATE, DOMAIN
Expand All @@ -18,7 +18,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
async_add_entities([CloudRemoteBinary(cloud)])


class CloudRemoteBinary(BinarySensorDevice):
class CloudRemoteBinary(BinarySensorEntity):
"""Representation of an Cloud Remote UI Connection binary sensor."""

def __init__(self, cloud):
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/command_line/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from homeassistant.components.binary_sensor import (
DEVICE_CLASSES_SCHEMA,
PLATFORM_SCHEMA,
BinarySensorDevice,
BinarySensorEntity,
)
from homeassistant.const import (
CONF_COMMAND,
Expand Down Expand Up @@ -68,7 +68,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
)


class CommandBinarySensor(BinarySensorDevice):
class CommandBinarySensor(BinarySensorEntity):
"""Representation of a command line binary sensor."""

def __init__(
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/concord232/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from homeassistant.components.binary_sensor import (
DEVICE_CLASSES,
PLATFORM_SCHEMA,
BinarySensorDevice,
BinarySensorEntity,
)
from homeassistant.const import CONF_HOST, CONF_PORT
import homeassistant.helpers.config_validation as cv
Expand Down Expand Up @@ -95,7 +95,7 @@ def get_opening_type(zone):
return "opening"


class Concord232ZoneSensor(BinarySensorDevice):
class Concord232ZoneSensor(BinarySensorEntity):
"""Representation of a Concord232 zone as a sensor."""

def __init__(self, hass, client, zone, zone_type):
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/danfoss_air/binary_sensor.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Support for the for Danfoss Air HRV binary sensors."""
from pydanfossair.commands import ReadCommand

from homeassistant.components.binary_sensor import BinarySensorDevice
from homeassistant.components.binary_sensor import BinarySensorEntity

from . import DOMAIN as DANFOSS_AIR_DOMAIN

Expand All @@ -23,7 +23,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities(dev, True)


class DanfossAirBinarySensor(BinarySensorDevice):
class DanfossAirBinarySensor(BinarySensorEntity):
"""Representation of a Danfoss Air binary sensor."""

def __init__(self, data, name, sensor_type, device_class):
Expand Down
Loading