Skip to content

Commit

Permalink
Merge pull request #8 from golles/2021.12-fixes
Browse files Browse the repository at this point in the history
1.1.3, fixes related to the HA 2021.12 release
  • Loading branch information
golles authored Dec 12, 2021
2 parents b2ffed1 + 40ceb29 commit 8aa32f0
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion custom_components/knmi/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ async def async_get_data(self) -> dict:
async def api_wrapper(self, method: str, url: str) -> dict:
"""Get information from the API."""
try:
async with async_timeout.timeout(TIMEOUT, loop=asyncio.get_event_loop()):
async with async_timeout.timeout(TIMEOUT):
if method == "get":
response = await self._session.get(url)
# The API has no proper error handling for a wrong API key.
Expand Down
17 changes: 11 additions & 6 deletions custom_components/knmi/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ async def async_step_user(self, user_input=None):

return await self._show_config_form(user_input)

user_input = {}
# Provide defaults for form
user_input[CONF_API_KEY] = ""
user_input[CONF_LATITUDE] = self.hass.config.latitude
user_input[CONF_LONGITUDE] = self.hass.config.longitude
user_input[CONF_NAME] = self.hass.config.location_name

return await self._show_config_form(user_input)

@staticmethod
Expand All @@ -59,16 +66,14 @@ async def _show_config_form(self, user_input): # pylint: disable=unused-argumen
step_id="user",
data_schema=vol.Schema(
{
vol.Required(CONF_NAME, default=user_input[CONF_NAME]): str,
vol.Required(
CONF_NAME, default=self.hass.config.location_name
): str,
vol.Required(
CONF_LATITUDE, default=self.hass.config.latitude
CONF_LATITUDE, default=user_input[CONF_LATITUDE]
): cv.latitude,
vol.Required(
CONF_LONGITUDE, default=self.hass.config.longitude
CONF_LONGITUDE, default=user_input[CONF_LONGITUDE]
): cv.longitude,
vol.Required(CONF_API_KEY): str,
vol.Required(CONF_API_KEY, default=user_input[CONF_API_KEY]): str,
}
),
errors=self._errors,
Expand Down
2 changes: 1 addition & 1 deletion custom_components/knmi/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# Base component constants.
NAME = "KNMI"
DOMAIN = "knmi"
VERSION = "1.1.2"
VERSION = "1.1.3"
ATTRIBUTION = "KNMI Weergegevens via https://weerlive.nl/"

# Platforms.
Expand Down
5 changes: 3 additions & 2 deletions custom_components/knmi/entity.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""KnmiEntity class"""
from homeassistant.helpers.device_registry import DeviceEntryType
from homeassistant.helpers.update_coordinator import CoordinatorEntity

from .const import DOMAIN, NAME, VERSION, ATTRIBUTION
Expand All @@ -21,12 +22,12 @@ def device_info(self):
"name": NAME,
"model": VERSION,
"manufacturer": NAME,
"entry_type": "service",
"entry_type": DeviceEntryType.SERVICE,
"configuration_url": "http://weerlive.nl/api/toegang/account.php",
}

@property
def device_state_attributes(self):
def extra_state_attributes(self):
"""Return the state attributes."""
return {
"attribution": ATTRIBUTION,
Expand Down
2 changes: 1 addition & 1 deletion custom_components/knmi/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"documentation": "https://github.com/golles/ha-knmi/",
"iot_class": "cloud_polling",
"issue_tracker": "https://github.com/golles/ha-knmi//issues",
"version": "1.1.2",
"version": "1.1.3",
"config_flow": true,
"codeowners": [
"@golles"
Expand Down

0 comments on commit 8aa32f0

Please sign in to comment.