Analyze real-time energy consumption from your Home Assistant instance. Identifies the highest consumers, groups usage by room/area, and generates actionable automations.
unit_of_measurement set to W or kWSet the environment variable before running:
bash
export HA_TOKEN="your-home-assistant-long-lived-access-token"
The skill reads smart_home/skill.yaml for all other settings:
yaml
home_assistant:
url: "http://homeassistant.local:8123" # Your HA URL
token: "${HA_TOKEN}" # Resolved from env var
units:
power: ["W", "kW"]
energy: ["Wh", "kWh"]
rules:
- name: "High Power Shutoff"
threshold_watts: 2000 # Trigger above this
time_window: { after: "06:00", before: "22:00" }
require_occupancy: "off" # Only trigger when unoccupied
action: "turn_off" # turn_off, turn_on, or notify
outputs:
default: ["summary", "table"] # Formats produced when none specified
FieldDefaultDescriptionhome_assistant.urlRequiredHA instance URLhome_assistant.tokenRequiredLong-lived access token (use ${HA_TOKEN} env var)rules[].threshold_watts2000Power threshold for automation triggersrules[].time_window.after"06:00"Automation active after this timerules[].time_window.before"22:00"Automation active before this timerules[].require_occupancy"off"Occupancy state required for triggerrules[].action"turn_off"Action: turn_off, turn_on, or notify``outputs.default["summary", "table"]Output formats when none specified
Three formats, selectable per request. Request by name: summary, table, automation.
summary — Text Insight#A 2-3 sentence human-readable energy snapshot:
Laundry is drawing 2,200W — 57% of your total 3,842W. The Dryer is the single highest consumer at 2,200W. No anomalies detected.
table — Markdown Comparison#AreaDeviceConsumption (W)LaundryDryer2,200.0KitchenFridge180.5UnassignedSmart Plug 345.0
Sorted by consumption descending, grouped by area.
automation — HA Automation JSON#Generates a JSON payload ready for Home Assistant's automation.create service:
json
[
{
"alias": "High Power Alert - Laundry",
"trigger": {
"platform": "numeric_state",
"entity_id": "sensor.dryer_power",
"above": 2000
},
"condition": [
{
"condition": "time",
"after": "06:00:00",
"before": "22:00:00"
},
{
"condition": "state",
"entity_id": "binary_sensor.laundry_occupancy",
"state": "off"
}
],
"action": {
"service": "switch.turn_off",
"target": { "entity_id": "switch.dryer" }
}
}
]
Conditions are generated based on your config rules:
threshold_watts get automationstime_window configbinary_sensor.<area>_occupancy in your entities. Omitted if no occupancy sensor exists for that area.The skill runs a three-stage pipeline:
text
FETCH ANALYZE FORMAT
HA REST API → Filter energy → Summary
/api/states entities Markdown table
Area registry Normalize kW→W Automation JSON
Device reg. Group by area
Rank consumers
Entity detection: The skill identifies energy entities by checking for a numeric state value and a unit_of_measurement of W, kW, kWh, or Wh. Power values are auto-detected from the entity state, falling back to power, current_power, or power_consumption attributes.
Area mapping: Entities are mapped to rooms using the Home Assistant device and area registries. Entities without an area assignment appear under "Unassigned".
Read-only: This skill never modifies Home Assistant state. The automation JSON is a draft payload for you to review and apply manually.
ProblemCauseFix"HA_URL is not configured"Missing home_assistant.url in skill.yamlAdd your HA URL to smart_home/skill.yaml"HA_TOKEN is not configured"Env var not setRun export HA_TOKEN="your-token""Cannot reach Home Assistant"Network or URL issueVerify HA is running and URL is correct"No energy data available"No matching entitiesEnsure devices report unit_of_measurement: W or kWAll devices show "Unassigned"No area registry dataAssign devices to areas in HA Settings > AreasAutomation JSON is emptyNo devices exceed thresholdLower threshold_watts in config