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-4/

Smart Home Device Manager

A device management system for organizing and tracking smart home devices with support for device metadata, hierarchical relationships, and area assignments.

Requirements

Implement a device manager that handles device registration, updates, and organization for a smart home system. The system should track device information including manufacturer details, software versions, and location assignments.

Device Registration

  • Register new devices with unique identifiers and connection information
  • Support multiple connection types (MAC address, Zigbee, Bluetooth)
  • Store device metadata including manufacturer, model, and version information
  • Assign devices to specific areas (rooms or zones)
  • Track configuration entry associations for each device

Device Updates

  • Update device metadata including name, area assignment, and version information
  • Support user-defined custom names separate from default names
  • Merge additional identifiers and connections into existing device records
  • Handle software and hardware version updates

Device Queries

  • Retrieve devices by their unique identifiers or connection information
  • List all registered devices
  • Query device relationships including parent devices and configuration entries

Device Removal

  • Remove devices from the registry
  • Ensure proper cleanup of device relationships

Test Cases

  • Registering a new Zigbee temperature sensor with manufacturer "Acme", model "TempSense Pro", in the "Living Room" area returns a device entry with all specified attributes @test
  • Updating a device's area from "Bedroom" to "Kitchen" successfully changes the area assignment @test
  • Retrieving a device by its MAC address connection returns the correct device entry @test
  • Removing a device by its ID successfully removes it from the registry @test

Implementation

@generates

API

from typing import Optional, Set, Tuple

class DeviceManager:
    """Manages smart home device registration and organization."""

    def __init__(self, hass):
        """Initialize device manager.

        Args:
            hass: Home Assistant instance
        """
        pass

    async def register_device(
        self,
        config_entry_id: str,
        connections: Optional[Set[Tuple[str, str]]] = None,
        identifiers: Optional[Set[Tuple[str, str]]] = None,
        manufacturer: Optional[str] = None,
        model: Optional[str] = None,
        name: Optional[str] = None,
        sw_version: Optional[str] = None,
        hw_version: Optional[str] = None,
        area_id: Optional[str] = None,
        via_device: Optional[Tuple[str, str]] = None,
    ) -> dict:
        """Register a new device or retrieve existing device.

        Args:
            config_entry_id: Configuration entry ID
            connections: Set of device connections as (type, value) tuples
            identifiers: Set of device identifiers as (domain, id) tuples
            manufacturer: Device manufacturer name
            model: Device model name
            name: Device name
            sw_version: Software version
            hw_version: Hardware version
            area_id: Area ID for location assignment
            via_device: Parent device identifier tuple

        Returns:
            Device entry dictionary with device information
        """
        pass

    async def update_device(
        self,
        device_id: str,
        area_id: Optional[str] = None,
        name_by_user: Optional[str] = None,
        sw_version: Optional[str] = None,
        hw_version: Optional[str] = None,
        merge_identifiers: Optional[Set[Tuple[str, str]]] = None,
        merge_connections: Optional[Set[Tuple[str, str]]] = None,
    ) -> dict:
        """Update device information.

        Args:
            device_id: Device ID to update
            area_id: New area ID
            name_by_user: User-defined custom name
            sw_version: Updated software version
            hw_version: Updated hardware version
            merge_identifiers: Additional identifiers to merge
            merge_connections: Additional connections to merge

        Returns:
            Updated device entry dictionary
        """
        pass

    async def get_device(
        self,
        identifiers: Optional[Set[Tuple[str, str]]] = None,
        connections: Optional[Set[Tuple[str, str]]] = None,
    ) -> Optional[dict]:
        """Retrieve device by identifiers or connections.

        Args:
            identifiers: Device identifiers to search for
            connections: Device connections to search for

        Returns:
            Device entry dictionary or None if not found
        """
        pass

    async def remove_device(self, device_id: str) -> None:
        """Remove device from registry.

        Args:
            device_id: Device ID to remove
        """
        pass

    def get_all_devices(self) -> dict:
        """Get all registered devices.

        Returns:
            Dictionary mapping device IDs to device entries
        """
        pass

Dependencies { .dependencies }

homeassistant { .dependency }

Provides device registry functionality for managing smart home devices.

@satisfied-by

Version

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