Switch velbus from python-velbus to velbusaio (#54032)
* initial commit * use new release * Update for sensors * big update * pylint fixes, bump dependancy to 2021.8.2 * New version to try to fix the tests * Fix a lot of errors, bump version * more work * Bump version * Adde dimmer support * Make sure the counters are useable in the energy dashboard * bump version * Fix testcases * Update after review * Bump version to be able to have some decent exception catches, add the temperature device class * Readd the import of the platform from config file, but add a deprecation warning * More comments updated * Fix lefover index * Fix unique id to be backwards compatible * Fix small bug in covers * Fix testcases * Changes for theenery dashboard * Fixed services * Fix memo text * Make the interface for a service the port string instead of the device selector * Fix set_memo_text * added an async scan task, more comments * Accidently disabled some paltforms * More comments, bump version * Bump version, add extra attributes, enable mypy * Removed new features * More comments * Bump version * Update homeassistant/components/velbus/__init__.py Co-authored-by: brefra <frank_van_breugel@hotmail.com> * Readd the import step Co-authored-by: brefra <frank_van_breugel@hotmail.com>
This commit is contained in:
parent
1f997fcd58
commit
7472fb2049
14 changed files with 252 additions and 220 deletions
|
@ -1,7 +1,8 @@
|
|||
"""Config flow for the Velbus platform."""
|
||||
from __future__ import annotations
|
||||
|
||||
import velbus
|
||||
import velbusaio
|
||||
from velbusaio.exceptions import VelbusConnectionFailed
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
|
@ -33,14 +34,15 @@ class VelbusConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
"""Create an entry async."""
|
||||
return self.async_create_entry(title=name, data={CONF_PORT: prt})
|
||||
|
||||
def _test_connection(self, prt):
|
||||
async def _test_connection(self, prt):
|
||||
"""Try to connect to the velbus with the port specified."""
|
||||
try:
|
||||
controller = velbus.Controller(prt)
|
||||
except Exception: # pylint: disable=broad-except
|
||||
controller = velbusaio.controller.Velbus(prt)
|
||||
await controller.connect(True)
|
||||
await controller.stop()
|
||||
except VelbusConnectionFailed:
|
||||
self._errors[CONF_PORT] = "cannot_connect"
|
||||
return False
|
||||
controller.stop()
|
||||
return True
|
||||
|
||||
def _prt_in_configuration_exists(self, prt: str) -> bool:
|
||||
|
@ -56,7 +58,7 @@ class VelbusConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
name = slugify(user_input[CONF_NAME])
|
||||
prt = user_input[CONF_PORT]
|
||||
if not self._prt_in_configuration_exists(prt):
|
||||
if self._test_connection(prt):
|
||||
if await self._test_connection(prt):
|
||||
return self._create_device(name, prt)
|
||||
else:
|
||||
self._errors[CONF_PORT] = "already_configured"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue