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

Smart Home Label Manager

Build a label management system for organizing smart home entities. The system should allow users to create labels, assign them to entities, and query entities by their labels.

Requirements

Label Creation and Management

Create a LabelManager class that manages labels. Each label has:

  • A unique identifier
  • A name (required)
  • An optional color (hex format like "#FF0000")
  • An optional icon

The manager should support:

  • Creating new labels with validation (name is required)
  • Retrieving a label by ID
  • Listing all available labels
  • Removing labels

Entity-Label Association

Implement functionality to:

  • Assign one or more labels to an entity (identified by entity_id)
  • Remove labels from an entity
  • Retrieve all labels assigned to a specific entity
  • Find all entities that have a specific label

Label Filtering

Implement a method to find entities based on label criteria:

  • Find entities with ALL of a given set of labels
  • Find entities with ANY of a given set of labels

Test Cases

  • Creating a label with only a name succeeds and returns a label with a generated ID @test
  • Creating a label with name, color, and icon stores all attributes correctly @test
  • Attempting to create a label without a name raises a ValueError @test
  • Assigning two labels to an entity and retrieving them returns both labels @test
  • Finding entities by label returns only entities with that label @test
  • Finding entities with ALL labels returns only entities that have all specified labels @test

Implementation

@generates

API

class LabelManager:
    """Manages labels for smart home entities."""

    def create_label(self, name: str, color: str | None = None, icon: str | None = None) -> dict:
        """
        Create a new label.

        Args:
            name: The label name (required)
            color: Optional color in hex format (e.g., "#FF0000")
            icon: Optional icon identifier

        Returns:
            Dictionary with label data including generated 'id', 'name', 'color', 'icon'

        Raises:
            ValueError: If name is not provided or is empty
        """
        pass

    def get_label(self, label_id: str) -> dict | None:
        """
        Retrieve a label by its ID.

        Args:
            label_id: The label identifier

        Returns:
            Label dictionary or None if not found
        """
        pass

    def list_labels(self) -> list[dict]:
        """
        Get all labels.

        Returns:
            List of all label dictionaries
        """
        pass

    def remove_label(self, label_id: str) -> bool:
        """
        Remove a label.

        Args:
            label_id: The label identifier

        Returns:
            True if removed, False if not found
        """
        pass

    def assign_labels_to_entity(self, entity_id: str, label_ids: list[str]) -> None:
        """
        Assign labels to an entity.

        Args:
            entity_id: The entity identifier
            label_ids: List of label IDs to assign
        """
        pass

    def remove_labels_from_entity(self, entity_id: str, label_ids: list[str]) -> None:
        """
        Remove labels from an entity.

        Args:
            entity_id: The entity identifier
            label_ids: List of label IDs to remove
        """
        pass

    def get_entity_labels(self, entity_id: str) -> list[dict]:
        """
        Get all labels assigned to an entity.

        Args:
            entity_id: The entity identifier

        Returns:
            List of label dictionaries assigned to the entity
        """
        pass

    def get_entities_with_label(self, label_id: str) -> list[str]:
        """
        Get all entities that have a specific label.

        Args:
            label_id: The label identifier

        Returns:
            List of entity IDs
        """
        pass

    def find_entities_by_labels(self, label_ids: list[str], match_all: bool = True) -> list[str]:
        """
        Find entities based on label criteria.

        Args:
            label_ids: List of label IDs to search for
            match_all: If True, entities must have ALL labels; if False, entities must have ANY label

        Returns:
            List of entity IDs matching the criteria
        """
        pass

Dependencies { .dependencies }

homeassistant { .dependency }

Provides home automation platform capabilities including label registry functionality for organizing entities with custom tags.

@satisfied-by

Version

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