Add user input integration for in-app intragration

master
Matthieu DUVAL 5 years ago
parent 9acc7345a8
commit 1c1d53e0f9

@ -1,10 +1,10 @@
{ {
"config": { "config": {
"title": "Georide", "title": "GeoRide",
"step": { "step": {
"user": { "user": {
"title": "Set up Georide", "title": "Set up GeoRide",
"description": "Are you sure you want to set up Georide?", "description": "Are you sure you want to set up GeoRide ?",
"data": { "data": {
"email": "email", "email": "email",
"password": "password" "password": "password"

@ -63,7 +63,8 @@ async def async_setup_entry(hass, entry):
password password
) )
hass.data[DOMAIN]["context"] = context hass.data[DOMAIN]["context"] = context
""" hass.async_create_task(hass.config_entries.async_forward_entry_setup(entry, "device_tracker") ) """ hass.async_create_task(hass.config_entries.async_forward_entry_setup(entry, "device_tracker"))
return True return True

@ -10,8 +10,6 @@ from .const import CONF_EMAIL, CONF_PASSWORD
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
STEP_ID = 'user'
@config_entries.HANDLERS.register("georide") @config_entries.HANDLERS.register("georide")
class GeorideConfigFlow(config_entries.ConfigFlow): class GeorideConfigFlow(config_entries.ConfigFlow):
"""Georide config flow """ """Georide config flow """
@ -23,16 +21,18 @@ class GeorideConfigFlow(config_entries.ConfigFlow):
return self.async_abort(reason="one_instance_allowed") return self.async_abort(reason="one_instance_allowed")
if user_input is None: if user_input is None:
_LOGGER.info("user email: %", str(user_input)) return self.async_show_form(step_id='user', data_schema=vol.Schema({
return self.async_show_form(step_id=STEP_ID, data_schema=vol.Schema({
vol.Required(CONF_EMAIL): vol.All(str, vol.Length(min=3)), vol.Required(CONF_EMAIL): vol.All(str, vol.Length(min=3)),
vol.Required(CONF_PASSWORD): vol.All(str) vol.Required(CONF_PASSWORD): vol.All(str)
})) }))
# process info
return self.async_abort(reason="no_credentials") return self.async_create_entry(
title=user_input[CONF_EMAIL],
data={
CONF_EMAIL: user_input[CONF_EMAIL],
CONF_PASSWORD: user_input[CONF_PASSWORD]
}
)
@ -42,10 +42,10 @@ class GeorideConfigFlow(config_entries.ConfigFlow):
_LOGGER.info("user email: %", str(user_input)) _LOGGER.info("user email: %", str(user_input))
return self.async_create_entry( return self.async_create_entry(
title="Georide", title=user_input[CONF_EMAIL] + "machin",
data={ data={
CONF_EMAIL: "un_emal", CONF_EMAIL: user_input[CONF_EMAIL],
CONF_PASSWORD: "un password" CONF_PASSWORD: user_input[CONF_PASSWORD]
}, }
) )

@ -1,10 +1,10 @@
{ {
"config": { "config": {
"title": "Georide", "title": "GeoRide",
"step": { "step": {
"user": { "user": {
"title": "Set up Georide", "title": "Set up GeoRide",
"description": "Are you sure you want to set up Georide?", "description": "Are you sure you want to set up GeoRide ?",
"data": { "data": {
"email": "email", "email": "email",
"password": "password" "password": "password"

Loading…
Cancel
Save