Deconz make groups configurable (#14704)

* Make groups configurable

* Config flow and tests in place

* Fix too long line
This commit is contained in:
Robert Svensson 2018-06-15 20:31:22 +02:00 committed by Paulus Schoutsen
parent 940577e105
commit ac13a2736b
7 changed files with 46 additions and 12 deletions

View file

@ -8,7 +8,9 @@ from homeassistant.const import CONF_API_KEY, CONF_HOST, CONF_PORT
from homeassistant.helpers import aiohttp_client
from homeassistant.util.json import load_json
from .const import CONF_ALLOW_CLIP_SENSOR, CONFIG_FILE, DOMAIN
from .const import (
CONF_ALLOW_DECONZ_GROUPS, CONF_ALLOW_CLIP_SENSOR, CONFIG_FILE, DOMAIN)
CONF_BRIDGEID = 'bridgeid'
@ -94,12 +96,15 @@ class DeconzFlowHandler(data_entry_flow.FlowHandler):
"""Extra options for deCONZ.
CONF_CLIP_SENSOR -- Allow user to choose if they want clip sensors.
CONF_DECONZ_GROUPS -- Allow user to choose if they want deCONZ groups.
"""
from pydeconz.utils import async_get_bridgeid
if user_input is not None:
self.deconz_config[CONF_ALLOW_CLIP_SENSOR] = \
user_input[CONF_ALLOW_CLIP_SENSOR]
self.deconz_config[CONF_ALLOW_DECONZ_GROUPS] = \
user_input[CONF_ALLOW_DECONZ_GROUPS]
if CONF_BRIDGEID not in self.deconz_config:
session = aiohttp_client.async_get_clientsession(self.hass)
@ -115,6 +120,7 @@ class DeconzFlowHandler(data_entry_flow.FlowHandler):
step_id='options',
data_schema=vol.Schema({
vol.Optional(CONF_ALLOW_CLIP_SENSOR): bool,
vol.Optional(CONF_ALLOW_DECONZ_GROUPS): bool,
}),
)
@ -158,6 +164,7 @@ class DeconzFlowHandler(data_entry_flow.FlowHandler):
return await self.async_step_link()
self.deconz_config[CONF_ALLOW_CLIP_SENSOR] = True
self.deconz_config[CONF_ALLOW_DECONZ_GROUPS] = True
return self.async_create_entry(
title='deCONZ-' + self.deconz_config[CONF_BRIDGEID],
data=self.deconz_config