import asyncio import logging import sys import time from datetime import datetime import aiohttp import yaml # Setup logging logging.basicConfig( level=logging.INFO, format='%(asctime)s [%(levelname)s] %(message)s', handlers=[ logging.StreamHandler(sys.stdout) ] ) _LOGGER = logging.getLogger(__name__) async def main(): _LOGGER.info("Starting Simple Addon") # Example of Home Assistant API usage async with aiohttp.ClientSession() as session: try: # Get Home Assistant info async with session.get('http://supervisor/core/info') as response: if response.status == 200: data = await response.json() _LOGGER.info(f"Home Assistant version: {data.get('version')}") except Exception as e: _LOGGER.error(f"Error connecting to Home Assistant: {str(e)}") # Keep the addon running while True: await asyncio.sleep(60) if __name__ == "__main__": try: asyncio.run(main()) except KeyboardInterrupt: _LOGGER.info("Addon stopped")