Skip to content

Commit 2282856

Browse files
authored
Wallbox Integration - Type Config Entry (home-assistant#148594)
1 parent 5a4c837 commit 2282856

File tree

7 files changed

+22
-23
lines changed

7 files changed

+22
-23
lines changed

homeassistant/components/wallbox/__init__.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,17 @@
44

55
from wallbox import Wallbox
66

7-
from homeassistant.config_entries import ConfigEntry
87
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME, Platform
98
from homeassistant.core import HomeAssistant
109
from homeassistant.exceptions import ConfigEntryAuthFailed
1110

1211
from .const import UPDATE_INTERVAL
13-
from .coordinator import InvalidAuth, WallboxCoordinator, async_validate_input
12+
from .coordinator import (
13+
InvalidAuth,
14+
WallboxConfigEntry,
15+
WallboxCoordinator,
16+
async_validate_input,
17+
)
1418

1519
PLATFORMS = [
1620
Platform.LOCK,
@@ -20,8 +24,6 @@
2024
Platform.SWITCH,
2125
]
2226

23-
type WallboxConfigEntry = ConfigEntry[WallboxCoordinator]
24-
2527

2628
async def async_setup_entry(hass: HomeAssistant, entry: WallboxConfigEntry) -> bool:
2729
"""Set up Wallbox from a config entry."""
@@ -45,6 +47,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: WallboxConfigEntry) -> b
4547
return True
4648

4749

48-
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
50+
async def async_unload_entry(hass: HomeAssistant, entry: WallboxConfigEntry) -> bool:
4951
"""Unload a config entry."""
5052
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)

homeassistant/components/wallbox/coordinator.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@
7777
210: ChargerStatus.LOCKED_CAR_CONNECTED,
7878
}
7979

80+
type WallboxConfigEntry = ConfigEntry[WallboxCoordinator]
81+
8082

8183
def _require_authentication[_WallboxCoordinatorT: WallboxCoordinator, **_P](
8284
func: Callable[Concatenate[_WallboxCoordinatorT, _P], Any],
@@ -118,10 +120,10 @@ async def async_validate_input(hass: HomeAssistant, wallbox: Wallbox) -> None:
118120
class WallboxCoordinator(DataUpdateCoordinator[dict[str, Any]]):
119121
"""Wallbox Coordinator class."""
120122

121-
config_entry: ConfigEntry
123+
config_entry: WallboxConfigEntry
122124

123125
def __init__(
124-
self, hass: HomeAssistant, config_entry: ConfigEntry, wallbox: Wallbox
126+
self, hass: HomeAssistant, config_entry: WallboxConfigEntry, wallbox: Wallbox
125127
) -> None:
126128
"""Initialize."""
127129
self._station = config_entry.data[CONF_STATION]

homeassistant/components/wallbox/lock.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from typing import Any
66

77
from homeassistant.components.lock import LockEntity, LockEntityDescription
8-
from homeassistant.config_entries import ConfigEntry
98
from homeassistant.core import HomeAssistant
109
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
1110

@@ -14,7 +13,7 @@
1413
CHARGER_LOCKED_UNLOCKED_KEY,
1514
CHARGER_SERIAL_NUMBER_KEY,
1615
)
17-
from .coordinator import WallboxCoordinator
16+
from .coordinator import WallboxConfigEntry, WallboxCoordinator
1817
from .entity import WallboxEntity
1918

2019
LOCK_TYPES: dict[str, LockEntityDescription] = {
@@ -27,7 +26,7 @@
2726

2827
async def async_setup_entry(
2928
hass: HomeAssistant,
30-
entry: ConfigEntry,
29+
entry: WallboxConfigEntry,
3130
async_add_entities: AddConfigEntryEntitiesCallback,
3231
) -> None:
3332
"""Create wallbox lock entities in HASS."""

homeassistant/components/wallbox/number.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from typing import cast
1111

1212
from homeassistant.components.number import NumberEntity, NumberEntityDescription
13-
from homeassistant.config_entries import ConfigEntry
1413
from homeassistant.core import HomeAssistant
1514
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
1615

@@ -24,7 +23,7 @@
2423
CHARGER_PART_NUMBER_KEY,
2524
CHARGER_SERIAL_NUMBER_KEY,
2625
)
27-
from .coordinator import WallboxCoordinator
26+
from .coordinator import WallboxConfigEntry, WallboxCoordinator
2827
from .entity import WallboxEntity
2928

