Add switch platform

This commit is contained in:
ludeeus
2019-03-10 15:55:33 +01:00
parent 6ab2f89a30
commit 56d61a8c1f
6 changed files with 102 additions and 13 deletions

View File

@ -1,4 +1,4 @@
"""Binary ensor platform for blueprint."""
"""Binary sensor platform for blueprint."""
from homeassistant.components.binary_sensor import BinarySensorDevice
from . import update_data
from .const import BINARY_SENSOR_DEVICE_CLASS, DOMAIN_DATA
@ -7,12 +7,12 @@ from .const import BINARY_SENSOR_DEVICE_CLASS, DOMAIN_DATA
async def async_setup_platform(
hass, config, async_add_entities, discovery_info=None
): # pylint: disable=unused-argument
"""Setup sensor platform."""
"""Setup binary_sensor platform."""
async_add_entities([BlueprintBinarySensor(hass, discovery_info)], True)
class BlueprintBinarySensor(BinarySensorDevice):
"""blueprint Sensor class."""
"""blueprint binary_sensor class."""
def __init__(self, hass, config):
self.hass = hass
@ -21,7 +21,7 @@ class BlueprintBinarySensor(BinarySensorDevice):
self._name = config["name"]
async def async_update(self):
"""Update the sensor."""
"""Update the binary_sensor."""
# Send update "signal" to the component
await update_data(self.hass)
@ -40,17 +40,17 @@ class BlueprintBinarySensor(BinarySensorDevice):
@property
def name(self):
"""Return the name of the sensor."""
"""Return the name of the binary_sensor."""
return self._name
@property
def device_class(self):
"""Return the class of this sensor."""
"""Return the class of this binary_sensor."""
return BINARY_SENSOR_DEVICE_CLASS
@property
def is_on(self):
"""Return true if the binary sensor is on."""
"""Return true if the binary_sensor is on."""
return self._status
@property