Homeassisstant CLI
  • Go 97.6%
  • Makefile 1.3%
  • JavaScript 0.7%
  • Dockerfile 0.4%
Find a file
renovate bot c52779110a
All checks were successful
CI Pipeline / build (push) Successful in 41s
CI / build (push) Successful in 6s
pre-commit-check / pre-commit (push) Successful in 4s
Release / release (push) Successful in 10s
CI Pipeline / trivy_scan (push) Successful in 32s
Merge pull request 'chore(deps): update pre-commit hook bridgecrewio/checkov to v3.2.500' (#53) from renovate-bridgecrewio-checkov-3-x into main
2026-02-02 16:34:08 +00:00
.beads fix: align status counts and filters 2026-01-31 12:00:38 +01:00
.forgejo/workflows chore(docker): update aquasec/trivy docker tag to v0.69.0 2026-01-30 12:07:39 +00:00
adapters chore: streamline agent guide and handle close errors 2026-01-31 11:31:29 +01:00
app feat: add message command and configurable timeout 2026-01-31 17:20:53 +01:00
cmd feat: add message command and configurable timeout 2026-01-31 17:20:53 +01:00
domain feat: add errorlog function 2025-11-30 01:55:10 +01:00
internal feat: run CallService integration test only on defined hosts 2025-12-06 07:17:12 +01:00
pkg/utils feat: add pre-commit hooks and improve CLI functionality 2025-11-23 10:49:17 +01:00
ports feat: add update check command 2025-12-06 08:31:28 +01:00
.envrc feat: add integration test 2025-11-30 10:29:31 +01:00
.gitattributes chore: add beads repo configuration 2026-01-31 11:38:31 +01:00
.gitignore fix: bin folder 2025-11-23 11:27:01 +01:00
.golangci-lint.yml chore: improve .golangci-lint settings 2025-12-02 20:19:26 +01:00
.markdownlint.json fix: please markdown linter 2025-12-05 17:39:24 +01:00
.pre-commit-config.yaml chore(deps): update pre-commit hook bridgecrewio/checkov to v3.2.500 2026-02-01 14:07:59 +00:00
AGENTS.md docs: add ralph workflow guidance 2026-01-31 11:36:32 +01:00
CHANGELOG.md chore(release): 1.22.0 [skip ci] 2026-01-31 17:21:25 +01:00
Dockerfile chore(docker): update golang:1.25-alpine docker digest to 98e6cff 2026-01-29 22:07:25 +00:00
go.mod fix(deps): update module github.com/spf13/cobra to v1.10.2 2025-12-04 02:05:50 +00:00
go.sum docs: add comprehensive agent guidelines document 2025-12-05 07:47:48 +01:00
main.go feat: add message command and configurable timeout 2026-01-31 17:20:53 +01:00
main_test.go feat: improve unit test for main.go 2025-12-02 17:46:25 +01:00
Makefile feat: improve make test command 2025-12-05 20:45:04 +01:00
README.md docs: add architecture overview 2025-11-30 08:55:09 +01:00
release.config.mjs feat: add CI/CD workflows and improve HA service logic 2025-11-24 06:43:21 +01:00
renovate.json chore(deps): add renovate.json 2025-11-24 08:05:58 +00:00

ha-cli

ha-cli is a command-line tool for controlling Home Assistant. It allows listing devices, turning entities on and off, and supports wildcards and domain filters.


Features

  • List all entities in Home Assistant (device list)
  • Filter by domains or wildcards (device list light decke*)
  • Display all domains (device list --domains)
  • Turn entities on and off (device turn-on/turn-off)
  • Auto-completion of entity IDs in shells (Bash, Zsh)
  • Support for Home Assistant API tokens via environment variables

Architecture

  • adapters/ → Outbound + Inbound Adapter (HTTP, CLI, DB, Logger …)
  • app/ → Application Layer (Use-Cases)
  • domain/ → Business Domain (Entities, Aggregate Roots, Policies)
  • ports/ → Ports/Interfaces (Input + Output Ports)
  • cmd/ → Eingänge (Cobra Commands, CLI-Parsing etc.)
  • internal/ → private Helper, die NICHT Teil der Architektur sind
  • pkg/ → Public Libraries (optional)
  • main.go → Composition Root (Wiring)
Ordner Rolle im Hexagon Darf wen kennen?
domain/ Zentrum (Entities, Regeln) kennt niemand
ports/ Ports (Interfaces) darf domain kennen
app/ Use-Cases kennt domain + ports
adapters/ Adapter implementieren Ports kennt ports, nicht app/domain
cmd/ Primäre Adapter (CLI) kennt app
main.go Composition Root kennt ALLES (darf das!)
internal/ Hilfen abhängig vom Inhalt

Overview

                     +----------------------+
   CLI (cobra) ----> |        cmd/          | (Primary Adapter)
                     +----------+-----------+
                                |
                                v
                     +----------------------+
                     |        app/          | (Use Cases)
                     +----------+-----------+
                                |
                                v
                   +---------------------------+
                   |          ports/           | (Input/Output Ports)
                   +----------+----------------+
                     /                     \
                    v                       v
     +-------------------------+     +----------------------------+
     | adapters/logger         |     | adapters/homeassistant_http|
     | (Logger implementation) |     |  (HTTP implementation)     |
     +-------------------------+     +----------------------------+

                       Core domain:
                       +---------------+
                       |    domain/    |
                       +---------------+

Installation

# With Go
go install git.bueraner.de/murdoc/ha-cli@latest

Configuration

Set the environment variables:

export HA_BASE_URL="http://homeassistant.local:8123"
export HA_TOKEN="Your_Long_HomeAssistant_Token"
# Optional: Load token from file
export HA_TOKEN_FILE="/path/to/token.txt"

Usage

List devices

# All devices
ha-cli device list

# List only lights
ha-cli device list light

# List only switches with "decken" in the name
ha-cli device list switch decken

# Display all domains
ha-cli device list --domains

Control devices

# Turn on an entity
ha-cli device turn-on switch.eg_wz_wled_decke

# Turn off an entity
ha-cli device turn-off light.wohnzimmer

Wildcards and multiple filters

# All switches with 'wled' in the name
ha-cli device list switch wled*

# Lights on the ceiling
ha-cli device list light decken*

Enable shell completion

# Bash
source <(ha-cli completion bash)

# Zsh
autoload -U compinit; compinit
source <(ha-cli completion zsh)

Now turn-on and turn-off will auto-complete entity IDs.


Development

  • Clone the repository
  • Build: make install
  • Tests: make test

License

MIT License


Support

For questions or issues: Git Repository Issues