← Back to Skills Marketplace
mrbese

Grid-Aware Energy Load Shifter

by Omer Bese · GitHub ↗ · v1.0.3
cross-platform ✓ Security Clean
531
Downloads
0
Stars
0
Active Installs
4
Versions
Install in OpenClaw
/install grid-aware-energy-load-shifter
Description
Grid-aware energy load shifter for Home Assistant. Reads real-time electricity prices (TOU, time-of-use, dynamic pricing), solar production forecasts, batter...
README (SKILL.md)

Grid-Aware Energy Load Shifter

Shift heavy residential loads to the cheapest electricity hours using Home Assistant energy data.

Quick Start

# Find all energy-related entities in HA
python3 {baseDir}/scripts/ha_bridge.py discover

# Get a full energy dashboard snapshot (prices, solar, consumption, batteries)
python3 {baseDir}/scripts/ha_bridge.py energy-summary

# Turn on the EV charger
python3 {baseDir}/scripts/ha_bridge.py call-service switch/turn_on --entity-id switch.ev_charger

Connection

Two paths to reach Home Assistant:

  1. MCP (preferred): If the HA MCP server is configured, use mcporter call homeassistant.\x3Ctool> directly.
  2. REST API: Use python3 {baseDir}/scripts/ha_bridge.py. Requires HA_URL and HA_TOKEN environment variables.

Security

Required credentials:

