Skip to content

Add Grandstream Home integration#167872

Draft
wtxu-gs wants to merge 1 commit intohome-assistant:devfrom
wtxu-gs:feat/grandstream_home
Draft

Add Grandstream Home integration#167872
wtxu-gs wants to merge 1 commit intohome-assistant:devfrom
wtxu-gs:feat/grandstream_home

Conversation

@wtxu-gs
Copy link
Copy Markdown

@wtxu-gs wtxu-gs commented Apr 10, 2026

This integration adds support for Grandstream GDS/GNS/GSC devices.

Features:

  • System status sensors
  • Zeroconf discovery

Breaking change

Proposed change

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • I understand the code I am submitting and can explain how it works.
  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.
  • Any generated code has been carefully reviewed for correctness and compliance with project standards.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies a diff between library versions and ideally a link to the changelog/release notes is added to the PR description.

To help with the load of incoming pull requests:

@mawoka-myblock
Copy link
Copy Markdown
Contributor

The source for the library is missing: https://github.com/GrandstreamEngineering/grandstream_home_api

@wtxu-gs wtxu-gs force-pushed the feat/grandstream_home branch 4 times, most recently from f443b7c to aa77908 Compare April 10, 2026 08:37
@wtxu-gs
Copy link
Copy Markdown
Author

wtxu-gs commented Apr 10, 2026

The source for the library is missing: https://github.com/GrandstreamEngineering/grandstream_home_api

It is added now

@wtxu-gs wtxu-gs force-pushed the feat/grandstream_home branch from aa77908 to 8a3b791 Compare April 10, 2026 08:43
@wtxu-gs
Copy link
Copy Markdown
Author

wtxu-gs commented Apr 10, 2026

Copy link
Copy Markdown
Member

@edenhaus edenhaus left a comment

Choose a reason for hiding this comment

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

I did an initial review until I stopped as this PR is to huge. Some code needs to move to the library and also the config flow is huge. Please refactor the code and make it more readable.

Also the library needs a working workflow to deploy directly to pypi.
As 10.000 changes is to much, can we just add a single device/model in this PR and then add other models in a follow up PR. This PR needs to be a lot smaller

unique-config-entry: done

# Silver
action-exceptions: done
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please set all rules except the bronze one to todo. As they need to be evaluated after the integration was added

Comment on lines +238 to +256
async def _handle_existing_device(
hass: HomeAssistant, unique_id: str, name: str, device_type: str
) -> None:
"""Check and update existing device if found."""
device_registry = dr.async_get(hass)

for dev in device_registry.devices.values():
for identifier in dev.identifiers:
if identifier[0] == DOMAIN and identifier[1] == unique_id:
_LOGGER.info("Found existing device: %s, name: %s", dev.id, dev.name)

# Update device attributes
device_registry.async_update_device(
dev.id,
name=name,
manufacturer="Grandstream",
model=device_type,
)
return
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why is this needed?

api = await _setup_api_with_error_handling(hass, entry, device_type)

# Store API in runtime_data (required for Bronze quality scale)
entry.runtime_data = {"api": api}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Use a typed classed not a dictionary

Comment on lines +300 to +301
hass.data.setdefault(DOMAIN, {})
hass.data[DOMAIN][entry.entry_id] = {}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
hass.data.setdefault(DOMAIN, {})
hass.data[DOMAIN][entry.entry_id] = {}

Use runtime data instead

raise # Let auth failures propagate to trigger reauth flow
except Exception as e:
_LOGGER.exception("Error setting up integration")
raise ConfigEntryNotReady("Integration setup failed") from e
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should not put all code into the try catch block. Just put the code in it, which is also raising the specific exceptions

return self.device_model
return self.device_type or "Unknown"

def _register_device(self) -> None:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why are you needing this?

device_info is in the most cases enough as the device will be created and also updated. Just make sure to have a unique identifier

Comment on lines +1 to +11
"""Custom exceptions for Grandstream Home integration - re-exported from library."""

from grandstream_home_api.error import (
GrandstreamError,
GrandstreamHAControlDisabledError,
)

__all__ = [
"GrandstreamError",
"GrandstreamHAControlDisabledError",
]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
"""Custom exceptions for Grandstream Home integration - re-exported from library."""
from grandstream_home_api.error import (
GrandstreamError,
GrandstreamHAControlDisabledError,
)
__all__ = [
"GrandstreamError",
"GrandstreamHAControlDisabledError",
]

Makes no sense

{
"domain": "grandstream_home",
"name": "Grandstream Home",
"codeowners": ["@GrandstreamEngineering"],
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You should be the code owner and not a random user. If you want to add them too, then they need to comment on this PR, thats it's fine for them to be code owner

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

GrandstreamEngineering is an organization

"name": "Grandstream Home",
"codeowners": ["@GrandstreamEngineering"],
"config_flow": true,
"dependencies": [],
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Remove empty ones

)

@staticmethod
def _get_by_path(data: dict[str, Any], path: str, index: int | None = None):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Need to be in the libary

@home-assistant home-assistant bot marked this pull request as draft April 10, 2026 12:15
@home-assistant
Copy link
Copy Markdown

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants