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

Device Status Monitor

A system that monitors multiple IoT device endpoints asynchronously and reports their status updates in real-time.

Capabilities

Monitor multiple devices concurrently

  • The monitor initializes with a Home Assistant instance and can track multiple device endpoints @test
  • Device polling operations run concurrently without blocking the main event loop @test

Handle blocking I/O operations

  • Device status checks that involve blocking I/O (simulated network calls) are executed properly without blocking the event loop @test
  • Multiple blocking operations can run concurrently in the thread pool @test

Track background tasks

  • Background monitoring tasks are properly tracked and can be monitored for completion @test
  • All background tasks are automatically cleaned up when the monitor stops @test

Report status updates

  • Status updates from devices are collected and made available to callers @test
  • The monitor correctly handles devices that respond with different status values @test

Implementation

@generates

Implement a DeviceMonitor class that manages concurrent device status monitoring using Home Assistant's background task management capabilities.

The monitor should:

  • Accept a Home Assistant instance in its constructor
  • Provide a method to start monitoring a list of device URLs
  • Poll each device endpoint every 2 seconds (simulated)
  • Handle both async operations (for coordination) and blocking operations (for simulated network I/O)
  • Track all background tasks properly
  • Provide a method to get the latest status of all devices
  • Provide a method to stop monitoring and cleanup tasks

Simulated device polling should use time.sleep() to represent blocking I/O operations.

API

from homeassistant.core import HomeAssistant
from typing import Dict, List

class DeviceMonitor:
    """Monitors multiple device endpoints and reports their status."""

    def __init__(self, hass: HomeAssistant):
        """Initialize the device monitor.

        Args:
            hass: Home Assistant instance
        """
        pass

    def start_monitoring(self, device_urls: List[str]) -> None:
        """Start monitoring the specified device URLs.

        Args:
            device_urls: List of device endpoint URLs to monitor
        """
        pass

    def get_device_status(self) -> Dict[str, str]:
        """Get the latest status for all monitored devices.

        Returns:
            Dictionary mapping device URL to its latest status
        """
        pass

    async def stop_monitoring(self) -> None:
        """Stop monitoring all devices and cleanup background tasks."""
        pass

Dependencies { .dependencies }

homeassistant { .dependency }

Provides home automation platform capabilities including background task management.

Version

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