py-homeassistant-cli

Tiny and short Python CLI tool to control Home Assistant devices and automations via the REST API. No external dependencies — uses only Python 3.6+ standard library.

Safety Notice

This listing is from the official public ClawHub registry. Review SKILL.md and referenced scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "py-homeassistant-cli" with this command: npx skills add xwings/py-homeassistant-cli

Home Assistant Skill

Control smart home devices via the Home Assistant REST API using the Python CLI tool at {baseDir}/scripts/homeassistant-cli.py. No external dependencies — uses only Python standard library.

Setup

Configure via environment variables or command-line arguments (args take priority):

# Optional: Environment variables
export HA_URL="http://10.0.0.10:8123"
export HA_TOKEN="your_long_lived_access_token"

# pass via args (overrides env vars)
python3 {baseDir}/scripts/homeassistant-cli.py --server http://10.0.0.10:8123 --token YOUR_TOKEN check

Use --help on any command for details: python3 {baseDir}/scripts/homeassistant-cli.py light --help

Safety Rules

Always confirm with the user before: locking/unlocking locks, arming/disarming alarm panels, opening/closing garage doors or gates, disabling security automations.

Command Reference

All commands follow: python3 {baseDir}/scripts/homeassistant-cli.py [--server URL] [--token TOKEN] <command> [args]

Discovery & Status

check                                          # Check API connectivity
entities                                       # List all entities
entities --domain light                        # List entities by domain (light, switch, sensor, etc.)
state <entity_id>                              # Get full entity state JSON
areas                                          # List all areas
area-entities <area> [--domain light]          # Entities in an area, optionally filtered
area-of <entity_id>                            # Find which area an entity belongs to
floors                                         # List all floors and their areas
services [--domain light]                      # List available services
dashboard                                      # Quick overview: lights on, doors, temps, locks, presence
presence [--trackers]                          # Who is home (--trackers for device trackers)
weather [--forecast daily|hourly] [-e entity]  # Current weather or forecast

Device Control

switch <turn_on|turn_off|toggle> <entity_id>
light <turn_on|turn_off> <entity_id> [--brightness 80] [--rgb 255,150,50] [--color-temp 300]
fan <turn_on|turn_off> <entity_id> [--percentage 50]
cover <open|close|set_position> <entity_id> [--position 50]
lock <lock|unlock> <entity_id>
media <play_pause|volume> <entity_id> [--level 0.5]
vacuum <start|dock> <entity_id>
climate <state|set_temp|set_mode> <entity_id> [--temperature 72] [--mode auto]
alarm <arm_home|disarm> <entity_id> [--code 1234]
scene <entity_id>

Automations & Scripts

automation <list|trigger|enable|disable> [entity_id]
script <list|run> [entity_id] [--variables '{"key": "value"}']

Notifications

notify list                                                    # List notification targets
notify send <service> "message" [--title "title"]              # Send notification

Input Helpers

input boolean <entity_id>                   # Toggle
input number <entity_id> <value>            # Set number
input select <entity_id> "option"           # Set selection
input text <entity_id> "value"              # Set text
input datetime <entity_id> "07:30:00"       # Set time

Calendar & TTS

calendar list                                              # List calendars
calendar events <entity_id> [--days 14]                    # Upcoming events
tts <tts_entity> <media_player_entity> "message"           # Text-to-speech

Templates, History & Logbook

template '{{ states.light | list | count }} lights'                                    # Evaluate Jinja2
history <entity_id> [--start ISO8601] [--end ISO8601]                                  # State history
logbook [--entity entity_id] [--limit 20]                                              # Logbook entries

Template functions: states(), is_state(), state_attr(), areas(), area_entities(), area_name(), floors(), floor_areas(), labels(), label_entities(), devices(), device_entities(), now(), relative_time().

Generic Service Call

service <domain> <service> --data '{"entity_id": "light.living_room"}'

# Batch: pass array of entity_ids
service light turn_off --data '{"entity_id": ["light.room1", "light.room2"]}'

Tesla

Entities: sensor.mao_dou_battery, device_tracker.mao_dou_location_tracker, device_tracker.mao_dou_destination_location_tracker, automation.tesla_battery_below_20

tesla battery        # Battery level
tesla location       # GPS coordinates, heading, speed
tesla destination    # Destination location
tesla automations    # List Tesla-related entities

Entity Domains

DomainExamplesDomainExamples
switch.*Smart plugslight.*Lights (Hue, LIFX)
climate.*Thermostats, ACcover.*Blinds, garage doors
lock.*Smart locksfan.*Fans, ventilation
media_player.*TVs, speakersvacuum.*Robot vacuums
alarm_control_panel.*Security systemsscene.*Pre-configured scenes
script.*Action sequencesautomation.*Automations
sensor.*Temp, humidity, powerbinary_sensor.*Motion, door/window
person.*Presence trackingdevice_tracker.*Device locations
weather.*Weather/forecastscalendar.*Calendar events
notify.*Notification targetstts.*Text-to-speech
input_boolean.*Virtual togglesinput_number.*Numeric sliders
input_select.*Dropdown selectorsinput_text.*Text inputs
input_datetime.*Date/time inputs

HTTP Status Codes

CodeMeaning
200Success
400Bad request (malformed JSON)
401Unauthorized (bad/missing token)
404Entity or endpoint not found
503HA starting up or unavailable

Notes

  • Long-lived tokens don't expire — store securely
  • Test entity IDs with entities --domain first
  • Use service command for any operation not covered by dedicated commands
  • Service calls return JSON arrays of affected entity states; errors print to stderr

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Coding

Contact Map Bm

Generate an interactive Germany map of Odoo contacts (click markers to open the record in Odoo).

Registry SourceRecently Updated
Coding

Code Documentation

Comprehensive code documentation skill — use this any time documentation is requested, after any significant code change, when onboarding a new subsystem, au...

Registry SourceRecently Updated
Coding

repair-agent

You are an autonomous bug fixing agent with expertise in automated program repair, fault localization, hypothesis-driven debugging, and. Use when: autonomous...

Registry SourceRecently Updated
Coding

refactoring-specialist

Expert refactoring specialist mastering safe code transformation techniques and design pattern application. Specializes in improving code structure, reducing...

Registry SourceRecently Updated