Rename BinarySensorDevice to BinarySensorEntity (#34462)

* Rename BinarySensorDevice to BinarySensorEntity

* Tweak

* Move deprecation warning to __new__, add test

* Move deprecation warning back to __init__

* Move deprecation warning to __init_subclass
This commit is contained in:
Erik Montnemery 2020-04-23 21:57:07 +02:00 committed by GitHub
parent 0b64f49e3a
commit b022e08db9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
147 changed files with 371 additions and 352 deletions

View file

@ -3,7 +3,7 @@ import logging
import pywink
from homeassistant.components.binary_sensor import BinarySensorDevice
from homeassistant.components.binary_sensor import BinarySensorEntity
from . import DOMAIN, WinkDevice
@ -33,12 +33,12 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
_id = sensor.object_id() + sensor.name()
if _id not in hass.data[DOMAIN]["unique_ids"]:
if sensor.capability() in SENSOR_TYPES:
add_entities([WinkBinarySensorDevice(sensor, hass)])
add_entities([WinkBinarySensorEntity(sensor, hass)])
for key in pywink.get_keys():
_id = key.object_id() + key.name()
if _id not in hass.data[DOMAIN]["unique_ids"]:
add_entities([WinkBinarySensorDevice(key, hass)])
add_entities([WinkBinarySensorEntity(key, hass)])
for sensor in pywink.get_smoke_and_co_detectors():
_id = sensor.object_id() + sensor.name()
@ -68,19 +68,19 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
for door_bell_sensor in pywink.get_door_bells():
_id = door_bell_sensor.object_id() + door_bell_sensor.name()
if _id not in hass.data[DOMAIN]["unique_ids"]:
add_entities([WinkBinarySensorDevice(door_bell_sensor, hass)])
add_entities([WinkBinarySensorEntity(door_bell_sensor, hass)])
for camera_sensor in pywink.get_cameras():
_id = camera_sensor.object_id() + camera_sensor.name()
if _id not in hass.data[DOMAIN]["unique_ids"]:
try:
if camera_sensor.capability() in SENSOR_TYPES:
add_entities([WinkBinarySensorDevice(camera_sensor, hass)])
add_entities([WinkBinarySensorEntity(camera_sensor, hass)])
except AttributeError:
_LOGGER.info("Device isn't a sensor, skipping")
class WinkBinarySensorDevice(WinkDevice, BinarySensorDevice):
class WinkBinarySensorEntity(WinkDevice, BinarySensorEntity):
"""Representation of a Wink binary sensor."""
def __init__(self, wink, hass):
@ -115,7 +115,7 @@ class WinkBinarySensorDevice(WinkDevice, BinarySensorDevice):
return super().device_state_attributes
class WinkSmokeDetector(WinkBinarySensorDevice):
class WinkSmokeDetector(WinkBinarySensorEntity):
"""Representation of a Wink Smoke detector."""
@property
@ -126,7 +126,7 @@ class WinkSmokeDetector(WinkBinarySensorDevice):
return _attributes
class WinkHub(WinkBinarySensorDevice):
class WinkHub(WinkBinarySensorEntity):
"""Representation of a Wink Hub."""
@property
@ -146,7 +146,7 @@ class WinkHub(WinkBinarySensorDevice):
return _attributes
class WinkRemote(WinkBinarySensorDevice):
class WinkRemote(WinkBinarySensorEntity):
"""Representation of a Wink Lutron Connected bulb remote."""
@property
@ -165,7 +165,7 @@ class WinkRemote(WinkBinarySensorDevice):
return None
class WinkButton(WinkBinarySensorDevice):
class WinkButton(WinkBinarySensorEntity):
"""Representation of a Wink Relay button."""
@property
@ -177,7 +177,7 @@ class WinkButton(WinkBinarySensorDevice):
return _attributes
class WinkGang(WinkBinarySensorDevice):
class WinkGang(WinkBinarySensorEntity):
"""Representation of a Wink Relay gang."""
@property