Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions homeassistant/components/sensor/velbus.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
"""
Velbus sensors.

For more details about this platform, please refer to the documentation
https://home-assistant.io/components/velbus/

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Url doesn't have correct format. Look at other platforms for the correct format.

"""
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):

@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._cur

@property
def unit_of_measurement(self):
"""Return the unit this state is expressed in."""
return TEMP_CELSIUS
7 changes: 5 additions & 2 deletions homeassistant/components/velbus.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from homeassistant.helpers.discovery import load_platform
from homeassistant.helpers.entity import Entity

REQUIREMENTS = ['python-velbus==2.0.17']
REQUIREMENTS = ['python-velbus==2.0.19']

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -47,7 +47,8 @@ def callback():
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):
Expand All @@ -61,6 +62,8 @@ def callback():
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)

Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1134,7 +1134,7 @@ python-telegram-bot==10.1.0
python-twitch==1.3.0

# homeassistant.components.velbus
python-velbus==2.0.17
python-velbus==2.0.19

# homeassistant.components.media_player.vlc
python-vlc==1.1.2
Expand Down