Home Assistant Developer Documentation

repository·master·Indexed 19 days ago

https://github.com/home-assistant/developers.home-assistant

Source files and guides for Home Assistant development. Includes instructions for setting up local development environments via VS Code devcontainers or Node.js/Yarn, guidelines for contributing using AI, and technical documentation on creating custom panels, configuring OAuth2 authentication, and structuring custom components.

Tokens
415.1K
Snippets
988
Records
1.7K
Agent score
63%

What's inside developers.home-assistant

  1. Introduction to Home Assistant Apps

    master

    Apps (formerly known as add-ons) allow users to extend Home Assistant functionality. They are used to run applications that integrate with Home Assistant (such as an MQTT broker) or to provide services like sharing configuration via Samba for easy editing.

    Apps are implemented as container images published to registries such as GitHub Container Registry or Docker Hub. Users configure these apps via the Supervisor panel within Home Assistant.

  2. Overview of Native App Integration with Home Assistant

    master

    Building a native Home Assistant app involves establishing a secure connection to a user's Home Assistant instance and providing a seamless interface for controlling their smart home. This guide covers the core capabilities required for a functional integration:

    • Authentication: Allowing users to connect and authenticate with their specific Home Assistant instance.
    • Telemetry: Sending device information and location data back to the Home Assistant server.
    • Remote Control: Executing service actions, firing events, and rendering templates remotely.
    • Webview Control: Providing a view to control the home via an authenticated webview.
  3. General Android development principles

    master

    Follow these core principles when developing for Android:

    • SOLID: Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, Dependency Inversion.
    • KISS: Keep It Simple, Stupid.
    • DRY: Don't Repeat Yourself.
    • Keep it direct: Avoid premature abstractions. Only abstract when a second real use case appears or to hide implementation details from other modules.
    • Root cause before fix: Address the actual cause of a bug rather than patching symptoms with speculative workarounds.
  4. Android Architecture Overview

    master
    The Home Assistant Android app is built with a PWA-first philosophy, using a WebView as its centerpiece to integrate with the Home Assistant frontend. While the core is a WebView, the app incorporates native capabilities for tasks like background sensor data collection. The codebase is written entirely in Kotlin and follows Google's recommended Android architecture (inspired by the NowInAndroid repository).
  5. Ways to contribute to Home Assistant Android

    master

    Contributions to the Home Assistant Android project are categorized into several areas:

    • Code contributions: Fixing bugs, implementing new features, or optimizing performance.
    • Code reviews: Providing constructive feedback on pull requests from other developers.
    • Testing: Verifying app stability and functionality across various Android devices.
    • Documentation: Writing and maintaining clear, concise guides.
    • Beta testing: Joining the Google Play beta program to identify issues before production releases.
    • Feedback: Providing ideas and suggestions for app improvements.
  6. Access the Home Assistant Design Portal

    master

    The Home Assistant design portal (also referred to as the "gallery" in the frontend repository) is a central resource for frontend design specifications. It provides information on:

    • Reusable UI components: Documentation and visual references for components.
    • Dashboard cards: Various configurations and states for cards.
    • Theme comparison: Tools to compare components and cards between light and dark themes.
    • Wording guidelines: Specific notes regarding terminology used within Home Assistant.

    You can access the live portal at https://design.home-assistant.io.

  7. Explore Home Assistant Intents

    master

    Home Assistant uses an intent system to process commands. For detailed implementation and usage, refer to the Home Assistant Core documentation for the following areas:

    • Built-in intents: A list of intents natively supported by the system.
    • Conversation API: How to send text commands to Home Assistant and receive responses.
    • Intent Handlers: How to register new intents to extend Home Assistant's capabilities.
    • Firing Intents: How to trigger intents manually if you are using custom sentence matching logic.
  8. Identify Apple platform targets in the Home Assistant iOS repository

    master

    The Home Assistant iOS repository is a multi-target workspace. A single change can affect multiple surfaces. When developing, you must identify which target your changes impact to ensure proper validation and testing across the following surfaces:

    • Main App: The primary iPhone and iPad application.
    • Widgets and App Intents: Home Screen widgets and system integrations.
    • Apple Watch: Watch-specific actions, notifications, and complications.
    • CarPlay: Templates, list items, and action execution for vehicles.
    • Notification Extensions: Rich push handling and command execution.
    • Extensions: Share and Matter extensions.
    • macOS: macOS-specific bridge code.
    • Supporting Packages: Standalone Swift packages for push services.
  9. Experimental support for Hardkernel ODROID-C4

    master

    Home Assistant support for the Hardkernel ODROID-C4 is currently considered experimental. It relies heavily on configurations used for the Odroid-C2 and N2 due to SoC similarities and comparable Linux kernel support.

    While support is experimental, the following features have been tested and confirmed to work:

    • Booting from SD
    • Booting from eMMC
    • Obtaining the MAC address from eFuse

    For additional configuration details, refer to the documentation for the ODROID-C2 and Odroid-N2, as much of that information is applicable to the C4.

  10. Understand the Home Assistant frontend architecture

    master

    The Home Assistant frontend is built using web components, which encapsulate templates, styling, and logic into composable HTML tags. The architecture is divided into four primary layers:

    1. Bootstrap (src/entrypoints/core.ts): The initial script that handles authentication and establishes the WebSocket connection with the backend.
    2. App shell (src/entrypoints/app.ts): Loads the <home-assistant> root element, initializes application state, and handles top-level navigation.
    3. Panels (src/panels/): Represents individual pages (e.g., 'states', 'map', 'logbook'). Components can register additional panels.
    4. Dialogs (src/dialogs): Used for information flows and data entry (e.g., the 'entity more info' dialog) that can be triggered from any page.