2019-02-13 20:21:14 +00:00
|
|
|
"""Support for Volvo On Call sensors."""
|
2017-02-19 01:09:25 +00:00
|
|
|
import logging
|
|
|
|
|
2018-11-30 18:07:42 +00:00
|
|
|
from homeassistant.components.volvooncall import VolvoEntity, DATA_KEY
|
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-05-02 16:18:47 +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):
|
|
|
|
"""Representation of a Volvo sensor."""
|
|
|
|
|
|
|
|
@property
|
|
|
|
def state(self):
|
2018-11-30 18:07:42 +00:00
|
|
|
"""Return the state."""
|
|
|
|
return self.instrument.state
|
2017-02-19 01:09:25 +00:00
|
|
|
|
|
|
|
@property
|
|
|
|
def unit_of_measurement(self):
|
|
|
|
"""Return the unit of measurement."""
|
2018-11-30 18:07:42 +00:00
|
|
|
return self.instrument.unit
|