Skip to content
Snippets Groups Projects
Commit 2b150ed9 authored by jkerdreu's avatar jkerdreu
Browse files

- Added db_server editing through config_flow

git-svn-id: https://redmine.imt-atlantique.fr/svn/xaal/code/Python/branches/0.7@3017 b32b6428-25c9-4566-ad07-03861ab6144f
parent 2368d376
Branches
Tags
No related merge requests found
......@@ -4,9 +4,10 @@ from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.device_registry import DeviceEntry
from xaal.lib import tools
from .bridge import Bridge
from .const import DOMAIN
from .const import DOMAIN, CONF_DB_SERVER
_LOGGER = logging.getLogger(__name__)
......@@ -16,7 +17,10 @@ PLATFORMS: list[str] = ["light", "switch", "sensor", "binary_sensor","cover", "s
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
# create the hub and load the platforms
bridge = Bridge(hass)
addr = entry.data.get(CONF_DB_SERVER)
db_server = tools.get_uuid(addr)
bridge = Bridge(hass, db_server)
hass.data.setdefault(DOMAIN, {})[entry.entry_id] = bridge
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
......
......@@ -14,8 +14,6 @@ from xaal.monitor import Monitor, Notification
import logging
_LOGGER = logging.getLogger(__name__)
#DB_SERVER = tools.get_uuid('d28fbc27-190f-4ee5-815a-fe05233400a2')
DB_SERVER = tools.get_uuid('9064ccbc-84ea-11e8-80cc-82ed25e6aaaa')
UNSUPPORTED_TYPES = ['cli','hmi','windgauge',]
......@@ -29,12 +27,12 @@ def filter_msg(msg: Message) -> bool:
class Bridge(object):
def __init__(self, hass: HomeAssistant) -> None:
def __init__(self, hass: HomeAssistant, db_server) -> None:
"""Init xAAL bridge."""
self._hass = hass
self._eng = AsyncEngine()
self._dev = self.setup_device()
self._mon = Monitor(self._dev, filter_msg, db_server=DB_SERVER)
self._mon = Monitor(self._dev, filter_msg, db_server)
self._eng.on_start(self.on_start)
self._eng.on_stop(self.on_stop)
self._eng.start()
......
......@@ -3,13 +3,16 @@ import voluptuous as vol
from homeassistant import config_entries
import logging
# from . import bridge
from .const import DOMAIN # pylint:disable=unused-import
from .const import DOMAIN, CONF_DB_SERVER
_LOGGER = logging.getLogger(__name__)
DATA_SCHEMA = vol.Schema({})
DATA_SCHEMA = vol.Schema(
{
vol.Required(CONF_DB_SERVER): str,
}
)
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
......@@ -21,10 +24,6 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
# no user input right now, so we just show the empty form
errors = {}
# br = bridge.Bridge(self.hass)
# r = await br.wait_is_ready()
# print(f"READY={r}")
# br.engine.stop()
# if we have some user_input let's start
if user_input is not None:
......
......@@ -3,3 +3,5 @@
# This is the internal name of the integration, it should also match the directory
# name for the integration.
DOMAIN = "xaal"
CONF_DB_SERVER = "db_server"
\ No newline at end of file
{
"config": {
"step": {
"user": {
"data": {
"db_server": "xALL DB SERVER"
}
}
}
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment