Skip to content

Commit

Permalink
Remove support for 3.0.0 betas
Browse files Browse the repository at this point in the history
  • Loading branch information
pnbruckner committed Mar 13, 2024
1 parent 57c09a1 commit 7a0ab19
Showing 1 changed file with 1 addition and 22 deletions.
23 changes: 1 addition & 22 deletions custom_components/sun2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import re
from typing import Any, cast

from astral import SunDirection

from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
from homeassistant.const import (
CONF_BINARY_SENSORS,
Expand All @@ -25,7 +23,7 @@
from homeassistant.helpers.service import async_register_admin_service
from homeassistant.helpers.typing import ConfigType

from .const import CONF_DIRECTION, CONF_TIME_AT_ELEVATION, DOMAIN, SIG_HA_LOC_UPDATED
from .const import DOMAIN, SIG_HA_LOC_UPDATED
from .helpers import LocData, LocParams, Sun2Data

PLATFORMS = [Platform.BINARY_SENSOR, Platform.SENSOR]
Expand Down Expand Up @@ -135,25 +133,6 @@ async def entry_updated(hass: HomeAssistant, entry: ConfigEntry) -> None:

async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up config entry."""
# From 3.0.0b8 or older: Convert config direction from -1, 1 -> "setting", "rising"
options = dict(entry.options)
for sensor in options.get(CONF_SENSORS, []):
if CONF_TIME_AT_ELEVATION not in sensor:
continue
if isinstance(direction := sensor[CONF_DIRECTION], str):
continue
sensor[CONF_DIRECTION] = SunDirection(direction).name.lower()
if options != entry.options:
hass.config_entries.async_update_entry(entry, options=options)

# From 3.0.0b9 or older: Convert unique_id from entry.entry_id-unique_id -> unique_id
ent_reg = er.async_get(hass)
for entity in ent_reg.entities.values():
if entity.platform != DOMAIN:
continue
if m := _OLD_UNIQUE_ID.fullmatch(entity.unique_id):
ent_reg.async_update_entity(entity.entity_id, new_unique_id=m.group(1))

entry.async_on_unload(entry.add_update_listener(entry_updated))
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
return True
Expand Down

0 comments on commit 7a0ab19

Please sign in to comment.