Skip to content

Latest commit

 

History

9 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Expanding HassIO Smart Home Capabilities via Low-Code Automation Development with SmAuto

Google Summer of Code 2025 Home Assistant License: MIT SmAuto

A Google Summer of Code 2025 project that enhances SmAuto — a Domain-Specific Language (DSL) for smart environment automation — and integrates it into Home Assistant as an open-source add-on.

SmAuto enables users to define complex automation scenarios through a textual, low-code interface. This project extends the DSL with new capabilities and brings it directly into the Home Assistant ecosystem, empowering users to design and deploy sophisticated automations with minimal coding expertise.


Project Goals

Goal 1: REST Protocol Support

Extend the SmAuto DSL to support the REST protocol for accessing external data sources. This introduces a RESTSource concept in the TextX grammar, allowing automations to fetch and use data from external REST APIs.

RESTSource weather_api
    url: "https://api.weather.com"
    key: "temp"
end

Goal 2: Auxiliary DSL Concepts

Introduce new node types to enrich automation workflows:

  • Delay — Pause execution for a specified duration (Delay duration: 10s)
  • Switch — Toggle state based on conditions (Switch state: bool)
  • Compute — Perform calculations on sensor data (Compute output: float expression: "sensor1.value + sensor2.value")

Goal 3: Home Assistant Add-on Integration

Integrate SmAuto into Home Assistant as an open-source add-on, enabling users to:

  • Design automations graphically using SmAuto's low-code environment
  • Access and control Home Assistant entities directly from SmAuto models
  • Deploy automations seamlessly via MQTT as the communication bus

Architecture

┌─────────────────────────────────────────────────────┐
│                   Home Assistant                    │
│                                                     │
│  ┌──────────────┐         ┌──────────────────────┐  │
│  │  HA Entities  │◄───────►│  SmAuto Add-on       │  │
│  │  (sensors,    │  MQTT   │  (Web UI + Backend)  │  │
│  │   actuators)  │         │                      │  │
│  └──────────────┘         └──────────┬───────────┘  │
│                                      │              │
└──────────────────────────────────────┼──────────────┘
                                       │
                              ┌────────▼────────┐
                              │  MQTT Broker    │
                              │  (Mosquitto)    │
                              └────────┬────────┘
                                       │
                              ┌────────▼────────┐
                              │  SmAuto REST    │
                              │  API Server     │
                              │  (Code Gen)     │
                              └─────────────────┘

Components:

  • SmAuto REST API Server — A FastAPI server (Docker) that receives SmAuto DSL models, generates Python automation scripts, and returns the code via REST API
  • MQTT Broker (Mosquitto) — Central message bus bridging Home Assistant entities and SmAuto automation scripts
  • SmAuto Add-on — Home Assistant add-on providing a web-based interface for authoring and deploying SmAuto automations
  • Home Assistant Entities — Sensors and actuators mapped to SmAuto entities via MQTT topics

Repository Structure

.
├── Dockerfile                  # Add-on Docker image definition
├── config.yaml                 # Home Assistant add-on configuration
├── run.sh                      # Add-on startup script
├── examples/
│   ├── automations.yaml        # Example HA automations for MQTT bridging
│   └── smauto_model.auto       # Example SmAuto DSL model
├── LICENSE
└── README.md

SmAuto DSL Example

SmAuto uses a human-readable DSL to define automation scenarios. Here is an example that turns on a light when the temperature is high, and activates a thermostat when it's cold:

Metadata
    name: HomeAssistantTestModel
    version: "1.0.0"
    author: "Your Name"
end

Broker<MQTT> home_broker
    host: "localhost"
    port: 1883
    auth:
        username: ""
        password: ""
end

Entity weather_station
    type: sensor
    topic: "porch.weather_station"
    broker: home_broker
    attributes:
        - temperature: float
        - humidity: int
end

Entity office_light
    type: actuator
    topic: "office.light"
    broker: home_broker
    attributes:
        - power: bool
        - brightness: int
end

Automation turn_on_light_when_hot
    condition:
        (weather_station.temperature > 28) AND (office_light.power is false)
    enabled: true
    continuous: true
    actions:
        - office_light.power: true
        - office_light.brightness: 80
end

See examples/smauto_model.auto for the full model including thermostat control.


Getting Started

Prerequisites

1. Start the MQTT Broker

docker run -d --name mosquitto -p 1883:1883 eclipse-mosquitto mosquitto -c /mosquitto-no-auth.conf

2. Start the SmAuto REST API Server

# Clone and build from the SmAuto repository
git clone https://github.com/robotics-4-all/smauto.git
cd smauto
docker build -t smauto .
docker run -d --name smauto-api -p 8080:8080 smauto

3. Install the SmAuto Add-on

Build and install the add-on in your Home Assistant instance:

# From this repository's root
docker build -t smauto-addon-local .

For local development with Home Assistant Core, refer to the HA add-on development docs.

4. Configure MQTT Bridging

Add the example automations from examples/automations.yaml to your Home Assistant automations.yaml to bridge sensor and actuator events between HA and MQTT. Update topics and entity IDs to match your devices.


How It Works

  1. Author — Write automation logic in SmAuto DSL (.auto files)
  2. Generate — The SmAuto REST API compiles the DSL model into executable Python code
  3. Bridge (HA → SmAuto) — HA automations publish sensor state changes to MQTT topics
  4. Execute — The generated script subscribes to sensor topics, evaluates conditions, and publishes actuator commands
  5. Bridge (SmAuto → HA) — HA automations listen for MQTT actuator commands and call the corresponding HA services

Credits

License

This project is licensed under the MIT License — see LICENSE for details.

About

Expanding HassIO Smart Home Capabilities via Low-Code Automation Development with SmAuto

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages