2019-02-13 20:21:14 +00:00
|
|
|
"""Support for Volvo On Call sensors."""
|
2021-03-22 18:47:44 +00:00
|
|
|
from homeassistant.components.sensor import SensorEntity
|
|
|
|
|
2019-03-21 05:56:46 +00:00
|
|
|
from . import DATA_KEY, VolvoEntity
|
2017-02-19 01:09:25 +00:00
|
|
|
|
|
|
|
|
2019-07-31 19:25:30 +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
|
|
|
|
|
|
|
|
2021-03-22 18:47:44 +00:00
|
|
|
class VolvoSensor(VolvoEntity, SensorEntity):
|
2017-02-19 01:09:25 +00:00
|
|
|
"""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
|