From 4e29eb55cd1378efa2e498a7f28bfd18c0b6dae2 Mon Sep 17 00:00:00 2001 From: Chris Date: Tue, 7 Sep 2021 13:23:53 -0700 Subject: [PATCH] fix radius not working on config flow (#10) --- custom_components/openei/config_flow.py | 5 +++-- custom_components/openei/manifest.json | 2 +- custom_components/openei/translations/en.json | 6 ++++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/custom_components/openei/config_flow.py b/custom_components/openei/config_flow.py index 3f451c7..e544bf0 100644 --- a/custom_components/openei/config_flow.py +++ b/custom_components/openei/config_flow.py @@ -184,7 +184,7 @@ def _get_default(key: str, fallback_default: Any = None) -> None: vol.Required( CONF_API_KEY, default=_get_default(CONF_API_KEY, "") ): cv.string, - vol.Optional(CONF_RADIUS, default=_get_default(CONF_RADIUS, "")): cv.float, + vol.Optional(CONF_RADIUS, default=_get_default(CONF_RADIUS, "")): cv.string, }, ) @@ -243,8 +243,9 @@ async def _get_utility_list(hass, user_input) -> list | None: lat = hass.config.latitude lon = hass.config.longitude api = user_input[CONF_API_KEY] + radius = user_input[CONF_RADIUS] - plans = openeihttp.Rates(api, lat, lon) + plans = openeihttp.Rates(api, lat, lon, radius=radius) plans = await hass.async_add_executor_job(_lookup_plans, plans) utilities = [] diff --git a/custom_components/openei/manifest.json b/custom_components/openei/manifest.json index 2fbedba..1d1a854 100644 --- a/custom_components/openei/manifest.json +++ b/custom_components/openei/manifest.json @@ -8,5 +8,5 @@ "config_flow": true, "codeowners": ["@firstof9"], "requirements": ["python-openei==0.1.6"], - "version": "0.0.5" + "version": "0.0.6" } diff --git a/custom_components/openei/translations/en.json b/custom_components/openei/translations/en.json index 91b54ee..c91d1b7 100644 --- a/custom_components/openei/translations/en.json +++ b/custom_components/openei/translations/en.json @@ -5,7 +5,8 @@ "title": "OpenEI (Step 1)", "description": "If you do not have an API Key yet you can get one here: https://openei.org/services/api/signup/", "data": { - "api_key": "API Key" + "api_key": "API Key", + "radius": "Radius in miles (optional)" } }, "user_2": { @@ -36,7 +37,8 @@ "title": "OpenEI (Step 1)", "description": "If you do not have an API Key yet you can get one here: https://openei.org/services/api/signup/", "data": { - "api_key": "API Key" + "api_key": "API Key", + "radius": "Radius in miles (optional)" } }, "user_2": {