Skip to content

Commit

Permalink
Fixed reconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
kgn3400 committed Sep 2, 2024
1 parent 5d2a9c2 commit 5d87cbf
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 35 deletions.
22 changes: 1 addition & 21 deletions custom_components/hiper_drift/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,7 @@
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator

from .component_api import ComponentApi
from .const import (
CONF_CITY,
CONF_CITY_CHECK,
CONF_GENERAL_MSG,
CONF_REGION,
CONF_STREET,
CONF_STREET_CHECK,
DOMAIN,
LOGGER,
)
from .const import DOMAIN, LOGGER

PLATFORMS: list[Platform] = [Platform.BINARY_SENSOR, Platform.SENSOR]

Expand All @@ -40,12 +31,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
coordinator,
entry,
async_get_clientsession(hass),
entry.options[CONF_REGION],
entry.options[CONF_GENERAL_MSG],
entry.options[CONF_CITY_CHECK],
entry.options[CONF_CITY],
entry.options[CONF_STREET_CHECK],
entry.options[CONF_STREET],
)

entry.async_on_unload(entry.add_update_listener(update_listener))
Expand Down Expand Up @@ -85,9 +70,4 @@ async def update_listener(
) -> None:
"""Reload on config entry update."""

component_api: ComponentApi = hass.data[DOMAIN][config_entry.entry_id][
"component_api"
]

await hass.config_entries.async_reload(config_entry.entry_id)
await component_api.async_update()
33 changes: 20 additions & 13 deletions custom_components/hiper_drift/component_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,19 @@
from homeassistant.core import HomeAssistant, ServiceCall
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator

from .const import CONF_CONTENT, CONF_FYN_REGION, CONF_MSG, CONF_SJ_BH_REGION, DOMAIN
from .const import (
CONF_CITY,
CONF_CITY_CHECK,
CONF_CONTENT,
CONF_FYN_REGION,
CONF_GENERAL_MSG,
CONF_MSG,
CONF_REGION,
CONF_SJ_BH_REGION,
CONF_STREET,
CONF_STREET_CHECK,
DOMAIN,
)


# ------------------------------------------------------------------
Expand All @@ -28,25 +40,20 @@ def __init__(
coordinator: DataUpdateCoordinator,
entry: ConfigEntry,
session: ClientSession | None,
region: str,
general_msg: bool,
city_check: bool,
city: str,
street_check: bool,
street: str,
) -> None:
"""Hiper api."""

self.hass: HomeAssistant = hass
self.coordinator: DataUpdateCoordinator = coordinator
self.entry: ConfigEntry = entry
self.session: ClientSession | None = session
self.region: str = region
self.general_msg: bool = general_msg
self.city_check: bool = city_check
self.city: str = city
self.street_check: bool = street_check
self.street: str = street

self.region: str = entry.options[CONF_REGION]
self.general_msg: bool = entry.options[CONF_GENERAL_MSG]
self.city_check: bool = entry.options[CONF_CITY_CHECK]
self.city: str = entry.options[CONF_CITY]
self.street_check: bool = entry.options[CONF_STREET_CHECK]
self.street: str = entry.options[CONF_STREET]

self.request_timeout: int = 10
self.close_session: bool = False
Expand Down
2 changes: 1 addition & 1 deletion custom_components/hiper_drift/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
],
"single_config_entry": true,
"ssdp": [],
"version": "1.0.19",
"version": "1.0.20",
"zeroconf": []
}

0 comments on commit 5d87cbf

Please sign in to comment.