Skip to content

Commit 1392544

Browse files
committed
Fix some deprecated methods in Home Assistant 2025.1
1 parent 3219bfa commit 1392544

File tree

6 files changed

+18
-25
lines changed

6 files changed

+18
-25
lines changed

custom_components/pandora_cas/__init__.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@
1212
from homeassistant import config_entries
1313
from homeassistant.config_entries import SOURCE_DISCOVERY, ConfigEntry
1414
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
15+
from homeassistant.core import HomeAssistant
1516
from homeassistant.helpers import discovery
1617
from homeassistant.helpers.event import async_track_time_interval, track_time_interval
17-
from homeassistant.helpers.typing import ConfigType, HomeAssistantType
18+
from homeassistant.helpers.typing import ConfigType
1819
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
1920

2021
from .api import PandoraApi, PandoraApiException
@@ -64,7 +65,7 @@
6465
PANDORA_CAS_PLATFORMS = ["sensor", "binary_sensor", "device_tracker"]
6566

6667

67-
async def async_setup(hass: HomeAssistantType, config: ConfigType) -> bool:
68+
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
6869
"""Activate Pandora Car Alarm System component"""
6970

7071
hass.data[DOMAIN] = {}
@@ -91,7 +92,7 @@ async def async_setup(hass: HomeAssistantType, config: ConfigType) -> bool:
9192
return True
9293

9394

94-
async def async_setup_entry(hass: HomeAssistantType, config_entry: ConfigEntry) -> bool:
95+
async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool:
9596
"""Setup configuration entry for Pandora Car Alarm System."""
9697

9798
username = config_entry.data[CONF_USERNAME]
@@ -122,18 +123,13 @@ async def _execute_command(call) -> bool:
122123
_LOGGER.error("Setting up entry %s failed: %s", username, str(ex))
123124
return False
124125

125-
for platform in PANDORA_CAS_PLATFORMS:
126-
hass.async_create_task(hass.config_entries.async_forward_entry_setup(config_entry, platform))
126+
await hass.config_entries.async_forward_entry_setups(config_entry, PANDORA_CAS_PLATFORMS)
127127

128128
return True
129129

130130

131-
async def async_unload_entry(hass: HomeAssistantType, config_entry: ConfigEntry) -> bool:
131+
async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool:
132132
"""Unload the config entry and platforms."""
133133
hass.data.pop(DOMAIN)
134134

135-
tasks = []
136-
for platform in PANDORA_CAS_PLATFORMS:
137-
tasks.append(hass.config_entries.async_forward_entry_unload(config_entry, platform))
138-
139-
return all(await asyncio.gather(*tasks))
135+
return await hass.config_entries.async_unload_platforms(entry, PANDORA_CAS_PLATFORMS)

custom_components/pandora_cas/api.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@
77
from typing import Callable
88

99
import aiohttp
10-
from homeassistant.core import CALLBACK_TYPE, callback
10+
from homeassistant.core import CALLBACK_TYPE, HomeAssistant, callback
1111
from homeassistant.helpers.aiohttp_client import async_create_clientsession
1212
from homeassistant.helpers.event import async_track_point_in_utc_time
13-
from homeassistant.helpers.typing import HomeAssistantType
1413
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
1514
from homeassistant.util.dt import utcnow
1615

@@ -49,7 +48,7 @@ class PandoraApiException(Exception):
4948
class PandoraApi:
5049
"""Pandora API class."""
5150

52-
def __init__(self, hass: HomeAssistantType, username: str, password: str, polling_interval: int) -> None:
51+
def __init__(self, hass: HomeAssistant, username: str, password: str, polling_interval: int) -> None:
5352
"""Constructor"""
5453
self._hass = hass
5554
self._username = username

custom_components/pandora_cas/binary_sensor.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
)
1313
from homeassistant.config_entries import ConfigEntry
1414
from homeassistant.const import ATTR_DEVICE_CLASS, ATTR_ICON, ATTR_NAME
15-
from homeassistant.core import callback
16-
from homeassistant.helpers.typing import HomeAssistantType
15+
from homeassistant.core import HomeAssistant, callback
1716
from homeassistant.util import slugify
1817

1918
from .api import PandoraDevice
@@ -134,7 +133,7 @@
134133

135134

136135
# pylint: disable=unused-argument
137-
async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry, async_add_entities):
136+
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry, async_add_entities):
138137
""""""
139138

140139
api = hass.data[DOMAIN]

custom_components/pandora_cas/device_tracker.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
from homeassistant.components.device_tracker import DOMAIN as PLATFORM_DOMAIN, SourceType
99
from homeassistant.components.device_tracker.config_entry import TrackerEntity
1010
from homeassistant.config_entries import ConfigEntry
11-
from homeassistant.helpers.typing import HomeAssistantType
11+
from homeassistant.core import HomeAssistant, callback
1212
from homeassistant.util import slugify
13-
from homeassistant.core import callback
13+
1414

1515
from .api import PandoraDevice
1616
from .const import DOMAIN
@@ -19,7 +19,7 @@
1919
_LOGGER = logging.getLogger(__name__)
2020

2121
# pylint: disable=unused-argument
22-
async def async_setup_entry(hass: HomeAssistantType, config_entry: ConfigEntry, async_add_entities):
22+
async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities):
2323
"""Set up the tracker."""
2424

2525
api = hass.data[DOMAIN]
@@ -42,7 +42,7 @@ async def async_setup_entry(hass: HomeAssistantType, config_entry: ConfigEntry,
4242
class PandoraTrackerEntity(TrackerEntity):
4343
""""""
4444

45-
def __init__(self, hass: HomeAssistantType, device: PandoraDevice):
45+
def __init__(self, hass: HomeAssistant, device: PandoraDevice):
4646
self._hass = hass
4747
self._device = device
4848
self._latitude = None

custom_components/pandora_cas/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
"iot_class": "cloud_polling",
99
"issue_tracker": "https://github.com/turbulator/pandora-cas/issues",
1010
"requirements": [],
11-
"version": "1.4.7"
11+
"version": "1.4.8"
1212
}

custom_components/pandora_cas/sensor.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
from homeassistant.components.sensor.const import SensorDeviceClass
1010
from homeassistant.config_entries import ConfigEntry
1111
from homeassistant.const import ATTR_DEVICE_CLASS, ATTR_ICON, ATTR_NAME, PERCENTAGE, UnitOfLength, UnitOfElectricPotential, UnitOfTemperature, UnitOfSpeed
12-
from homeassistant.core import callback
13-
from homeassistant.helpers.typing import HomeAssistantType
12+
from homeassistant.core import HomeAssistant, callback
1413
from homeassistant.util import slugify
1514

1615
from .api import PandoraDevice
@@ -100,7 +99,7 @@
10099

101100

102101
# pylint: disable=unused-argument
103-
async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry, async_add_entities):
102+
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry, async_add_entities):
104103
"""Set up ecobee binary (occupancy) sensors."""
105104

106105
api = hass.data[DOMAIN]

0 commit comments

Comments
 (0)