Skip to content

Updated to new HA standards, and added ssl support#21

Open
arnonm wants to merge 4 commits intoshaiu:mainfrom
arnonm:main
Open

Updated to new HA standards, and added ssl support#21
arnonm wants to merge 4 commits intoshaiu:mainfrom
arnonm:main

Conversation

@arnonm
Copy link
Copy Markdown

@arnonm arnonm commented Apr 23, 2026

No description provided.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds support for custom ports and SSL configurations to the Technicolor integration, including a new options flow for post-setup adjustments. It also implements entry unloading and refines logging levels. Review feedback identifies a critical bug where ConfigEntryNotReady is returned instead of raised, a potential KeyError during unloading, and the use of protected members from an external library, which poses a maintenance risk.

Comment thread custom_components/technicolor/router.py Outdated
Comment on lines 57 to 61
try:
await self.loop.run_in_executor(None, self._api.authenticate)
except Exception as e:
_LOGGER.exception("Failed to connect to Technicolor", e)
except Exception:
_LOGGER.exception("Failed to connect to Technicolor")
return ConfigEntryNotReady
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The setup method returns the ConfigEntryNotReady exception class instead of raising it. In Home Assistant, ConfigEntryNotReady should be raised during the setup process to signal that the integration should retry later (e.g., if the device is temporarily offline). Returning it causes the setup to proceed as if it succeeded, which will lead to errors when the integration attempts to use the unauthenticated API.

Suggested change
try:
await self.loop.run_in_executor(None, self._api.authenticate)
except Exception as e:
_LOGGER.exception("Failed to connect to Technicolor", e)
except Exception:
_LOGGER.exception("Failed to connect to Technicolor")
return ConfigEntryNotReady
try:
await self.loop.run_in_executor(None, self._api.authenticate)
except Exception:
_LOGGER.exception("Failed to connect to Technicolor")
raise ConfigEntryNotReady

Comment on lines +68 to +69
router = hass.data[DOMAIN].pop(entry.entry_id)[DOMAIN]
router.async_unload()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Directly popping from hass.data[DOMAIN] using the entry_id can raise a KeyError if the entry was not fully initialized or if it has already been removed. It is safer to handle the case where the entry ID is missing.

Suggested change
router = hass.data[DOMAIN].pop(entry.entry_id)[DOMAIN]
router.async_unload()
router = hass.data[DOMAIN].pop(entry.entry_id, {}).get(DOMAIN)
if router:
router.async_unload()

Comment on lines +53 to +55
self._api._uri = f"{scheme}://{self._host}:{self._port}"
if self._use_ssl and not self._verify_ssl:
self._api._br.session.verify = False
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Accessing and modifying protected members of an external library (like _uri and _br in TechnicolorGateway) is risky and can lead to breakage if the library's internal implementation changes. It is better to use public APIs if available, or consider contributing the necessary SSL support to the upstream library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant