Show how to only allow one instance
This commit is contained in:
parent
a53b0f75a1
commit
a727e061d6
@ -5,7 +5,7 @@
|
|||||||
"appPort": [
|
"appPort": [
|
||||||
"9123:8123"
|
"9123:8123"
|
||||||
],
|
],
|
||||||
"postCreateCommand": "dc install",
|
"postCreateCommand": "cc install",
|
||||||
"runArgs": [
|
"runArgs": [
|
||||||
"-v",
|
"-v",
|
||||||
"${env:HOME}${env:USERPROFILE}/.ssh:/tmp/.ssh"
|
"${env:HOME}${env:USERPROFILE}/.ssh:/tmp/.ssh"
|
||||||
|
@ -13,6 +13,9 @@
|
|||||||
},
|
},
|
||||||
"error": {
|
"error": {
|
||||||
"auth": "Username/Password is wrong."
|
"auth": "Username/Password is wrong."
|
||||||
|
},
|
||||||
|
"abort": {
|
||||||
|
"single_instance_allowed": "Only a single configuration of Blueprint is allowed."
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"options": {
|
"options": {
|
||||||
|
@ -13,6 +13,9 @@
|
|||||||
},
|
},
|
||||||
"error": {
|
"error": {
|
||||||
"auth": "Brukernavn/Passord er feil."
|
"auth": "Brukernavn/Passord er feil."
|
||||||
|
},
|
||||||
|
"abort": {
|
||||||
|
"single_instance_allowed": "Du kan konfigurere Blueprint kun en gang."
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"options": {
|
"options": {
|
||||||
|
@ -1,15 +1,14 @@
|
|||||||
"""Adds config flow for Blueprint."""
|
"""Adds config flow for Blueprint."""
|
||||||
from collections import OrderedDict
|
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
from sampleclient.client import Client
|
|
||||||
from homeassistant import config_entries
|
from homeassistant import config_entries
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
|
|
||||||
from custom_components.blueprint.const import (
|
from sampleclient.client import Client
|
||||||
DOMAIN,
|
|
||||||
|
from custom_components.blueprint.const import ( # pylint: disable=unused-import
|
||||||
CONF_PASSWORD,
|
CONF_PASSWORD,
|
||||||
CONF_USERNAME,
|
CONF_USERNAME,
|
||||||
|
DOMAIN,
|
||||||
PLATFORMS,
|
PLATFORMS,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -25,10 +24,15 @@ class BlueprintFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
self._errors = {}
|
self._errors = {}
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input={}
|
self, user_input=None # pylint: disable=bad-continuation
|
||||||
): # pylint: disable=dangerous-default-value
|
):
|
||||||
"""Handle a flow initialized by the user."""
|
"""Handle a flow initialized by the user."""
|
||||||
self._errors = {}
|
self._errors = {}
|
||||||
|
|
||||||
|
# Uncomment the next 2 lines if only a single instance of the integration is allowed:
|
||||||
|
# if self._async_current_entries():
|
||||||
|
# return self.async_abort(reason="single_instance_allowed")
|
||||||
|
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
valid = await self._test_credentials(
|
valid = await self._test_credentials(
|
||||||
user_input[CONF_USERNAME], user_input[CONF_PASSWORD]
|
user_input[CONF_USERNAME], user_input[CONF_PASSWORD]
|
||||||
@ -49,7 +53,7 @@ class BlueprintFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
def async_get_options_flow(config_entry):
|
def async_get_options_flow(config_entry):
|
||||||
return BlueprintOptionsFlowHandler(config_entry)
|
return BlueprintOptionsFlowHandler(config_entry)
|
||||||
|
|
||||||
async def _show_config_form(self, user_input):
|
async def _show_config_form(self, user_input): # pylint: disable=unused-argument
|
||||||
"""Show the configuration form to edit location data."""
|
"""Show the configuration form to edit location data."""
|
||||||
return self.async_show_form(
|
return self.async_show_form(
|
||||||
step_id="user",
|
step_id="user",
|
||||||
@ -78,7 +82,7 @@ class BlueprintOptionsFlowHandler(config_entries.OptionsFlow):
|
|||||||
self.config_entry = config_entry
|
self.config_entry = config_entry
|
||||||
self.options = dict(config_entry.options)
|
self.options = dict(config_entry.options)
|
||||||
|
|
||||||
async def async_step_init(self, user_input=None):
|
async def async_step_init(self, user_input=None): # pylint: disable=unused-argument
|
||||||
"""Manage the options."""
|
"""Manage the options."""
|
||||||
return await self.async_step_user()
|
return await self.async_step_user()
|
||||||
|
|
||||||
|
@ -43,11 +43,9 @@ class BlueprintEntity(entity.Entity):
|
|||||||
|
|
||||||
async def async_added_to_hass(self):
|
async def async_added_to_hass(self):
|
||||||
"""Connect to dispatcher listening for entity data notifications."""
|
"""Connect to dispatcher listening for entity data notifications."""
|
||||||
self.coordinator.async_add_listener(self.async_write_ha_state)
|
self.async_on_remove(
|
||||||
|
self.coordinator.async_add_listener(self.async_write_ha_state)
|
||||||
async def async_will_remove_from_hass(self):
|
)
|
||||||
"""Disconnect from update signal."""
|
|
||||||
self.coordinator.async_remove_listener(self.async_write_ha_state)
|
|
||||||
|
|
||||||
async def async_update(self):
|
async def async_update(self):
|
||||||
"""Update Brother entity."""
|
"""Update Brother entity."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user