Fix missing default latitude/longitude/elevation in OpenUV config flow (#52380)

This commit is contained in:
Aaron Bach 2021-07-01 03:35:14 -05:00 committed by GitHub
parent f8eb07444b
commit 8f70b5c183
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -14,26 +14,35 @@ from homeassistant.helpers import aiohttp_client, config_validation as cv
from .const import DOMAIN
CONFIG_SCHEMA = vol.Schema(
{
vol.Required(CONF_API_KEY): str,
vol.Inclusive(CONF_LATITUDE, "coords"): cv.latitude,
vol.Inclusive(CONF_LONGITUDE, "coords"): cv.longitude,
vol.Optional(CONF_ELEVATION): vol.Coerce(float),
}
)
class OpenUvFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
"""Handle an OpenUV config flow."""
VERSION = 2
@property
def config_schema(self):
"""Return the config schema."""
return vol.Schema(
{
vol.Required(CONF_API_KEY): str,
vol.Inclusive(
CONF_LATITUDE, "coords", default=self.hass.config.latitude
): cv.latitude,
vol.Inclusive(
CONF_LONGITUDE, "coords", default=self.hass.config.longitude
): cv.longitude,
vol.Optional(
CONF_ELEVATION, default=self.hass.config.elevation
): vol.Coerce(float),
}
)
async def _show_form(self, errors=None):
"""Show the form to the user."""
return self.async_show_form(
step_id="user",
data_schema=CONFIG_SCHEMA,
data_schema=self.config_schema,
errors=errors if errors else {},
)