Skip to content

Commit f720162

Browse files
authored
Merge pull request #72 from RustyDust/sru_work
Hotfix: Reconfigure flow for existing installations
2 parents 43ae4b0 + e1392f0 commit f720162

File tree

3 files changed

+27
-8
lines changed

3 files changed

+27
-8
lines changed

.github/workflows/validate.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Validate
2+
3+
on:
4+
push:
5+
pull_request:
6+
schedule:
7+
- cron: "0 1 * * *"
8+
workflow_dispatch:
9+
10+
jobs:
11+
validate-hacs:
12+
runs-on: "ubuntu-latest"
13+
steps:
14+
- name: HACS validation
15+
uses: "hacs/action@main"
16+
with:
17+
category: "integration"

custom_components/sonnenbatterie/config_flow.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,30 +76,31 @@ async def async_step_reconfigure(self, user_input):
7676
{
7777
vol.Required(
7878
CONF_IP_ADDRESS,
79-
default = entry.data[CONF_IP_ADDRESS] or None
79+
default = entry.data.get(CONF_IP_ADDRESS) or None
8080
): str,
8181
vol.Required(
8282
CONF_USERNAME,
83-
default = entry.data[CONF_USERNAME] or "User"
83+
default = entry.data.get(CONF_USERNAME) or "User"
8484
): vol.In(["User", "Installer"]),
8585
vol.Required(
8686
CONF_PASSWORD,
87-
default = entry.data[CONF_PASSWORD] or ""
87+
default = entry.data.get(CONF_PASSWORD) or ""
8888
): str,
8989
vol.Required(
9090
CONF_SCAN_INTERVAL,
91-
default=entry.data[CONF_SCAN_INTERVAL] or DEFAULT_SCAN_INTERVAL
91+
default=entry.data.get(CONF_SCAN_INTERVAL) or DEFAULT_SCAN_INTERVAL
9292
): cv.positive_int,
9393
vol.Optional(
9494
ATTR_SONNEN_DEBUG,
95-
default=entry.data[ATTR_SONNEN_DEBUG] or DEFAULT_SONNEN_DEBUG)
95+
default=entry.data.get(ATTR_SONNEN_DEBUG) or DEFAULT_SONNEN_DEBUG)
9696
: cv.boolean,
9797
}
9898
)
9999

100100
if user_input is not None:
101-
await self.async_set_unique_id(entry.data[CONF_SERIAL_NUMBER])
102-
self._abort_if_unique_id_configured()
101+
if entry.data.get(CONF_SERIAL_NUMBER):
102+
await self.async_set_unique_id(entry.data[CONF_SERIAL_NUMBER])
103+
self._abort_if_unique_id_configured()
103104
# noinspection PyBroadException
104105
try:
105106
my_serial = await self.hass.async_add_executor_job(

custom_components/sonnenbatterie/manifest.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"dependencies": [],
77
"documentation": "https://github.com/weltmeyer/ha_sonnenbatterie",
88
"iot_class": "local_polling",
9+
"issue_tracker": "https://github.com/weltmeyer/ha_sonnenbatterie/issues",
910
"requirements": ["requests","sonnenbatterie>=0.3.0"],
10-
"version": "2024.12.01"
11+
"version": "2024.12.02"
1112
}

0 commit comments

Comments
 (0)