2019-02-13 20:21:14 +00:00
|
|
|
"""Support for VOC."""
|
2017-02-19 01:09:25 +00:00
|
|
|
import logging
|
|
|
|
|
2018-11-30 18:07:42 +00:00
|
|
|
from homeassistant.components.binary_sensor import (
|
2019-03-21 05:56:46 +00:00
|
|
|
DEVICE_CLASSES, BinarySensorDevice)
|
|
|
|
|
|
|
|
from . import DATA_KEY, VolvoEntity
|
2017-02-19 01:09:25 +00:00
|
|
|
|
|
|
|
_LOGGER = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
2019-02-13 20:21:14 +00:00
|
|
|
async def async_setup_platform(
|
|
|
|
hass, config, async_add_entities, discovery_info=None):
|
2017-04-30 05:04:49 +00:00
|
|
|
"""Set up the Volvo sensors."""
|
2017-02-19 01:09:25 +00:00
|
|
|
if discovery_info is None:
|
|
|
|
return
|
2018-11-30 18:07:42 +00:00
|
|
|
async_add_entities([VolvoSensor(hass.data[DATA_KEY], *discovery_info)])
|
2017-02-19 01:09:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
class VolvoSensor(VolvoEntity, BinarySensorDevice):
|
|
|
|
"""Representation of a Volvo sensor."""
|
|
|
|
|
|
|
|
@property
|
|
|
|
def is_on(self):
|
|
|
|
"""Return True if the binary sensor is on."""
|
2018-11-30 18:07:42 +00:00
|
|
|
return self.instrument.is_on
|
2017-02-19 01:09:25 +00:00
|
|
|
|
|
|
|
@property
|
|
|
|
def device_class(self):
|
2017-07-29 23:46:27 +00:00
|
|
|
"""Return the class of this sensor, from DEVICE_CLASSES."""
|
2018-11-30 18:07:42 +00:00
|
|
|
if self.instrument.device_class in DEVICE_CLASSES:
|
|
|
|
return self.instrument.device_class
|
|
|
|
return None
|