Variable Description
HA_URL Home Assistant base URL (e.g. http://homeassistant.local:8123)
HA_TOKEN Home Assistant Long-Lived Access Token

Least-privilege recommendations:

  • Create a dedicated Home Assistant user account for this skill (e.g. openclaw-energy)
  • Generate a Long-Lived Access Token from that account only
  • Limit the account's entity access to energy-related entities if your HA setup supports entity-level permissions
  • Test with read-only commands first (discover, energy-summary) before enabling device control

Domain allowlist: The call-service command restricts actions to energy-related domains only: switch, automation, script, climate, water_heater, input_boolean, input_number, number. All other domains (e.g. lock, alarm_control_panel) are blocked with exit code 2.

Commands

Command What it does Example
discover List all energy entities ha_bridge.py discover
energy-summary One-shot dashboard (prices + consumption + solar + storage) ha_bridge.py energy-summary
status \x3Centity> Read a single entity's state and attributes ha_bridge.py status sensor.electricity_price
call-service \x3Cd/s> Call an energy-related HA service (restricted to allowed domains) ha_bridge.py call-service switch/turn_on --entity-id switch.ev_charger
history \x3Centity> Get state changes over last N hours ha_bridge.py history sensor.grid_import --hours 24

All commands output JSON to stdout.

Load-Shifting Workflow

Follow these steps when asked about energy optimization:

  1. Discover available energy entities: run discover or energy-summary
  2. Read prices: Check pricing entities' state and attributes — look for:
    • Hourly price arrays in today / tomorrow / prices_today / rates attributes
    • price_level attribute (CHEAP / NORMAL / EXPENSIVE)
    • Current vs. average price comparison
  3. Identify deferrable loads: Find switch.* entities for schedulable devices (EV charger, pool pump, dishwasher, washer/dryer, water heater)
  4. Find the cheapest window: Scan hourly prices for the contiguous N-hour block with the lowest sum (N = estimated run time of device)
  5. Execute: Call switch/turn_on at the optimal time, or automation/trigger if the user has an existing automation

Interpreting Price Data

Different integrations expose prices differently:

  • Hourly arrays (Nordpool, ENTSO-e, Octopus): Read today/tomorrow attributes → find cheapest hours
  • Price level (Tibber): Read price_level → act when CHEAP or VERY_CHEAP
  • Real-time (Amber Electric): Read 5-minute pricing → shift loads immediately when cheap
  • Utility meter tariffs: Read sensor.*_peak vs sensor.*_offpeak → user's HA automations switch tariffs at configured times
  • Static TOU: Read current_price attribute → compare against historical average

Cost Savings Estimate

When recommending a shift, show estimated savings:

savings = (current_rate - cheapest_rate) × device_power_kw × run_duration_hours

Solar Self-Consumption

If solar sensors exist, align loads with peak production:

  • Read sensor.forecast_solar_* or sensor.solcast_* for today's forecast
  • Shift loads to hours with highest expected production
  • This avoids grid import entirely — savings = full retail rate × kWh shifted

HVAC Pre-Conditioning

HVAC is the largest residential load (40-50% of electricity). Pre-cool or pre-heat during cheap/solar hours so the home coasts through expensive peak periods:

  1. Read climate.* entities for current HVAC mode and setpoint
  2. During cheapest window: lower cooling setpoint by 2-3F (pre-cool) or raise heating setpoint by 2-3F (pre-heat)
  3. During peak window: raise cooling setpoint by 2-3F to coast on thermal mass
  4. Savings estimate: 1.5-3 kW shifted × price differential × hours

Water Heater Scheduling

Electric water heaters (4.5 kW typical) are ideal deferrable loads:

  1. Find switch.water_heater or water_heater.* entities
  2. Heat during cheapest/solar window to full temperature
  3. Turn off during peak hours (tank maintains temperature for 4-6 hours)
  4. Savings estimate: 4.5 kW × price differential × 3-4 hours/day

Battery Arbitrage

If home battery entities exist (sensor.battery_soc, sensor.powerwall_*, sensor.enphase_*):

  1. Read current state of charge and charge/discharge rate limits
  2. Charge from grid during cheapest hours (or from solar)
  3. Discharge to home during peak price hours to avoid grid import
  4. Advanced: If battery supports grid export and VPP enrollment, discharge to grid during extreme price events ($2,000+/MWh)
  5. Savings estimate: battery_capacity_kwh × (peak_rate - valley_rate)

Demand Response / VPP Integration

For homes enrolled in utility demand response or virtual power plant programs:

  1. Read demand response signal entities (if available via HA integration)
  2. When DR event active: shed non-critical loads, pre-cool/pre-heat, discharge battery
  3. Estimate DR payment: kW reduced × event duration × program rate

Entity Reference

For detailed entity patterns across providers, read: energy_entities.md

Usage Guidance
This skill appears to be what it claims: a small REST bridge to Home Assistant for energy-related discovery and limited service calls. Before installing, follow these precautions: 1) Create a dedicated Home Assistant user for this skill and generate a Long‑Lived Access Token from that account; limit that account's entity access if your HA supports entity-level permissions. 2) Start by running read-only commands (discover, energy-summary) to verify detected entities before enabling call-service. 3) Inspect the included scripts (scripts/ha_bridge.py) yourself—it uses only the HA REST API and standard Python libs, but verify there are no unexpected remote endpoints in the full file. 4) Restrict HA_URL to an internal/local address (do not point to an internet‑exposed HA instance) and place HA on a segmented network if possible. 5) Monitor Home Assistant logs for unexpected service calls and rotate/revoke the token when no longer needed.
Capability Analysis
Type: OpenClaw Skill Name: grid-aware-energy-load-shifter Version: 1.0.3 The OpenClaw skill bundle is benign. It is designed to interact with Home Assistant for energy load shifting, clearly stating its required credentials (`HA_URL`, `HA_TOKEN`). The `scripts/ha_bridge.py` script uses only Python standard library, minimizing supply chain risk, and critically implements a strict allowlist for Home Assistant service domains (`ALLOWED_SERVICE_DOMAINS`). This prevents the skill from accessing sensitive HA functions (e.g., locks, alarms) even if the provided `HA_TOKEN` has broader permissions. There is no evidence of data exfiltration, unauthorized network activity, shell injection, or prompt injection attempts in `SKILL.md` or `README.md` to subvert the agent's purpose.
Capability Assessment
Purpose & Capability
Name/description (grid-aware energy load shifting) match what the skill requires and does: it only needs HA_URL and HA_TOKEN, exposes discovery, summary, history, status, and controlled service calls for energy domains, and includes a single small Python bridge that uses the HA REST API.
Instruction Scope
SKILL.md instructs the agent to read HA energy entities and to call HA services limited to energy-related domains. It does not instruct broad file reads, other environment variables, or exfiltration to external endpoints. It explicitly recommends least‑privilege tokens and read‑only testing first.
Install Mechanism
No install spec; this is instruction‑only plus a single Python stdlib script (no external downloads or package installs). The included script claims zero external dependencies and uses only urllib/json/argparse from the stdlib.
Credentials
Only HA_URL and HA_TOKEN are required, which is appropriate for a Home Assistant integration. The SKILL.md and README document why these are needed and suggest scoped, dedicated tokens.
Persistence & Privilege
The skill is not marked always:true and does not request to modify other skills or system-wide settings. It runs on demand and the code does not persist additional credentials or write system-wide configuration.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install grid-aware-energy-load-shifter
  3. After installation, invoke the skill by name or use /grid-aware-energy-load-shifter
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.3
v1.0.3 Security Added domain allowlist to call-service command in ha_bridge.py. Only energy-related HA service domains are permitted: switch, automation, script, climate, water_heater, input_boolean, input_number, number. Unauthorized domains are rejected with exit code 2. Added comprehensive Security section to SKILL.md documenting required credentials, least-privilege token recommendations, and the domain allowlist. Fixed Replaced em dashes with hyphens across all files (ha_bridge.py, SKILL.md, README.md). Removed degree symbols from HVAC section in SKILL.md. Added missing docstring to main() in ha_bridge.py. Updated call-service description from "Call any HA service" to "Call an energy-related HA service (restricted to allowed domains)". Fixed SKILL.md metadata parsing by migrating environment variables to the official ClawHub requires: env: schema. Removed Removed .env.example file and custom .env loading function from ha_bridge.py per ClawHub validation. The skill now strictly relies on system environment variables (os.environ).
v1.0.2
v1.0.2 Security Added domain allowlist to call-service command in ha_bridge.py. Only energy-related HA service domains are permitted: switch, automation, script, climate, water_heater, input_boolean, input_number, number. Unauthorized domains are rejected with exit code 2. Declared HA_URL and HA_TOKEN as required environment variables in SKILL.md metadata. Fixed Replaced em dashes with hyphens across all files (ha_bridge.py, SKILL.md, README.md). Removed degree symbols from HVAC section in SKILL.md. Added missing docstring to main() in ha_bridge.py. Updated call-service description from "Call any HA service" to "Call an energy-related HA service (restricted to allowed domains)". Removed Removed .env.example file and all references to it per ClawHub validation. Environment variable requirements are now documented in SKILL.md metadata.
v1.0.1
Security Added domain allowlist to call-service command in ha_bridge.py. Only energy-related HA service domains are permitted: switch, automation, script, climate, water_heater, input_boolean, input_number, number. Unauthorized domains are rejected with exit code 2. Fixed Replaced em dashes with hyphens across all files (ha_bridge.py, SKILL.md, README.md). Removed degree symbols from HVAC section in SKILL.md. Added missing docstring to main() in ha_bridge.py.
v1.0.0
Initial release of Grid-Aware Energy Load Shifter for Home Assistant. - Schedules household loads (EV charging, HVAC, pool pump, dishwasher, laundry, water heater) to cheapest electricity price windows. - Integrates real-time utility prices, solar forecasts, battery state, and consumption data from Home Assistant. - Optimizes for cost savings, solar self-consumption, and supports VPP (virtual power plant) demand response signals. - Compatible with Nordpool, ENTSO-e, Tibber, Octopus Energy, Amber Electric, and global utility rate plans. - Provides commands for device/entity discovery, energy dashboard snapshots, direct service calls, and state/history queries.
Metadata
Slug grid-aware-energy-load-shifter
Version 1.0.3
License
All-time Installs 1
Active Installs 0
Total Versions 4
Frequently Asked Questions

What is Grid-Aware Energy Load Shifter?

Grid-aware energy load shifter for Home Assistant. Reads real-time electricity prices (TOU, time-of-use, dynamic pricing), solar production forecasts, batter... It is an AI Agent Skill for Claude Code / OpenClaw, with 531 downloads so far.

How do I install Grid-Aware Energy Load Shifter?

Run "/install grid-aware-energy-load-shifter" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is Grid-Aware Energy Load Shifter free?

Yes, Grid-Aware Energy Load Shifter is completely free (open-source). You can download, install and use it at no cost.

Which platforms does Grid-Aware Energy Load Shifter support?

Grid-Aware Energy Load Shifter is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created Grid-Aware Energy Load Shifter?

It is built and maintained by Omer Bese (@mrbese); the current version is v1.0.3.

💬 Comments