Skip to content

Commit

Permalink
Merge pull request #51 from anand-p-r/develop
Browse files Browse the repository at this point in the history
Bug fixes
  • Loading branch information
anand-p-r authored Mar 12, 2022
2 parents 5c4d0fb + 9f54e2c commit 557a846
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"domain": "fmi",
"version": "0.4.7",
"version": "0.4.8",
"name": "Finnish Meteorological Institute",
"documentation": "https://www.home-assistant.io/integrations/fmi/",
"requirements": [
Expand Down
18 changes: 15 additions & 3 deletions weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
WeatherEntity,
)

from homeassistant.const import CONF_NAME
from awesomeversion import AwesomeVersion
from homeassistant.const import CONF_NAME, __version__ as HA_VERSION
from homeassistant.helpers.update_coordinator import CoordinatorEntity
from .const import CONF_DAILY_MODE

Expand All @@ -29,6 +30,7 @@

PARALLEL_UPDATES = 1

CURRENT_HA_VERSION = AwesomeVersion(HA_VERSION)

async def async_setup_entry(hass, config_entry, async_add_entities):
"""Add an FMI weather entity from a config_entry."""
Expand Down Expand Up @@ -84,13 +86,23 @@ def unique_id(self):
@property
def device_info(self):
"""Return the device info."""
return {
info = {
"identifiers": {(DOMAIN, self.coordinator.unique_id)},
"name": NAME,
"manufacturer": MANUFACTURER,
"entry_type": "service",
}

# Legacy fallback can be removed when minimum required
# HA version is 2021.12.
if CURRENT_HA_VERSION >= "2021.12.0b0":
from homeassistant.helpers.device_registry import DeviceEntryType

info["entry_type"] = DeviceEntryType.SERVICE
else:
info["entry_type"] = "service"

return info

@property
def available(self):
"""Return if weather data is available from FMI."""
Expand Down

0 comments on commit 557a846

Please sign in to comment.