diff --git a/.github/workflows/validate.yaml b/.github/workflows/validate.yaml new file mode 100644 index 0000000..c38f573 --- /dev/null +++ b/.github/workflows/validate.yaml @@ -0,0 +1,17 @@ +name: Validate + +on: + push: + pull_request: + schedule: + - cron: "0 1 * * *" + workflow_dispatch: + +jobs: + validate-hacs: + runs-on: "ubuntu-latest" + steps: + - name: HACS validation + uses: "hacs/action@main" + with: + category: "integration" diff --git a/custom_components/sonnenbatterie/config_flow.py b/custom_components/sonnenbatterie/config_flow.py index 3371739..6f7a3fd 100644 --- a/custom_components/sonnenbatterie/config_flow.py +++ b/custom_components/sonnenbatterie/config_flow.py @@ -76,30 +76,31 @@ async def async_step_reconfigure(self, user_input): { vol.Required( CONF_IP_ADDRESS, - default = entry.data[CONF_IP_ADDRESS] or None + default = entry.data.get(CONF_IP_ADDRESS) or None ): str, vol.Required( CONF_USERNAME, - default = entry.data[CONF_USERNAME] or "User" + default = entry.data.get(CONF_USERNAME) or "User" ): vol.In(["User", "Installer"]), vol.Required( CONF_PASSWORD, - default = entry.data[CONF_PASSWORD] or "" + default = entry.data.get(CONF_PASSWORD) or "" ): str, vol.Required( CONF_SCAN_INTERVAL, - default=entry.data[CONF_SCAN_INTERVAL] or DEFAULT_SCAN_INTERVAL + default=entry.data.get(CONF_SCAN_INTERVAL) or DEFAULT_SCAN_INTERVAL ): cv.positive_int, vol.Optional( ATTR_SONNEN_DEBUG, - default=entry.data[ATTR_SONNEN_DEBUG] or DEFAULT_SONNEN_DEBUG) + default=entry.data.get(ATTR_SONNEN_DEBUG) or DEFAULT_SONNEN_DEBUG) : cv.boolean, } ) if user_input is not None: - await self.async_set_unique_id(entry.data[CONF_SERIAL_NUMBER]) - self._abort_if_unique_id_configured() + if entry.data.get(CONF_SERIAL_NUMBER): + await self.async_set_unique_id(entry.data[CONF_SERIAL_NUMBER]) + self._abort_if_unique_id_configured() # noinspection PyBroadException try: my_serial = await self.hass.async_add_executor_job( diff --git a/custom_components/sonnenbatterie/manifest.json b/custom_components/sonnenbatterie/manifest.json index b411b8e..b5edf52 100644 --- a/custom_components/sonnenbatterie/manifest.json +++ b/custom_components/sonnenbatterie/manifest.json @@ -6,6 +6,7 @@ "dependencies": [], "documentation": "https://github.com/weltmeyer/ha_sonnenbatterie", "iot_class": "local_polling", + "issue_tracker": "https://github.com/weltmeyer/ha_sonnenbatterie/issues", "requirements": ["requests","sonnenbatterie>=0.3.0"], - "version": "2024.12.01" + "version": "2024.12.02" }