Initial commit of Simple Home Assistant Addon with web interface

This commit is contained in:
Manu
2025-06-01 12:04:22 +02:00
commit 3d987c3eb6
12 changed files with 660 additions and 0 deletions

View File

@ -0,0 +1,21 @@
FROM homeassistant/amd64-base:latest
# Install basic dependencies
RUN apt-get update && \
apt-get install -y \
python3-pip \
python3-dev \
build-essential \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Copy addon files
COPY requirements.txt /
COPY run.sh /
COPY config.yaml /
# Set permissions
RUN chmod +x /run.sh
# Start the addon
CMD ["/run.sh"]

View File

@ -0,0 +1,16 @@
# Simple Home Assistant Addon
A basic Home Assistant addon template.
## Installation
1. Download this addon from the Home Assistant Addon Store
2. Install it through the Home Assistant Supervisor interface
## Configuration
No configuration is required for this basic addon.
## Usage
This addon provides a simple example of how to create a Home Assistant addon.

View File

@ -0,0 +1,42 @@
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")

View File

@ -0,0 +1,4 @@
requests==2.31.0
aiohttp==3.8.5
asyncio==3.4.3
pyyaml==6.0.1

View File

@ -0,0 +1,8 @@
#!/bin/bash
# Set environment variables
export PYTHONPATH=/usr/local/lib/python3.9/site-packages
# Start the addon
python3 -m pip install -r /requirements.txt
python3 /app/main.py