Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions homeassistant/components/homematic/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
)
from homeassistant.core import HomeAssistant, ServiceCall
from homeassistant.helpers import config_validation as cv, discovery
from homeassistant.helpers.service import async_register_admin_service
from homeassistant.helpers.typing import ConfigType
from homeassistant.util.async_ import run_callback_threadsafe

from .const import (
ATTR_ADDRESS,
Expand Down Expand Up @@ -381,12 +383,15 @@ def _service_handle_install_mode(service: ServiceCall) -> None:

homematic.setInstallMode(interface, t=time, mode=mode, address=address)

hass.services.register(
run_callback_threadsafe(
hass.loop,
async_register_admin_service,
hass,
DOMAIN,
Comment on lines +386 to 390
Copy link

Copilot AI Apr 26, 2026

Choose a reason for hiding this comment

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

Add an integration test that verifies homematic.set_install_mode is rejected for non-admin users (and allowed for admin users) when called with a user context, to prevent regressions in the new admin-only behavior.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@copilot apply changes based on this feedback

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Added two integration tests in tests/components/homematic/test_init.py (commit dd6c467):

  • test_set_install_mode_non_admin_rejected – calls the service with a read-only user context and asserts Unauthorized is raised.
  • test_set_install_mode_admin_allowed – calls the service with an admin user context, asserts it succeeds, and verifies setInstallMode was called with the correct arguments ("ccu2", t=60, mode=1, address=None).

SERVICE_SET_INSTALL_MODE,
_service_handle_install_mode,
schema=SCHEMA_SERVICE_SET_INSTALL_MODE,
)
SCHEMA_SERVICE_SET_INSTALL_MODE,
).result()

def _service_put_paramset(service: ServiceCall) -> None:
"""Service to call the putParamset method on a HomeMatic connection."""
Expand Down