|
8 | 8 |
|
9 | 9 | import logging |
10 | 10 | import re |
11 | | -from dataclasses import dataclass |
12 | | -from datetime import datetime |
13 | 11 |
|
14 | 12 | import voluptuous as vol |
15 | 13 | from awesomeversion.awesomeversion import AwesomeVersion |
16 | | -from homeassistant.config_entries import ConfigEntry |
17 | 14 | from homeassistant.const import __version__ as HA_VERSION # noqa: N812 |
18 | 15 | from homeassistant.core import HomeAssistant, callback |
19 | 16 | from homeassistant.helpers import config_validation as cv |
20 | 17 | from homeassistant.helpers import entity_registry as er |
21 | 18 | from homeassistant.helpers import issue_registry as ir |
22 | 19 | from homeassistant.helpers.typing import ConfigType |
23 | 20 | from homeassistant.util import dt as dt_util |
24 | | -from homeassistant.util.hass_dict import HassKey |
25 | 21 |
|
26 | 22 | from .config_flow import CONFIG_VERSION |
27 | 23 | from .const import ( |
|
44 | 40 | DEFAULT_SCHEMA_URL, |
45 | 41 | DOMAIN, |
46 | 42 | MIN_HA_VERSION, |
| 43 | + MY_KEY, |
47 | 44 | PLATFORMS, |
48 | 45 | ) |
49 | | -from .coordinator import BatteryNotesCoordinator |
| 46 | +from .coordinator import ( |
| 47 | + BatteryNotesConfigEntry, |
| 48 | + BatteryNotesCoordinator, |
| 49 | + BatteryNotesDomainConfig, |
| 50 | +) |
50 | 51 | from .discovery import DiscoveryManager |
51 | 52 | from .library_updater import LibraryUpdater |
52 | 53 | from .services import setup_services |
53 | 54 | from .store import ( |
54 | | - BatteryNotesStorage, |
55 | 55 | async_get_registry, |
56 | 56 | ) |
57 | 57 |
|
|
91 | 91 | extra=vol.ALLOW_EXTRA, |
92 | 92 | ) |
93 | 93 |
|
94 | | -@dataclass |
95 | | -class BatteryNotesDomainConfig: |
96 | | - """Class for sharing config data within the BatteryNotes integration.""" |
97 | | - enable_autodiscovery: bool = True |
98 | | - show_all_devices: bool = False |
99 | | - enable_replaced: bool = True |
100 | | - hide_battery: bool = False |
101 | | - round_battery: bool = False |
102 | | - default_battery_low_threshold: int = DEFAULT_BATTERY_LOW_THRESHOLD |
103 | | - battery_increased_threshod: int = DEFAULT_BATTERY_INCREASE_THRESHOLD |
104 | | - library_url: str = DEFAULT_LIBRARY_URL |
105 | | - schema_url: str = DEFAULT_SCHEMA_URL |
106 | | - library_updater: LibraryUpdater | None |
107 | | - library_last_update: datetime | None = None |
108 | | - user_library: str = "" |
109 | | - coordinator: BatteryNotesCoordinator | None |
110 | | - |
111 | | -type BatteryNotesConfigEntry = ConfigEntry[BatteryNotesData] |
112 | | - |
113 | | -MY_KEY: HassKey["BatteryNotesDomainConfig"] = HassKey(DOMAIN) |
114 | | - |
115 | | -@dataclass |
116 | | -class BatteryNotesData: |
117 | | - """Class for sharing data within the BatteryNotes integration.""" |
118 | | - |
119 | | - domain_config: BatteryNotesDomainConfig |
120 | | - store: BatteryNotesStorage |
121 | | - coordinator: BatteryNotesCoordinator |
122 | | - |
123 | 94 |
|
124 | 95 | async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: |
125 | 96 | """Integration setup.""" |
|
0 commit comments