diff --git a/README.md b/README.md index e5579d4..d66d61f 100644 --- a/README.md +++ b/README.md @@ -53,10 +53,46 @@ File | Purpose ## How? +* …or create a new repository on the command line: + ```bash + # Initialize your new origin repository + git init + git remote add origin https://github.com/YOUR_NEW_REPOSITORY + + # Apply blueprint repository + git remote add blueprint https://github.com/Limych/ha-blueprint.git + git fetch blueprint dev + git reset --hard blueprint/dev + git branch -M dev + + # Push changes to origin repository + git push -u origin main + ``` + +* …or apply blueprint to an existing repository from the command line: + ```bash + # Apply blueprint repository + git remote add blueprint https://github.com/Limych/ha-blueprint.git + git fetch blueprint dev + git merge blueprint/dev --allow-unrelated-histories + + # Push changes to origin repository + git push -u origin main + ``` + +After these steps, your repository will developing on a own branch. But in parallel there will be this blueprint repository, new changes in which you can always apply with a couple of simple commands: +```bash +./bin/update +git merge blueprint/dev +``` + +**Note:** Please, before starting to develop your own code, initialize the development environment with the command +```bash +./bin/setup +``` + If you want to use all the potential and features of this blueprint template you -should use Visual Studio Code to develop in a container. In this container you -will have all the tools to ease your python development and a dedicated Home -Assistant core instance to run your integration. See `.devcontainer/README.md` for more information. +should use devcontainer. See [.devcontainer/README.md](./.devcontainer/README.md) for more information. If you need to work on the python library in parallel of this integration (`sampleclient` in this example) there are different options. The following one seems diff --git a/bin/update b/bin/update index ffc9b49..0fcd7ea 100755 --- a/bin/update +++ b/bin/update @@ -8,7 +8,7 @@ ROOT="$( cd "$( dirname "$(readlink -f "$0")" )/.." >/dev/null 2>&1 && pwd )" cd "${ROOT}" if git branch -r | grep -q "blueprint/" ; then - git fetch blueprint + git fetch blueprint dev fi git fetch diff --git a/custom_components/integration_blueprint/config_flow.py b/custom_components/integration_blueprint/config_flow.py index a696520..8437c05 100644 --- a/custom_components/integration_blueprint/config_flow.py +++ b/custom_components/integration_blueprint/config_flow.py @@ -1,7 +1,11 @@ """Adds config flow for Blueprint.""" +from typing import Optional + import voluptuous as vol from homeassistant import config_entries +from homeassistant.config_entries import ConfigEntry from homeassistant.core import callback +from homeassistant.helpers import ConfigType from homeassistant.helpers.aiohttp_client import async_create_clientsession from .api import IntegrationBlueprintApiClient @@ -23,7 +27,7 @@ def __init__(self): """Initialize.""" self._errors = {} - async def async_step_user(self, user_input=None): + async def async_step_user(self, user_input: Optional[ConfigType] = None): """Handle a flow initialized by the user.""" self._errors = {} @@ -46,11 +50,12 @@ async def async_step_user(self, user_input=None): @staticmethod @callback - def async_get_options_flow(config_entry): + def async_get_options_flow(config_entry: ConfigEntry): """Get component options flow.""" return BlueprintOptionsFlowHandler(config_entry) - async def _show_config_form(self, user_input): # pylint: disable=unused-argument + # pylint: disable=unused-argument + async def _show_config_form(self, user_input: Optional[ConfigType]): """Show the configuration form to edit location data.""" return self.async_show_form( step_id="user", @@ -60,31 +65,32 @@ async def _show_config_form(self, user_input): # pylint: disable=unused-argumen errors=self._errors, ) - async def _test_credentials(self, username, password): + async def _test_credentials(self, username: str, password: str) -> bool: """Return true if credentials is valid.""" try: session = async_create_clientsession(self.hass) client = IntegrationBlueprintApiClient(username, password, session) await client.async_get_data() return True + except Exception: # pylint: disable=broad-except - pass - return False + return False class BlueprintOptionsFlowHandler(config_entries.OptionsFlow): """Blueprint config flow options handler.""" - def __init__(self, config_entry): + def __init__(self, config_entry: ConfigEntry): """Initialize HACS options flow.""" self.config_entry = config_entry self.options = dict(config_entry.options) - async def async_step_init(self, user_input=None): # pylint: disable=unused-argument + # pylint: disable=unused-argument + async def async_step_init(self, user_input: Optional[ConfigType] = None): """Manage the options.""" return await self.async_step_user() - async def async_step_user(self, user_input=None): + async def async_step_user(self, user_input: Optional[ConfigType] = None): """Handle a flow initialized by the user.""" if user_input is not None: self.options.update(user_input)