skills/hass-cli/SKILL.md
Control and query Home Assistant via the hass-cli Python CLI. Use when Codex needs to interact with a Home Assistant instance for controlling devices (lights, switches, climate, covers, etc.), querying entity states or attributes, managing areas/devices/entities, calling services, checking system status, or any Home Assistant automation/control tasks. Supports JSON output for structured data.
npx skillsauth add gregoryg/aipihkal hass-cliInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Control Home Assistant via the hass-cli Python CLI.
Binary location: ~/.local/python-venvs/boodle/bin/hass-cli (or see if it's in the path already with which hass-cli)
Secret Management (Secure Injection):
Load HASS_TOKEN from .env` or - if not there, load it securely:
source skills/common/secrets.sh
load_hass_token
export HASS_SERVER=http://172.16.17.7:8123 # Update if needed
Alternative (One-liner):
export HASS_TOKEN=$(gpg --decrypt ~/.authinfo.gpg 2>/dev/null | grep "machine ha-mcp-token" | awk '{for(i=1;i<=NF;i++) if($i=="password") print $(i+1)}')
Always export these variables before running hass-cli.
Entity discovery:
# List all entities (supports wildcards)
hass-cli -o json entity list 'light.*'
hass-cli -o json entity list 'switch.bar*'
# Get current state + attributes
hass-cli -o json state list 'light.bar*'
Control entities:
# Direct control commands (preferred for simple on/off/toggle)
hass-cli state turn_on light.bar_switch_light
hass-cli state turn_off light.living_room
hass-cli state toggle switch.porch
# Service calls (for parameters or services without direct commands)
hass-cli service call light.turn_on --arguments entity_id=light.bar_switch_light
hass-cli service call climate.set_temperature --arguments entity_id=climate.bedroom,temperature=72
Areas and organization:
# List areas
hass-cli -o json area list
# List devices
hass-cli -o json device list
Find entities in an area:
# 1. Get area_id from area list
hass-cli -o json area list | jq -r '.[] | select(.name=="Bar") | .area_id'
# 2. Filter entities by area_id (from entity metadata)
hass-cli -o json entity list | jq '.[] | select(.area_id=="bar")'
Get detailed state information:
# State includes: current value, attributes, last_changed, last_updated
hass-cli -o json state list 'light.bar_switch_light'
Wildcard searches:
light.* — all lightsswitch.bar* — switches starting with "bar"sensor.*temperature* — all temperature sensorsclimate.bedroom — exact matchJSON (preferred for structured data):
hass-cli -o json entity list
Table (human-readable):
hass-cli -o table state list 'light.*'
YAML:
hass-cli -o yaml area list
Broken commands:
hass-cli info — Uses deprecated endpoint, will failEntity vs State:
entity list — Registry metadata (area, device, platform, creation date)state list — Current state + attributes (on/off, brightness, temperature, etc.)state list for runtime information, entity list for organizationList available services:
hass-cli -o json service list
Common services by domain:
light.turn_on, light.turn_off, light.toggleswitch.turn_on, switch.turn_off, switch.toggleclimate.set_temperature, climate.set_hvac_modecover.open_cover, cover.close_coverautomation.trigger, automation.turn_on, automation.turn_offnotify.notify (send notifications)Service call syntax:
hass-cli service call <domain>.<service> --arguments key=value,key2=value2
Examples:
# Trigger automation
hass-cli service call automation.trigger --arguments entity_id=automation.good_night
# Light with brightness
hass-cli service call light.turn_on --arguments entity_id=light.bedroom,brightness=128
# Climate with temperature
hass-cli service call climate.set_temperature --arguments entity_id=climate.bedroom,temperature=72
# Notification
hass-cli service call notify.notify --arguments message="Garage door open!",title="Alert"
Turn on multiple lights:
hass-cli state turn_on light.living_room
hass-cli state turn_on light.kitchen
Check bedroom temperature:
hass-cli -o json state list 'sensor.bedroom_temperature' | jq -r '.[0].state'
List all lights that are currently on:
hass-cli -o json state list 'light.*' | jq '.[] | select(.state=="on") | .entity_id'a
Find entities with "bar" in the name:
hass-cli -o json entity list | jq '.[] | select(.entity_id | contains("bar"))'
tools
Write, review, and test Python code following PEP 8, type hints, and modern best practices (Python 3.12+). Use when writing, editing, debugging, or reviewing Python files. Enforces a mandatory verify-before-deliver rule - all written code must be tested for syntax and functionality using available shell tools before presenting to the user. Covers naming conventions, project layout, docstrings, formatting, and test authoring.
development
Write correct, idiomatic Org mode (vanilla) including denote-style optional frontmatter, agenda-aware tasks (TODO/STARTED/PAUSED/DONE, SCHEDULED/DEADLINE, repeaters, tags), and interactive executable Org Babel blocks (emacs-lisp, python, bash, sql) that produce in-buffer results. Use when asked to draft or transform .org files, planning/task documents, executable notes, or when Org syntax/agenda/Babel interactivity is needed instead of Markdown.
tools
Write, review, and test Emacs Lisp code following idiomatic conventions and hard-won local best practices. Use when writing, editing, debugging, or reviewing .el files, Emacs packages, or gptel tools. Enforces a mandatory verify-before-deliver rule - all written code must be batch byte-compiled and smoke-tested before presenting to the user. Covers load-path management, buffer-local variable safety, HTML/XML parsing, file I/O patterns, and batch testing workflows.
testing
invoke multiple LLMs to gather different perspectives, review each other's outputs, and act as a council under the directorship of you the Council Head. Or more generally, call other LLM instances as agents to provide summaries without cluttering context.