Add temperature sensors to the velbus component (#16203)
* Added support for velbus temperature sensors * Bumped the required version * updated requirements_all.txt * Auto review comments fixed * Updated after comments * Updated after comments * Fix travis * Fix travis
This commit is contained in:
parent
4da719f43c
commit
5d7a2f92df
3 changed files with 54 additions and 3 deletions
48
homeassistant/components/sensor/velbus.py
Normal file
48
homeassistant/components/sensor/velbus.py
Normal file
|
@ -0,0 +1,48 @@
|
|||
"""
|
||||
Velbus sensors.
|
||||
|
||||
For more details about this platform, please refer to the documentation
|
||||
https://home-assistant.io/components/sensor.velbus/
|
||||
"""
|
||||
import logging
|
||||
|
||||
from homeassistant.const import (
|
||||
TEMP_CELSIUS, DEVICE_CLASS_TEMPERATURE)
|
||||
from homeassistant.components.velbus import (
|
||||
DOMAIN as VELBUS_DOMAIN, VelbusEntity)
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
DEPENDENCIES = ['velbus']
|
||||
|
||||
|
||||
async def async_setup_platform(hass, config, async_add_entities,
|
||||
discovery_info=None):
|
||||
"""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]
|
||||
sensors.append(VelbusTempSensor(module, channel))
|
||||
async_add_entities(sensors)
|
||||
|
||||
|
||||
class VelbusTempSensor(VelbusEntity):
|
||||
"""Representation of a temperature sensor."""
|
||||
|
||||
@property
|
||||
def device_class(self):
|
||||
"""Return the device class of the sensor."""
|
||||
return DEVICE_CLASS_TEMPERATURE
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
"""Return the state of the sensor."""
|
||||
return self._module.getCurTemp()
|
||||
|
||||
@property
|
||||
def unit_of_measurement(self):
|
||||
"""Return the unit this state is expressed in."""
|
||||
return TEMP_CELSIUS
|
|
@ -12,7 +12,7 @@ from homeassistant.const import EVENT_HOMEASSISTANT_STOP, CONF_PORT
|
|||
from homeassistant.helpers.discovery import load_platform
|
||||
from homeassistant.helpers.entity import Entity
|
||||
|
||||
REQUIREMENTS = ['python-velbus==2.0.18']
|
||||
REQUIREMENTS = ['python-velbus==2.0.19']
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@ -47,7 +47,8 @@ async def async_setup(hass, config):
|
|||
modules = controller.get_modules()
|
||||
discovery_info = {
|
||||
'switch': [],
|
||||
'binary_sensor': []
|
||||
'binary_sensor': [],
|
||||
'temp_sensor': []
|
||||
}
|
||||
for module in modules:
|
||||
for channel in range(1, module.number_of_channels() + 1):
|
||||
|
@ -61,6 +62,8 @@ async def async_setup(hass, config):
|
|||
discovery_info['switch'], config)
|
||||
load_platform(hass, 'binary_sensor', DOMAIN,
|
||||
discovery_info['binary_sensor'], config)
|
||||
load_platform(hass, 'sensor', DOMAIN,
|
||||
discovery_info['temp_sensor'], config)
|
||||
|
||||
controller.scan(callback)
|
||||
|
||||
|
|
|
@ -1139,7 +1139,7 @@ python-telegram-bot==10.1.0
|
|||
python-twitch==1.3.0
|
||||
|
||||
# homeassistant.components.velbus
|
||||
python-velbus==2.0.18
|
||||
python-velbus==2.0.19
|
||||
|
||||
# homeassistant.components.media_player.vlc
|
||||
python-vlc==1.1.2
|
||||
|
|
Loading…
Add table
Reference in a new issue