mirror of
https://github.com/home-assistant/core
synced 2024-09-06 10:29:55 +02:00
![Paulus Schoutsen](/assets/img/avatar_default.png)
* Use relative imports inside integrations * Lint * Fix automation tests * Fix scene imports
34 lines
927 B
Python
34 lines
927 B
Python
"""Support for VOC."""
|
|
import logging
|
|
|
|
from homeassistant.components.binary_sensor import (
|
|
DEVICE_CLASSES, BinarySensorDevice)
|
|
|
|
from . import DATA_KEY, VolvoEntity
|
|
|
|
_LOGGER = logging.getLogger(__name__)
|
|
|
|
|
|
async def async_setup_platform(
|
|
hass, config, async_add_entities, discovery_info=None):
|
|
"""Set up the Volvo sensors."""
|
|
if discovery_info is None:
|
|
return
|
|
async_add_entities([VolvoSensor(hass.data[DATA_KEY], *discovery_info)])
|
|
|
|
|
|
class VolvoSensor(VolvoEntity, BinarySensorDevice):
|
|
"""Representation of a Volvo sensor."""
|
|
|
|
@property
|
|
def is_on(self):
|
|
"""Return True if the binary sensor is on."""
|
|
return self.instrument.is_on
|
|
|
|
@property
|
|
def device_class(self):
|
|
"""Return the class of this sensor, from DEVICE_CLASSES."""
|
|
if self.instrument.device_class in DEVICE_CLASSES:
|
|
return self.instrument.device_class
|
|
return None
|