Skip to content

Commit 03e007f

Browse files
authored
Merge pull request #778 from plugwise/fix_optionsflow
Implement OptionsFlow fix for HA 2024.12.0
2 parents f83aac4 + 74df746 commit 03e007f

File tree

5 files changed

+17
-12
lines changed

5 files changed

+17
-12
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22

33
Versions from 0.40 and up
44

5-
## Ongoing
5+
## v0.55.1
66

77
- Bugfix for Issue #776
88
- Support python 3.13 / HA-Core 2024.12
99
- Link to plugwise [v1.6.1](https://github.com/plugwise/python-plugwise/releases/tag/v1.6.1)
10+
- Make Config-OptionsFlow compatible with HA 2024.12.0
1011

1112
## v0.55.0
1213

custom_components/plugwise/config_flow.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from __future__ import annotations
44

5+
from copy import deepcopy
56
from typing import Any, Self
67

78
from plugwise import Smile
@@ -22,7 +23,6 @@
2223
ConfigFlow,
2324
ConfigFlowResult,
2425
OptionsFlow,
25-
OptionsFlowWithConfigEntry,
2626
)
2727

2828
# Upstream
@@ -247,35 +247,39 @@ async def async_step_user(
247247
@callback
248248
def async_get_options_flow(
249249
config_entry: PlugwiseConfigEntry,
250-
) -> OptionsFlow: # pw-beta options
250+
) -> PlugwiseOptionsFlowHandler: # pw-beta options
251251
"""Get the options flow for this handler."""
252252
return PlugwiseOptionsFlowHandler(config_entry)
253253

254254

255255
# pw-beta - change the scan-interval via CONFIGURE
256256
# pw-beta - add homekit emulation via CONFIGURE
257257
# pw-beta - change the frontend refresh interval via CONFIGURE
258-
class PlugwiseOptionsFlowHandler(OptionsFlowWithConfigEntry): # pw-beta options
258+
class PlugwiseOptionsFlowHandler(OptionsFlow): # pw-beta options
259259
"""Plugwise option flow."""
260260

261+
def __init__(self, config_entry: ConfigEntry) -> None:
262+
"""Initialize options flow."""
263+
self.options = deepcopy(dict(config_entry.options))
264+
261265
def _create_options_schema(self, coordinator: PlugwiseDataUpdateCoordinator) -> vol.Schema:
262266
interval = DEFAULT_SCAN_INTERVAL[coordinator.api.smile_type] # pw-beta options
263267
schema = {
264268
vol.Optional(
265269
CONF_SCAN_INTERVAL,
266-
default=self._options.get(CONF_SCAN_INTERVAL, interval.seconds),
270+
default=self.options.get(CONF_SCAN_INTERVAL, interval.seconds),
267271
): vol.All(cv.positive_int, vol.Clamp(min=10)),
268272
} # pw-beta
269273

270274
if coordinator.api.smile_type == THERMOSTAT:
271275
schema.update({
272276
vol.Optional(
273277
CONF_HOMEKIT_EMULATION,
274-
default=self._options.get(CONF_HOMEKIT_EMULATION, False),
278+
default=self.options.get(CONF_HOMEKIT_EMULATION, False),
275279
): vol.All(cv.boolean),
276280
vol.Optional(
277281
CONF_REFRESH_INTERVAL,
278-
default=self._options.get(CONF_REFRESH_INTERVAL, 1.5),
282+
default=self.options.get(CONF_REFRESH_INTERVAL, 1.5),
279283
): vol.All(vol.Coerce(float), vol.Range(min=1.5, max=10.0)),
280284
}) # pw-beta
281285

@@ -287,7 +291,7 @@ async def async_step_none(
287291
"""No options available."""
288292
if user_input is not None:
289293
# Apparently not possible to abort an options flow at the moment
290-
return self.async_create_entry(title="", data=self._options)
294+
return self.async_create_entry(title="", data=self.options)
291295
return self.async_show_form(step_id="none")
292296

293297
async def async_step_init(self, user_input: dict[str, Any] | None = None) -> ConfigFlowResult:

custom_components/plugwise/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
"iot_class": "local_polling",
99
"loggers": ["plugwise"],
1010
"requirements": ["plugwise==1.6.1"],
11-
"version": "0.55.0",
11+
"version": "0.55.1",
1212
"zeroconf": ["_plugwise._tcp.local."]
1313
}

hacs.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
"sensor",
1010
"switch"
1111
],
12-
"homeassistant": "2024.12.0",
12+
"homeassistant": "2024.12.0b2",
1313
"render_readme": true
1414
}

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
[project]
22
name = "plugwise-beta"
3-
version = "0.55.0"
3+
version = "0.55.1"
44
description = "Plugwise beta custom-component"
55
readme = "README.md"
6-
requires-python = ">=3.13"
6+
requires-python = ">=3.12"
77
license = {file = "LICENSE"}
88
keywords = ["Plugwise", "Adam", "Anna", "P1", "Stretch", "Smile"]
99
authors = [

0 commit comments

Comments
 (0)