Skip to content

Grid modeling

The Grid device composes a Node (bidirectional power source/sink) with two implicit one-way Connections, one for import and one for export, to model utility grid connections with time-varying import and export pricing.

Model elements created

graph LR
    subgraph "Device"
        SS["Node<br/>(is_source=true, is_sink=true)"]
        Import["Connection<br/>{name}:import"]
        Export["Connection<br/>{name}:export"]
    end

    Node[Connection Target]

    SS --> Import
    Import --> Node
    Node --> Export
    Export --> SS
Model Element Name Parameters From Configuration
Node {name} is_source=true, is_sink=true
Connection {name}:import import limit and import price
Connection {name}:export export limit and negated export price

Devices created

Grid creates 1 device in Home Assistant:

Device Name Created When Purpose
Primary {name} Always Bidirectional grid connection and pricing

Parameter mapping

The adapter transforms user configuration into segments on the import and export connections:

User Configuration Segment Segment Field Notes
price_source_target PricingSegment {name}:import price Cost per kWh imported
price_target_source PricingSegment {name}:export price Stored as negative to represent revenue
max_power_source_target PowerLimitSegment {name}:import max_power Maximum import power (optional)
max_power_target_source PowerLimitSegment {name}:export max_power Maximum export power (optional)
connection Connection import target, export source Endpoint to connect to
— Node is_source=true Grid can supply power
— Node is_sink=true Grid can absorb power

Sensors created

The sensors this element creates, with their entity IDs, are listed under Sensors created on the Grid page.

Configuration examples

Time-of-use pricing

Field Value
Name Main Grid
Import price sensor.electricity_import_price
Export price sensor.electricity_export_price
Connection Home Bus

With capacity limits

Field Value
Name Limited Grid
Import price sensor.electricity_import_price
Export price sensor.electricity_export_price
Import limit 10.0
Export limit 5.0
Connection Home Bus

Typical use cases

Time-of-Use Optimization: Grid with time-varying prices enables battery arbitrage—charge during low prices, discharge during high prices.

Feed-in Tariff Systems: Configure export pricing to model solar export revenue and optimize when to export vs. store in battery.

Demand-Limited Connections: Use import/export limits to model connection capacity constraints and prevent exceeding utility limits.

Physical interpretation

Grid represents the utility connection that can supply power (import) when local generation is insufficient, or absorb excess power (export) from solar or battery discharge.

Configuration guidelines

  • Import/Export Pricing: Use sensor or forecast for time-varying prices. Ensure export prices are always less than import prices to prevent unrealistic arbitrage.
  • Power Limits: Configure limits to model connection capacity constraints. If omitted, grid has unlimited capacity.
  • Pricing Strategy: Flat pricing provides limited optimization value (battery only useful for solar storage). Time-varying pricing enables full optimization benefits.
  • Zero Prices: Avoid setting both import and export prices to zero simultaneously—optimizer has no economic preference and may produce unexpected results.

Next steps