Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* text=auto eol=lf
*.png binary
*.jpg binary
55 changes: 55 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: CI

on:
push:
branches: [main]
pull_request:
schedule:
- cron: "0 5 * * *"

permissions:
contents: read

concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true

jobs:
hassfest:
name: Hassfest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: home-assistant/actions/hassfest@master

hacs:
name: HACS
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: hacs/action@22.5.0
with:
category: integration
# The brand assets are only required for the HACS default repository list.
ignore: brands

quality:
name: Ruff, mypy, pytest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v7
with:
python-version: "3.14"
cache: pip
cache-dependency-path: requirements_test.txt
- name: Install dependencies
run: pip install -r requirements_test.txt
- name: Ruff lint
run: ruff check .
- name: Ruff format
run: ruff format --check .
- name: mypy
run: mypy custom_components
- name: pytest
run: pytest
7 changes: 4 additions & 3 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
## Project Overview
Official Home Assistant custom integration (`smart_frame_engine`) for **Smart Frame Engine** (`[https://github.com/ant1fr/Smart-Frame-Engine](https://github.com/ant1fr/Smart-Frame-Engine)`), installable via HACS (Home Assistant Community Store) and manual installation.

- **Target Home Assistant Core:** 2026.x+ (Python 3.12+)
- **Target Home Assistant Core:** 2026.1.0+ (Python 3.13.2+; CI and local tests run on Python 3.14, which latest HA and `pytest-homeassistant-custom-component` require)
- **Integration Domain:** `smart_frame_engine`
- **IoT Class:** `local_polling` (with Zeroconf mDNS discovery on `_smartframe._tcp.local.`)
- **Supported Server Contract:** `SUPPORTED_API_VERSION = 1`
- **Supported Server Contract:** `SUPPORTED_API_VERSION = 1` (contract v1.1: the engine's `instance_id` from `GET /api/health` / Zeroconf TXT is the config entry `unique_id` and the `DeviceInfo` identifier)
- **Upstream API Contract (Single Source of Truth):**
- Human-readable contract: `[https://github.com/ant1fr/Smart-Frame-Engine/blob/main/docs/API_CONTRACT.md](https://github.com/ant1fr/Smart-Frame-Engine/blob/main/docs/API_CONTRACT.md)`
- Machine-readable OpenAPI schema: `[https://github.com/ant1fr/Smart-Frame-Engine/blob/main/docs/openapi.json](https://github.com/ant1fr/Smart-Frame-Engine/blob/main/docs/openapi.json)`
Expand All @@ -33,6 +33,7 @@ Official Home Assistant custom integration (`smart_frame_engine`) for **Smart Fr
- `tests/` — `pytest` + `pytest-homeassistant-custom-component`
- `hacs.json` — HACS metadata
- `pyproject.toml` — `ruff`, `mypy`, `pytest` configuration
- `requirements_test.txt` — test/lint dependencies (`pytest-homeassistant-custom-component`, `ruff`, `mypy`)

## Development, Quality & GitHub Rules (CRITICAL)

Expand Down Expand Up @@ -66,4 +67,4 @@ Official Home Assistant custom integration (`smart_frame_engine`) for **Smart Fr
- `ruff check .`
- `ruff format --check .`
- `mypy custom_components`
- `pytest`
- `pytest` — HA's test plugin imports `fcntl`, so run it on Linux/macOS/WSL (not native Windows); `ruff` and `mypy` run anywhere
46 changes: 46 additions & 0 deletions custom_components/smart_frame_engine/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
"""The Smart Frame Engine integration."""

from __future__ import annotations

from homeassistant.const import CONF_API_KEY, CONF_HOST, CONF_PORT, Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers.aiohttp_client import async_get_clientsession

from .api import SmartFrameClient
from .const import CONF_PATH, DEFAULT_PATH
from .coordinator import (
SmartFrameConfigEntry,
SmartFrameCoordinator,
async_delete_compatibility_issue,
)

# Entity platforms arrive in a later milestone; the coordinator and device already work.
PLATFORMS: list[Platform] = []


async def async_setup_entry(hass: HomeAssistant, entry: SmartFrameConfigEntry) -> bool:
"""Set up one engine from a config entry."""
client = SmartFrameClient(
async_get_clientsession(hass),
entry.data[CONF_HOST],
entry.data[CONF_PORT],
entry.data.get(CONF_PATH, DEFAULT_PATH),
entry.data.get(CONF_API_KEY),
)
coordinator = SmartFrameCoordinator(hass, entry, client)
# Raises ConfigEntryNotReady (unreachable / incompatible) or ConfigEntryAuthFailed (401).
await coordinator.async_config_entry_first_refresh()
entry.runtime_data = coordinator

await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
return True


async def async_unload_entry(hass: HomeAssistant, entry: SmartFrameConfigEntry) -> bool:
"""Unload a config entry."""
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)


async def async_remove_entry(hass: HomeAssistant, entry: SmartFrameConfigEntry) -> None:
"""Drop the compatibility Repair issue together with the entry."""
async_delete_compatibility_issue(hass, entry.entry_id)
Loading
Loading