Skip to content

OscillateLabsLLC/home-assistant-client

Repository files navigation

ha-http-client

Status: Active License: Apache-2.0 PyPI

A simple HTTP client for the Home Assistant REST API. Zero smart-home-stack dependencies.

Includes a CLI (ha-client) for quick scripting and a bundled Claude Code skill so Claude can control your Home Assistant instance.

Install

pip install ha-http-client
# or
uv pip install ha-http-client

Quick Start

Python API

from ha_http_client import SimpleHTTPHomeAssistantClient

client = SimpleHTTPHomeAssistantClient(
    url="http://homeassistant.local:8123",
    token="YOUR_LONG_LIVED_ACCESS_TOKEN",
)

# List all entities
states = client.get_states()

# Turn on a light
client.turn_on("light.living_room")

# Set brightness (0-100%)
client.set_brightness("light.living_room", 50)

# Set color by name
client.set_color("light.living_room", "warm white")

# Call any service
client.call_service("climate", "set_temperature", "climate.thermostat", temperature=72)

# Natural language via Assist
client.send_assist_command("turn off all the lights")

CLI

Set environment variables:

export HA_URL="http://homeassistant.local:8123"
export HA_TOKEN="your-long-lived-access-token"

Then:

ha-client states                          # List all entities
ha-client state light.living_room         # Get one entity
ha-client turn-on light.living_room       # Turn on
ha-client turn-off light.living_room      # Turn off
ha-client brightness light.living_room 50 # Set brightness
ha-client color light.living_room "red"   # Set color
ha-client assist "turn off the kitchen"   # Natural language
ha-client service tts speak --data '{"entity_id": "tts.cloud", "media_player_entity_id": "media_player.speaker", "message": "Hello"}'

Claude Code Skill

Install the bundled skill so Claude Code can control Home Assistant:

ha-install-skill

Then add your HA credentials to ~/.claude/settings.json:

{
  "env": {
    "HA_URL": "http://homeassistant.local:8123",
    "HA_TOKEN": "your-long-lived-access-token"
  }
}

Generate a token at: Home Assistant → Profile → Long-Lived Access Tokens

Development

uv sync --extra test
uv run pytest
uv run ruff check .
uv run mypy ha_http_client

License

Apache-2.0

About

No description or website provided.

Topics

Resources

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages