2019-02-13 20:21:14 +00:00
|
|
|
"""Support for Velbus sensors."""
|
2018-08-27 04:06:46 +00:00
|
|
|
import logging
|
|
|
|
|
2019-03-21 05:56:46 +00:00
|
|
|
from . import DOMAIN as VELBUS_DOMAIN, VelbusEntity
|
2018-08-27 04:06:46 +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):
|
2018-08-27 04:06:46 +00:00
|
|
|
"""Set up the Velbus temp sensor platform."""
|
|
|
|
if discovery_info is None:
|
|
|
|
return
|
|
|
|
sensors = []
|
|
|
|
for sensor in discovery_info:
|
|
|
|
module = hass.data[VELBUS_DOMAIN].get_module(sensor[0])
|
|
|
|
channel = sensor[1]
|
2018-09-18 13:51:22 +00:00
|
|
|
sensors.append(VelbusSensor(module, channel))
|
2018-08-27 04:06:46 +00:00
|
|
|
async_add_entities(sensors)
|
|
|
|
|
|
|
|
|
2018-09-18 13:51:22 +00:00
|
|
|
class VelbusSensor(VelbusEntity):
|
|
|
|
"""Representation of a sensor."""
|
2018-08-27 04:06:46 +00:00
|
|
|
|
|
|
|
@property
|
|
|
|
def device_class(self):
|
|
|
|
"""Return the device class of the sensor."""
|
2018-09-18 13:51:22 +00:00
|
|
|
return self._module.get_class(self._channel)
|
2018-08-27 04:06:46 +00:00
|
|
|
|
|
|
|
@property
|
|
|
|
def state(self):
|
|
|
|
"""Return the state of the sensor."""
|
2018-09-18 13:51:22 +00:00
|
|
|
return self._module.get_state(self._channel)
|
2018-08-27 04:06:46 +00:00
|
|
|
|
|
|
|
@property
|
|
|
|
def unit_of_measurement(self):
|
|
|
|
"""Return the unit this state is expressed in."""
|
2018-09-18 13:51:22 +00:00
|
|
|
return self._module.get_unit(self._channel)
|