Open-source home automation platform running on Python 3.
69
Build a simple event-driven notification system that tracks device state changes and sends notifications when specific conditions are met.
Your system should:
Create a NotificationManager class with the following functionality:
"notification_ready" event (with device name in event data) when a device reaches 3 state changes"notification_ready" event is fired with the device name @test@generates
from homeassistant.core import HomeAssistant, Event
class NotificationManager:
"""Manages device state change notifications using the event bus."""
def __init__(self, hass: HomeAssistant) -> None:
"""
Initialize the notification manager.
Args:
hass: Home Assistant instance with access to the event bus
"""
pass
async def start_tracking(self) -> None:
"""Start listening for state change events."""
pass
def register_one_time_listener(self, callback) -> None:
"""
Register a listener that will be called once when notification_ready event fires.
Args:
callback: Async function to call when the event fires
"""
pass
def fire_test_event(self, event_type: str, event_data: dict) -> None:
"""
Fire an event from a synchronous context.
Args:
event_type: Type of event to fire
event_data: Data to include with the event
"""
passProvides the event bus system for event-driven communication.
Install with Tessl CLI
npx tessl i tessl/pypi-homeassistantdocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10