Skip to content

Update config_flow.py#59

Open
LukaszP2 wants to merge 1 commit into
hass-agent:2.1.2-beta1from
LukaszP2:patch-1
Open

Update config_flow.py#59
LukaszP2 wants to merge 1 commit into
hass-agent:2.1.2-beta1from
LukaszP2:patch-1

Conversation

@LukaszP2

Copy link
Copy Markdown

This PR fixes a critical "500 Internal Server Error" in Home Assistant 2024.x/2025.x/2026.x caused by an AttributeError in config_flow.py.

This PR fixes a critical "500 Internal Server Error" in Home Assistant 2024.x/2025.x/2026.x caused by an AttributeError in config_flow.py.
@amadeo-alex amadeo-alex changed the base branch from main to 2.1.2-beta1 January 14, 2026 07:25
@amadeo-alex

Copy link
Copy Markdown

Hello, thank you for the PR, could you please TL;DR me a way to reproduce the described issue?
I haven't had my cup of coffee yet today but I don't believe I encountered it on 2024 and 2025 versions of HA.

@LukaszP2

Copy link
Copy Markdown
Author

It is when you want to reconfig your settings

@amadeo-alex

Copy link
Copy Markdown

Reconfigure as like this?
obraz

I just changed it for two devices and there was no error of any kind.

@LukaszP2

Copy link
Copy Markdown
Author

Yes, ther...
image

@amadeo-alex

Copy link
Copy Markdown

I've downloaded 2.1.1 version of the integration but it still works correctly. Could you please check if there are any errors in the logs and show me those if so?

@amadeo-alex

Copy link
Copy Markdown

Let's move the investigation to #61

@amadeo-alex

Copy link
Copy Markdown

Could you please try the same? #61

@amadeo-alex amadeo-alex added the stale needs an update to keep alive label Jun 4, 2026
v1k70rk4 referenced this pull request in v1k70rk4/HASS.Agent.NET10-Integration Jun 5, 2026
### Summary

Full modernization of the HASS.Agent custom integration to ensure compatibility with Home Assistant 2026.x, fix known bugs, and align with current HA development best practices.

---

### 🐛 Bug Fixes

- **Fix Configure button 500 error** (PR #59 / Issue #61) — Removed broken `OptionsFlowHandler.__init__` that overwrote the parent without calling `super()`, preventing `self.config_entry` from being injected by the framework.
- **Fix notify platform unload error** — The old `"ValueError: Config entry was never loaded!"` is gone because notify now uses standard `async_forward_entry_setups` instead of `discovery.async_load_platform`.
- **Fix thumbnail view crash** — Returns 404 instead of crashing with `AttributeError` when an invalid entity ID is requested.

### 🔄 HA 2026.x Compatibility

- **`FlowResult` → `ConfigFlowResult` / `OptionsFlowResult`** — Replace deprecated type from `data_entry_flow`.
- **`BaseNotificationService` → `NotifyEntity`** — Full rewrite of `notify.py` from legacy service-based pattern to modern entity-based `NotifyEntity` with standard `async_setup_entry`.
- **`utcnow()` → `datetime.now(UTC)`** — Replace deprecated `homeassistant.util.dt.utcnow()` with Python 3.11+ native approach.

### ⚡ Performance

- **Synchronous `requests` → async `aiohttp`** — All HTTP calls in `__init__.py`, `config_flow.py`, and `notify.py` now use `async_get_clientsession`. The event loop is no longer blocked by synchronous I/O.

### 🛡️ Error Handling

- `async_setup_entry` now returns `False` with an error log if the device is unreachable, instead of crashing.
- Config flow catches specific `ClientError`/`TimeoutError` instead of bare `Exception`.
- Notification HTTP error handling simplified from 60+ line status code switch to concise `response.ok` check.

### 🧹 Code Cleanup

- Removed ~15 unused imports (`asyncio`, `Coroutine`, `suppress`, `Path`, `cast`, `SOURCE_IMPORT`, `SERVICE_RELOAD`, `slugify`, `discovery`, `requests`, etc.)
- Removed commented-out code blocks (notify unload workaround)
- Simplified platform unload to single `async_unload_platforms` call with a list

### 📦 Repository & HACS

- All GitHub links updated to `v1k70rk4/HASS.Agent-Integration`
- `codeowners` updated to `@v1k70rk4`
- HACS version set to `20260601.1`
- Minimum HA version bumped to `2024.1`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale needs an update to keep alive

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants