File tree Expand file tree Collapse file tree 3 files changed +17
-12
lines changed
homeassistant/components/nextdns Expand file tree Collapse file tree 3 files changed +17
-12
lines changed Original file line number Diff line number Diff line change 4
4
5
5
from datetime import timedelta
6
6
import logging
7
- from typing import TYPE_CHECKING , TypeVar
7
+ from typing import TYPE_CHECKING
8
8
9
9
from aiohttp .client_exceptions import ClientConnectorError
10
10
from nextdns import (
33
33
34
34
_LOGGER = logging .getLogger (__name__ )
35
35
36
- CoordinatorDataT = TypeVar ("CoordinatorDataT" , bound = NextDnsData )
37
36
38
-
39
- class NextDnsUpdateCoordinator (DataUpdateCoordinator [CoordinatorDataT ]):
37
+ class NextDnsUpdateCoordinator [CoordinatorDataT : NextDnsData ](
38
+ DataUpdateCoordinator [CoordinatorDataT ]
39
+ ):
40
40
"""Class to manage fetching NextDNS data API."""
41
41
42
42
config_entry : NextDnsConfigEntry
Original file line number Diff line number Diff line change 1
1
"""Define NextDNS entities."""
2
2
3
+ from nextdns .model import NextDnsData
4
+
3
5
from homeassistant .helpers .device_registry import DeviceEntryType , DeviceInfo
4
6
from homeassistant .helpers .entity import EntityDescription
5
7
from homeassistant .helpers .update_coordinator import CoordinatorEntity
6
8
7
9
from .const import DOMAIN
8
- from .coordinator import CoordinatorDataT , NextDnsUpdateCoordinator
10
+ from .coordinator import NextDnsUpdateCoordinator
9
11
10
12
11
- class NextDnsEntity (CoordinatorEntity [NextDnsUpdateCoordinator [CoordinatorDataT ]]):
13
+ class NextDnsEntity [CoordinatorDataT : NextDnsData ](
14
+ CoordinatorEntity [NextDnsUpdateCoordinator [CoordinatorDataT ]]
15
+ ):
12
16
"""Define NextDNS entity."""
13
17
14
18
_attr_has_entity_name = True
Original file line number Diff line number Diff line change 4
4
5
5
from collections .abc import Callable
6
6
from dataclasses import dataclass
7
- from typing import Generic
8
7
9
8
from nextdns import (
10
9
AnalyticsDnssec ,
13
12
AnalyticsProtocols ,
14
13
AnalyticsStatus ,
15
14
)
15
+ from nextdns .model import NextDnsData
16
16
17
17
from homeassistant .components .sensor import (
18
18
SensorEntity ,
32
32
ATTR_PROTOCOLS ,
33
33
ATTR_STATUS ,
34
34
)
35
- from .coordinator import CoordinatorDataT
36
35
from .entity import NextDnsEntity
37
36
38
37
PARALLEL_UPDATES = 0
39
38
40
39
41
40
@dataclass (frozen = True , kw_only = True )
42
- class NextDnsSensorEntityDescription (
43
- SensorEntityDescription , Generic [ CoordinatorDataT ]
41
+ class NextDnsSensorEntityDescription [ CoordinatorDataT : NextDnsData ] (
42
+ SensorEntityDescription
44
43
):
45
44
"""NextDNS sensor entity description."""
46
45
@@ -297,10 +296,12 @@ async def async_setup_entry(
297
296
)
298
297
299
298
300
- class NextDnsSensor (NextDnsEntity , SensorEntity ):
299
+ class NextDnsSensor [CoordinatorDataT : NextDnsData ](
300
+ NextDnsEntity [CoordinatorDataT ], SensorEntity
301
+ ):
301
302
"""Define an NextDNS sensor."""
302
303
303
- entity_description : NextDnsSensorEntityDescription
304
+ entity_description : NextDnsSensorEntityDescription [ CoordinatorDataT ]
304
305
305
306
@property
306
307
def native_value (self ) -> StateType :
You can’t perform that action at this time.
0 commit comments