ha-rest-api
Provides methods to interact with Home Assistant REST API for entity discovery, state retrieval, and service calls including authentication, entity patterns, service calls, and state queries. Use when working with Home Assistant integrations, controlling devices, querying sensor data, or automating Home Assistant operations.
What this skill does
Works with Home Assistant REST API, Python requests library, and bash/curl commands.
# Home Assistant REST API
Interact with Home Assistant using the REST API to discover entities, retrieve states, and call services.
## When to Use This Skill
Use this skill when you need to:
- Discover and query Home Assistant entities programmatically
- Retrieve entity states and attributes for external systems
- Call Home Assistant services from Python scripts or bash commands
- Build custom integrations or automation tools outside of Home Assistant
- Monitor multiple sensors for data collection or analysis
- Control devices programmatically via REST API
Do NOT use when:
- You can use Home Assistant automations (prefer built-in automation engine)
- Building real-time dashboards (use WebSocket API instead for live updates)
- You need to create or modify dashboards (use WebSocket API for dashboard management)
## Quick Start
All API calls require authentication using a long-lived access token:
```bash
# Token stored in ~/.zshrc as HA_LONG_LIVED_TOKEN
source ~/.zshrc
# Test connection
curl -s "http://192.168.68.123:8123/api/" \
-H "Authorization: Bearer $HA_LONG_LIVED_TOKEN" \
-H "Content-Type: application/json"
```
## Usage
This skill provides REST API interaction methods for Home Assistant. Use the Quick Start section above to authenticate, then follow the Core Operations below for entity discovery, state retrieval, and service calls.
## Core Operations
### 1. Discover Entities
Get all entities or filter by domain:
```python
import requests
import os
HA_URL = "http://192.168.68.123:8123"
HA_TOKEN = os.environ["HA_LONG_LIVED_TOKEN"]
def get_all_entities():
"""Get all entity states."""
url = f"{HA_URL}/api/states"
headers = {
"Authorization": f"Bearer {HA_TOKEN}",
"Content-Type": "application/json",
}
response = requests.get(url, headers=headers, timeout=10)
response.raise_for_status()
return response.json()
def discover_entities(pattern: str) -> dict[str, str]:
"""Discover entity IDs matching a pattern."""
entities = {}
for state in get_all_entities():
entity_id = state["entity_id"]
if pattern.lower() in entity_id.lower():
entities[entity_id] = state["state"]
return entities
# Examples
climate_entities = discover_entities("climate.")
office_sensors = discover_entities("sensor.office")
```
**bash equivalent:**
```bash
# Get all entities
curl -s "$HA_URL/api/states" \
-H "Authorization: Bearer $HA_LONG_LIVED_TOKEN" | jq
# Filter to specific domain
curl -s "$HA_URL/api/states" \
-H "Authorization: Bearer $HA_LONG_LIVED_TOKEN" | \
jq '.[] | select(.entity_id | startswith("climate."))'
```
### 2. Get Entity State
Retrieve full entity state including attributes:
```python
def get_entity_state(entity_id: str) -> dict:
"""Get full entity state including attributes."""
url = f"{HA_URL}/api/states/{entity_id}"
headers = {"Authorization": f"Bearer {HA_TOKEN}"}
response = requests.get(url, headers=headers, timeout=10)
response.raise_for_status()
return response.json()
# Returns: {
# "entity_id": "sensor.temperature",
# "state": "22.5",
# "attributes": {"unit_of_measurement": "°C", ...},
# "last_changed": "2025-12-14T10:30:00+00:00"
# }
# Example
temp_state = get_entity_state("sensor.officeht_temperature")
print(f"Temperature: {temp_state['state']}{temp_state['attributes']['unit_of_measurement']}")
```
**bash equivalent:**
```bash
curl -s "$HA_URL/api/states/sensor.officeht_temperature" \
-H "Authorization: Bearer $HA_LONG_LIVED_TOKEN" | jq
```
### 3. Call Services
Control devices by calling Home Assistant services:
```python
def call_service(domain: str, service: str, entity_id: str, **kwargs):
"""Call a Home Assistant service."""
url = f"{HA_URL}/api/services/{domain}/{service}"
headers = {
"Authorization": f"Bearer {HA_TOKEN}",
"Content-Type": "application/json",
}
data = {"entity_id": entity_id, **kwargs}
response = requests.post(url, headers=headers, json=data, timeout=10)
response.raise_for_status()
return response.json()
# Examples
# Turn on light with brightness
call_service("light", "turn_on", "light.living_room_dimmer", brightness=150)
# Set AC temperature
call_service("climate", "set_temperature", "climate.snorlug", temperature=22)
# Turn on irrigation zone
call_service("switch", "turn_on", "switch.s01_left_top_patio_lawn_station_enabled")
# Turn off climate
call_service("climate", "turn_off", "climate.mines_of_moria")
```
**bash equivalent:**
```bash
# Turn on light with brightness
curl -X POST "$HA_URL/api/services/light/turn_on" \
-H "Authorization: Bearer $HA_LONG_LIVED_TOKEN" \
-H "Content-Type: application/json" \
-d '{"entity_id": "light.living_room_dimmer", "brightness": 150}'
# Set AC temperature
curl -X POST "$HA_URL/api/services/climate/set_temperature" \
-H "Authorization: Bearer $HA_LONG_LIVED_TOKEN" \
-H "Content-Type: application/json" \
-d '{"entity_id": "climate.snorlug", "temperature": 22}'
```
### 4. Get Available Services
Discover what services are available:
```bash
curl -s "$HA_URL/api/services" \
-H "Authorization: Bearer $HA_LONG_LIVED_TOKEN" | jq
```
### 5. Get Configuration
Retrieve Home Assistant configuration:
```bash
curl -s "$HA_URL/api/config" \
-H "Authorization: Bearer $HA_LONG_LIVED_TOKEN" | jq
```
## Common Patterns
### Monitor Multiple Sensors
```python
def get_environmental_data() -> dict:
"""Get all environmental sensor data."""
sensors = [
"sensor.officeht_temperature",
"sensor.officeht_humidity",
"sensor.enviro_temperature",
"sensor.enviro_humidity",
"sensor.enviro_pressure",
"sensor.enviro_pm2_5",
]
data = {}
for sensor in sensors:
state = get_entity_state(sensor)
data[sensor] = {
"value": state["state"],
"unit": state["attributes"].get("unit_of_measurement"),
"last_updated": state["last_changed"],
}
return data
```
### Batch Service Calls
```python
def turn_off_all_acs():
"""Turn off all air conditioners."""
acs = ["climate.snorlug", "climate.val_hella_wam", "climate.mines_of_moria"]
for ac in acs:
call_service("climate", "turn_off", ac)
```
### Entity State Monitoring
```python
def check_if_entity_changed(entity_id: str, last_check: str) -> bool:
"""Check if entity state changed since last check."""
state = get_entity_state(entity_id)
return state["last_changed"] > last_check
```
## Common Service Domains
| Domain | Common Services | Example Entities |
|--------|----------------|------------------|
| `light` | turn_on, turn_off, toggle | light.living_room_dimmer |
| `climate` | turn_on, turn_off, set_temperature, set_hvac_mode | climate.snorlug |
| `switch` | turn_on, turn_off, toggle | switch.s01_* (irrigation) |
| `media_player` | turn_on, turn_off, play_media, volume_set | media_player.* |
| `automation` | trigger, turn_on, turn_off | automation.* |
## Error Handling
```python
def safe_service_call(domain: str, service: str, entity_id: str, **kwargs):
"""Call service with error handling."""
try:
result = call_service(domain, service, entity_id, **kwargs)
return {"success": True, "result": result}
except requests.HTTPError as e:
if e.response.status_code == 404:
return {"success": False, "error": "Entity or service not found"}
elif e.response.status_code == 401:
return {"success": False, "error": "Authentication failed"}
else:
return {"success": False, "error": f"HTTP {e.response.status_code}"}
except requests.Timeout:
return {"success": False, "error": "Request timeout"}
```
## Shell Aliases
Add to ~/.zshrc for quick API access:
```bash
export HA_URL="http://192.168.68.123:8123"
# QuickRelated in Backend & APIs
jfrog
IncludedInteract with the JFrog Platform via the JFrog CLI and REST/GraphQL APIs. Use this skill when the user wants to manage Artifactory repositories, upload or download artifacts, manage builds, configure permissions, manage users and groups, work with access tokens, configure JFrog CLI servers, search artifacts, manage properties, set up replication, manage JFrog Projects, run security audits or scans, look up CVE details, query exposures scan results from JFrog Advanced Security, manage release bundles and lifecycle operations, aggregate or export platform data, or perform any JFrog Platform administration task. Also use when the user mentions jf, jfrog, artifactory, xray, distribution, evidence, apptrust, onemodel, graphql, workers, mission control, curation, advanced security, exposures, or any JFrog product name.
cupynumeric-migration-readiness
IncludedPre-migration readiness assessor for porting NumPy to cuPyNumeric. Use BEFORE substantial porting work begins when the user asks whether code will scale on GPU, whether they should migrate to cuPyNumeric, which NumPy patterns transfer cleanly, what must be refactored before porting, or mentions pre-port assessment, scaling analysis, or refactor planning. Inspect the user's source code, look up NumPy usage, cross-reference the cuPyNumeric API support manifest, and distinguish distributed-scaling-friendly patterns from blockers such as unsupported APIs, scalar synchronization, host round-trips, Python/object-heavy control flow, shape/data-dependent branching, and in-place mutation hazards. Produce a verdict of READY, LIGHT REFACTOR, SIGNIFICANT REFACTOR, or NOT RECOMMENDED, with concrete refactor pointers.
alibabacloud-data-agent-skill
IncludedInvoke Alibaba Cloud Apsara Data Agent for Analytics via CLI to perform natural language-driven data analysis on enterprise databases. Data Agent for Analytics is an intelligent data analysis agent developed by Alibaba Cloud Database team for enterprise users. It automatically completes requirement analysis, data understanding, analysis insights, and report generation based on natural language descriptions. This tool supports: discovering data resources (instances/databases/tables) managed in DMS, initiating query or deep analysis sessions, real-time progress tracking, and retrieving analysis conclusions and generated reports. Use this Skill when users need to query databases, analyze data trends, generate data reports, ask questions in natural language, or mention "Data Agent", "data analysis", "database query", "SQL analysis", "data insights".
token-optimizer
IncludedReduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and native 2026.2.15 features (session pruning, bootstrap size limits, cache TTL alignment). Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. The 4 executable scripts (context_optimizer, model_router, heartbeat_optimizer, token_tracker) are local-only — no network requests, no subprocess calls, no system modifications. Reference files (PROVIDERS.md, config-patches.json) document optional multi-provider strategies that require external API keys and network access if you choose to use them. See SECURITY.md for full breakdown.
resend-cli
IncludedUse this skill when the task is specifically about operating Resend from an AI agent, terminal session, or CI job via the official resend CLI: installing/authenticating the CLI, sending/listing/updating/cancelling emails, batch sends, domains and DNS, webhooks and local listeners, inbound receiving, contacts, topics, segments, broadcasts, templates, API keys, profiles, or debugging Resend CLI/API failures. Trigger on mentions of Resend CLI, `resend`, `resend doctor`, `resend emails send`, `resend domains`, `resend webhooks listen`, `resend emails receiving`, or agent-friendly terminal automation.
alibabacloud-odps-maxframe-coding
IncludedUse this skill for MaxFrame SDK development and documentation navigation on Alibaba Cloud MaxCompute (ODPS). Helps answer MaxFrame API, concept, official example, and supported pandas API questions; create data processing programs; read/write MaxCompute tables; debug jobs (remote or local); and build custom DPE runtime images. Trigger when users mention MaxFrame, MaxCompute with MaxFrame, ODPS table processing, DPE runtime, MaxFrame docs/examples, DataFrame/Tensor operations, or GPU runtime setup. Works for both English and Chinese queries about Alibaba Cloud data processing with MaxFrame.