From f13daa33220f62e594d117e942b36eee972540fd Mon Sep 17 00:00:00 2001 From: Matthieu Date: Sat, 26 Oct 2019 21:01:41 +0200 Subject: [PATCH] Small login fix and add urllib3 specification --- custom_components/georide/.translations/en.json | 2 +- custom_components/georide/__init__.py | 1 + custom_components/georide/config_flow.py | 11 ++++++++++- custom_components/georide/manifest.json | 3 ++- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/custom_components/georide/.translations/en.json b/custom_components/georide/.translations/en.json index 85055ad..bcf76b3 100644 --- a/custom_components/georide/.translations/en.json +++ b/custom_components/georide/.translations/en.json @@ -17,7 +17,7 @@ }, "create_entry": { - "default": "\n\nJust give your credentials" + "default": "\n\nLogin succes ({auth_token})" } } } \ No newline at end of file diff --git a/custom_components/georide/__init__.py b/custom_components/georide/__init__.py index 3a9b2f1..79b5e21 100644 --- a/custom_components/georide/__init__.py +++ b/custom_components/georide/__init__.py @@ -59,6 +59,7 @@ async def async_setup_entry(hass, entry): password = config.get(CONF_EMAIL) or entry.data[CONF_EMAIL] account = GeorideApi.get_authorisation_token(email, password) + context = GeorideContext( hass, email, diff --git a/custom_components/georide/config_flow.py b/custom_components/georide/config_flow.py index 54a34f1..fc62df5 100644 --- a/custom_components/georide/config_flow.py +++ b/custom_components/georide/config_flow.py @@ -41,8 +41,17 @@ class GeorideConfigFlow(config_entries.ConfigFlow): _LOGGER.info("user email: %", str(user_input)) + if self._async_current_entries(): + return self.async_abort(reason="one_instance_allowed") + + if user_input is None: + return self.async_show_form(step_id='user', data_schema=vol.Schema({ + vol.Required(CONF_EMAIL): vol.All(str, vol.Length(min=3)), + vol.Required(CONF_PASSWORD): vol.All(str) + })) + return self.async_create_entry( - title=user_input[CONF_EMAIL] + "machin", + title=user_input, data={ CONF_EMAIL: user_input[CONF_EMAIL], CONF_PASSWORD: user_input[CONF_PASSWORD] diff --git a/custom_components/georide/manifest.json b/custom_components/georide/manifest.json index 26a48e9..66d9837 100644 --- a/custom_components/georide/manifest.json +++ b/custom_components/georide/manifest.json @@ -4,7 +4,8 @@ "config_flow": true, "documentation": "https://git.tontontux.fr/mduval/GeorideHA", "requirements": [ - "georideapilib==0.1.0" + "georideapilib==0.1.0", + "urllib3>=1.25.6" ], "dependencies": [], "codeowners": ["@ptimatth"]