3029

@@ -79,7 +78,7 @@ class WallboxNumberEntityDescription(NumberEntityDescription):
7978

8079
async def async_setup_entry(
8180
hass: HomeAssistant,
82-
entry: ConfigEntry,
81+
entry: WallboxConfigEntry,
8382
async_add_entities: AddConfigEntryEntitiesCallback,
8483
) -> None:
8584
"""Create wallbox number entities in HASS."""
@@ -103,7 +102,7 @@ class WallboxNumber(WallboxEntity, NumberEntity):
103102
def __init__(
104103
self,
105104
coordinator: WallboxCoordinator,
106-
entry: ConfigEntry,
105+
entry: WallboxConfigEntry,
107106
description: WallboxNumberEntityDescription,
108107
) -> None:
109108
"""Initialize a Wallbox number entity."""

homeassistant/components/wallbox/select.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from requests import HTTPError
99

1010
from homeassistant.components.select import SelectEntity, SelectEntityDescription
11-
from homeassistant.config_entries import ConfigEntry
1211
from homeassistant.core import HomeAssistant
1312
from homeassistant.exceptions import HomeAssistantError
1413
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
@@ -23,7 +22,7 @@
2322
DOMAIN,
2423
EcoSmartMode,
2524
)
26-
from .coordinator import WallboxCoordinator
25+
from .coordinator import WallboxConfigEntry, WallboxCoordinator
2726
from .entity import WallboxEntity
2827

2928

@@ -58,7 +57,7 @@ class WallboxSelectEntityDescription(SelectEntityDescription):
5857

5958
async def async_setup_entry(
6059
hass: HomeAssistant,
61-
entry: ConfigEntry,
60+
entry: WallboxConfigEntry,
6261
async_add_entities: AddConfigEntryEntitiesCallback,
6362
) -> None:
6463
"""Create wallbox select entities in HASS."""

homeassistant/components/wallbox/sensor.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
SensorEntityDescription,
1212
SensorStateClass,
1313
)
14-
from homeassistant.config_entries import ConfigEntry
1514
from homeassistant.const import (
1615
PERCENTAGE,
1716
UnitOfElectricCurrent,
@@ -44,7 +43,7 @@
4443
CHARGER_STATE_OF_CHARGE_KEY,
4544
CHARGER_STATUS_DESCRIPTION_KEY,
4645
)
47-
from .coordinator import WallboxCoordinator
46+
from .coordinator import WallboxConfigEntry, WallboxCoordinator
4847
from .entity import WallboxEntity
4948

5049

@@ -169,7 +168,7 @@ class WallboxSensorEntityDescription(SensorEntityDescription):
169168

170169
async def async_setup_entry(
171170
hass: HomeAssistant,
172-
entry: ConfigEntry,
171+
entry: WallboxConfigEntry,
173172
async_add_entities: AddConfigEntryEntitiesCallback,
174173
) -> None:
175174
"""Create wallbox sensor entities in HASS."""

homeassistant/components/wallbox/switch.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from typing import Any
66

77
from homeassistant.components.switch import SwitchEntity, SwitchEntityDescription
8-
from homeassistant.config_entries import ConfigEntry
98
from homeassistant.core import HomeAssistant
109
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
1110

@@ -16,7 +15,7 @@
1615
CHARGER_STATUS_DESCRIPTION_KEY,
1716
ChargerStatus,
1817
)
19-
from .coordinator import WallboxCoordinator
18+
from .coordinator import WallboxConfigEntry, WallboxCoordinator
2019
from .entity import WallboxEntity
2120

2221
SWITCH_TYPES: dict[str, SwitchEntityDescription] = {
@@ -29,7 +28,7 @@
2928

3029
async def async_setup_entry(
3130
hass: HomeAssistant,
32-
entry: ConfigEntry,
31+
entry: WallboxConfigEntry,
3332
async_add_entities: AddConfigEntryEntitiesCallback,
3433
) -> None:
3534
"""Create wallbox sensor entities in HASS."""

0 commit comments

Comments
 (0)