Skip to content

Commit 2900f20

Browse files
committed
Fix compatibility with HA < 2024.4
- Remove Python 3.12-only 'type' alias syntax (use ConfigEntry directly) - Replace _get_reconfigure_entry() and async_update_reload_and_abort() with compatible equivalents that work on HA 2023.4+ - Lower manifest homeassistant minimum from 2024.4.0 to 2023.4.0 https://claude.ai/code/session_01RaoB8Zt3kjJRVZMoV6q56u
1 parent edc10b1 commit 2900f20

3 files changed

Lines changed: 7 additions & 11 deletions

File tree

‎custom_components/luxcloud/__init__.py‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@
1616

1717
PLATFORMS = [Platform.SENSOR, Platform.SWITCH, Platform.NUMBER, Platform.SELECT]
1818

19-
type LuxCloudConfigEntry = ConfigEntry[LuxCloudCoordinator]
2019

21-
22-
async def async_setup_entry(hass: HomeAssistant, entry: LuxCloudConfigEntry) -> bool:
20+
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
2321
session = async_get_clientsession(hass)
2422
api = LuxCloudApi(
2523
session=session,
@@ -41,7 +39,7 @@ async def handle_refresh(_call: ServiceCall) -> None:
4139
return True
4240

4341

44-
async def async_unload_entry(hass: HomeAssistant, entry: LuxCloudConfigEntry) -> bool:
42+
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
4543
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
4644
if unload_ok and not hass.config_entries.async_entries(DOMAIN):
4745
hass.services.async_remove(DOMAIN, "refresh")

‎custom_components/luxcloud/config_flow.py‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,19 +123,17 @@ async def async_step_reauth_confirm(self, user_input=None):
123123
# ------------------------------------------------------------------
124124

125125
async def async_step_reconfigure(self, user_input=None):
126-
entry = self._get_reconfigure_entry()
126+
entry = self.hass.config_entries.async_get_entry(self.context["entry_id"])
127127
errors: dict[str, str] = {}
128128

129129
if user_input is not None:
130130
merged = {**entry.data, **user_input}
131131
if error := await _validate(self.hass, merged):
132132
errors["base"] = error
133133
else:
134-
return self.async_update_reload_and_abort(
135-
entry,
136-
data=merged,
137-
reason="reconfigure_successful",
138-
)
134+
self.hass.config_entries.async_update_entry(entry, data=merged)
135+
await self.hass.config_entries.async_reload(entry.entry_id)
136+
return self.async_abort(reason="reconfigure_successful")
139137

140138
return self.async_show_form(
141139
step_id="reconfigure",

‎custom_components/luxcloud/manifest.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
"codeowners": ["@beardedtech0o"],
99
"iot_class": "cloud_polling",
1010
"version": "1.0.0",
11-
"homeassistant": "2024.4.0",
11+
"homeassistant": "2023.4.0",
1212
"loggers": ["custom_components.luxcloud"]
1313
}

0 commit comments

Comments
 (0)