Skip to content

Commit 40ceb29

Browse files
committed
1.1.3, fixes related to the HA 2021.12 release
Updated config flow from upstream
1 parent b2ffed1 commit 40ceb29

File tree

5 files changed

+17
-11
lines changed

5 files changed

+17
-11
lines changed

custom_components/knmi/api.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ async def async_get_data(self) -> dict:
3030
async def api_wrapper(self, method: str, url: str) -> dict:
3131
"""Get information from the API."""
3232
try:
33-
async with async_timeout.timeout(TIMEOUT, loop=asyncio.get_event_loop()):
33+
async with async_timeout.timeout(TIMEOUT):
3434
if method == "get":
3535
response = await self._session.get(url)
3636
# The API has no proper error handling for a wrong API key.

custom_components/knmi/config_flow.py

+11-6
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ async def async_step_user(self, user_input=None):
4646

4747
return await self._show_config_form(user_input)
4848

49+
user_input = {}
50+
# Provide defaults for form
51+
user_input[CONF_API_KEY] = ""
52+
user_input[CONF_LATITUDE] = self.hass.config.latitude
53+
user_input[CONF_LONGITUDE] = self.hass.config.longitude
54+
user_input[CONF_NAME] = self.hass.config.location_name
55+
4956
return await self._show_config_form(user_input)
5057

5158
@staticmethod
@@ -59,16 +66,14 @@ async def _show_config_form(self, user_input): # pylint: disable=unused-argumen
5966
step_id="user",
6067
data_schema=vol.Schema(
6168
{
69+
vol.Required(CONF_NAME, default=user_input[CONF_NAME]): str,
6270
vol.Required(
63-
CONF_NAME, default=self.hass.config.location_name
64-
): str,
65-
vol.Required(
66-
CONF_LATITUDE, default=self.hass.config.latitude
71+
CONF_LATITUDE, default=user_input[CONF_LATITUDE]
6772
): cv.latitude,
6873
vol.Required(
69-
CONF_LONGITUDE, default=self.hass.config.longitude
74+
CONF_LONGITUDE, default=user_input[CONF_LONGITUDE]
7075
): cv.longitude,
71-
vol.Required(CONF_API_KEY): str,
76+
vol.Required(CONF_API_KEY, default=user_input[CONF_API_KEY]): str,
7277
}
7378
),
7479
errors=self._errors,

custom_components/knmi/const.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# Base component constants.
1717
NAME = "KNMI"
1818
DOMAIN = "knmi"
19-
VERSION = "1.1.2"
19+
VERSION = "1.1.3"
2020
ATTRIBUTION = "KNMI Weergegevens via https://weerlive.nl/"
2121

2222
# Platforms.

custom_components/knmi/entity.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""KnmiEntity class"""
2+
from homeassistant.helpers.device_registry import DeviceEntryType
23
from homeassistant.helpers.update_coordinator import CoordinatorEntity
34

45
from .const import DOMAIN, NAME, VERSION, ATTRIBUTION
@@ -21,12 +22,12 @@ def device_info(self):
2122
"name": NAME,
2223
"model": VERSION,
2324
"manufacturer": NAME,
24-
"entry_type": "service",
25+
"entry_type": DeviceEntryType.SERVICE,
2526
"configuration_url": "http://weerlive.nl/api/toegang/account.php",
2627
}
2728

2829
@property
29-
def device_state_attributes(self):
30+
def extra_state_attributes(self):
3031
"""Return the state attributes."""
3132
return {
3233
"attribution": ATTRIBUTION,

custom_components/knmi/manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"documentation": "https://github.com/golles/ha-knmi/",
55
"iot_class": "cloud_polling",
66
"issue_tracker": "https://github.com/golles/ha-knmi//issues",
7-
"version": "1.1.2",
7+
"version": "1.1.3",
88
"config_flow": true,
99
"codeowners": [
1010
"@golles"

0 commit comments

Comments
 (0)