Enable velbus config entries (#25308)

* Initial work on config_flow

* Finish config flow

* Pylint checks, make sure the import only happens once

* Added support for unloading, small fixes

* Check in the hassfest output files

* Flake8 fixes

* pylint mistake after flake8 fixes

* Work on comments

* Abort the import if it is already imported

* More comments resolved

* Added testcases for velbus config flow

* Fix pylint and flake8

* Added connection test to the config flow

* More sugestions

* renamed the abort reason

* excluded all but the config_flow.py from the velbus component in coveragerc

* Rewrote testcases with a patched version of _test_connection

* Docstyle fixes

* Updated the velbus testcases

* just yield

* flake8 fixes
This commit is contained in:
Maikel Punie authored and Martin Hjelmare committed 2019-07-29 09:21:26 +02:00
1 parent 03052802a4
commit 1f9f201571
18 files changed
+407 -81

No files matched your search

@@ -3,22 +3,28 @@ import logging
from homeassistant.components.binary_sensor import BinarySensorDevice
from . import DOMAIN as VELBUS_DOMAIN, VelbusEntity
from .const import DOMAIN
from . import VelbusEntity
_LOGGER = logging.getLogger(__name__)
async def async_setup_platform(
hass, config, async_add_entities, discovery_info=None):
"""Set up Velbus binary sensors."""
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(VelbusBinarySensor(module, channel))
async_add_entities(sensors)
"""Old way."""
pass
async def async_setup_entry(hass, entry, async_add_entities):
"""Set up Velbus binary sensor based on config_entry."""
cntrl = hass.data[DOMAIN][entry.entry_id]['cntrl']
modules_data = hass.data[DOMAIN][entry.entry_id]['binary_sensor']
entities = []
for address, channel in modules_data:
module = cntrl.get_module(address)
entities.append(
VelbusBinarySensor(module, channel))
async_add_entities(entities)
class VelbusBinarySensor(VelbusEntity, BinarySensorDevice):