CtrlK
CommunityDocumentationLog inGet started
Tessl Logo

tessl/pypi-homeassistant

tessl install tessl/pypi-homeassistant@2025.9.0

Open-source home automation platform running on Python 3.

Agent Success

Agent success rate when using this tile

69%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.19x

Baseline

Agent success rate without this tile

58%

task.mdevals/scenario-6/

Device Control Service Manager

Build a simple device control system that registers and manages services for controlling smart home devices.

Requirements

Create a Python module that implements a service manager for a smart home device controller. The system should:

  1. Register a custom service called notify_users in the alerts domain that accepts a message parameter and a list of user IDs
  2. Register a custom service called set_brightness in the lighting domain that accepts a brightness level (0-100) and validates it
  3. Provide a way to invoke these services programmatically
  4. Check whether specific services are registered before attempting to use them
  5. Support unregistering services when they are no longer needed

The service handlers should:

  • Accept service data as parameters
  • Validate input data (brightness must be between 0-100)
  • Return appropriate response data indicating success or failure
  • Use async execution patterns

Test Cases

  • Registering the alerts.notify_users service succeeds and makes it available for invocation @test
  • Calling the alerts.notify_users service with valid data executes successfully @test
  • Registering the lighting.set_brightness service with validation succeeds @test
  • Calling lighting.set_brightness with brightness 50 succeeds @test
  • Calling lighting.set_brightness with brightness 150 raises a validation error @test
  • Checking if a registered service exists returns True @test
  • Unregistering a service removes it from the registry @test

Implementation

@generates

API

import voluptuous as vol
from homeassistant.core import HomeAssistant, ServiceCall
from typing import Any, Dict

async def register_notify_service(hass: HomeAssistant) -> None:
    """Register the alerts.notify_users service."""
    pass

async def register_brightness_service(hass: HomeAssistant) -> None:
    """Register the lighting.set_brightness service with validation."""
    pass

async def call_service(hass: HomeAssistant, domain: str, service: str, service_data: Dict[str, Any]) -> None:
    """Call a registered service by domain and service name."""
    pass

def check_service_exists(hass: HomeAssistant, domain: str, service: str) -> bool:
    """Check if a service is registered."""
    pass

async def unregister_service(hass: HomeAssistant, domain: str, service: str) -> None:
    """Unregister a service from the registry."""
    pass

Dependencies { .dependencies }

homeassistant { .dependency }

Provides the service registry and core functionality for managing services.

voluptuous { .dependency }

Provides schema validation for service data.

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/homeassistant@2025.9.x
tile.json