Skip to content

Selectra-Dev/selectra-ha

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

22 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

โšก Selectra for Home Assistant

Home Assistant Status License Free

An electricity price integration for Home Assistant from Selectra.

Turn your devices on and off based on the real-time price of electricity. Perfect for off-peak schedules, demand-response programs, and dynamic pricing offers.


๐Ÿšง Beta Notice

This integration is currently in beta. We are actively developing new features and improving reliability. We'd love your feedback โ€” whether it's a bug report, a feature request, or just an idea. Don't hesitate to open an issue or start a discussion!


โœจ Features

  • Real-time electricity pricing โ€” Access current and upcoming electricity prices for your plan directly in Home Assistant.
  • A ready-to-automate "Planned Run" signal โ€” A single binary sensor that turns on when it's a good time to run your devices, whatever your tariff type.
  • Smart automations โ€” Trigger automations based on price thresholds, off-peak windows, or the cheapest upcoming hours.
  • Massive coverage โ€” 80 countries, 2,000+ energy providers, and 16,000+ electricity plans supported today.
  • Always free โ€” This integration is and will remain free to use.

๐ŸŒ Coverage

Current Goal (end of 2026)
Countries 80 Worldwide
Energy providers 2,000+ All residential providers
Electricity plans 16,000+ Every residential plan

Can't find your provider or plan? Open an issue and we'll look into adding it.

โœ… Requirements

๐Ÿ“ฆ Installation

Via HACS (recommended)

  1. Open HACS in Home Assistant.
  2. Search for Selectra and install it.
  3. Restart Home Assistant.
  4. Go to Settings โ†’ Devices & Services โ†’ Add Integration โ†’ search for Selectra.

Not finding it? Go to HACS โ†’ three-dot menu โ†’ Custom repositories, paste https://github.com/Selectra-Dev/selectra-ha and select Integration.

Manual installation

  1. Download the latest release from the Releases page.
  2. Copy the custom_components/selectra folder into your Home Assistant config/custom_components/ directory.
  3. Restart Home Assistant.
  4. Go to Settings โ†’ Devices & Services โ†’ Add Integration โ†’ search for Selectra.

โš™๏ธ Configuration

Everything is configured through the Home Assistant UI โ€” no YAML required. After adding the integration you'll go through a short guided setup:

  1. API token โ€” Paste your free Selectra API token (see below).

  2. Qualification โ€” Identify your exact contract: country, postal code, electricity provider, offer, pricing option, subscribed power, and off-peak hours where applicable.

  3. Behaviour โ€” For classic (multi-period) and dynamic plans, you'll then either:

    • pick the active periods (classic plans, e.g. peak / off-peak), or
    • choose an optimization strategy (dynamic plans).

    Flat-rate plans skip this step โ€” the integration is ready as soon as qualification is done.

Need to change something later? Select the integration โ†’ โ‹ฎ menu โ†’ Reconfigure. This is Home Assistant's native reconfigure flow: it reuses your existing API token and re-runs qualification โ€” you won't be asked for the token again.

๐Ÿง  How it works โ€” operating modes

The integration adapts to your tariff. The Planned Run binary sensor turns on according to one of three modes:

Mode For which plans When Planned Run is on
Flat Single flat-rate tariffs Always on (the price never changes).
Classic Multi-period plans (e.g. peak / off-peak) During the periods you selected at setup.
Dynamic Dynamic / spot-price plans During the cheapest hours, based on your chosen strategy.

For dynamic plans, two strategies are available:

  • Cheapest X% of the day โ€” the sensor is on during the cheapest X% of today's hours (e.g. the cheapest 30%).
  • Cheapest X consecutive hours โ€” the sensor is on during the single cheapest uninterrupted window of X hours (great for EV charging or a dishwasher run).

๐Ÿ“Ÿ Entities

Once configured, the integration creates the following entities:

Entity Type Description
Planned Run binary_sensor The core entity. on = good time to run your devices (see modes above).
Current Price sensor The current electricity price per kWh, in your currency.
Provider sensor (diagnostic) Your electricity provider.
Offer sensor (diagnostic) Your offer/plan. Carries rich attributes (category, distributor, off-peak hours, featuresโ€ฆ).
Option sensor (diagnostic) Your pricing option.

Exact entity IDs depend on your setup โ€” check them under Settings โ†’ Devices & Services โ†’ Selectra. The examples below use binary_sensor.selectra_planned_run and sensor.selectra_current_price.

Useful attributes

Planned Run exposes, among others:

  • current_period_name, current_price, currency
  • next_change โ€” when the sensor will next switch on/off
  • prices โ€” the full list of upcoming price periods, each with name, price, start, end, and is_active. Ideal for building charts (see Visualization).

Current Price exposes period_name, period_start, period_end, and next_update.

๐Ÿค– Automation examples

Your entity IDs may differ from the examples below. Check the real IDs under Settings โ†’ Devices & Services โ†’ Selectra and adjust the automations and chart config accordingly.

Run your water heater during the planned (cheap) periods:

automation:
  - alias: "Water heater โ€” cheap hours only"
    trigger:
      - platform: state
        entity_id: binary_sensor.selectra_planned_run
        to: "on"
    action:
      - action: switch.turn_on
        target:
          entity_id: switch.water_heater
  - alias: "Water heater โ€” off outside cheap hours"
    trigger:
      - platform: state
        entity_id: binary_sensor.selectra_planned_run
        to: "off"
    action:
      - action: switch.turn_off
        target:
          entity_id: switch.water_heater

Charge the EV only when the price drops below a threshold:

automation:
  - alias: "EV charging โ€” below 0.15 /kWh"
    trigger:
      - platform: numeric_state
        entity_id: sensor.selectra_current_price
        below: 0.15
    action:
      - action: switch.turn_on
        target:
          entity_id: switch.ev_charger

๐Ÿ“Š Visualization

You can plot today's prices using the prices attribute of the Planned Run sensor โ€” for example with the popular ApexCharts card:

type: custom:apexcharts-card
header:
  title: Electricity prices today
series:
  - entity: binary_sensor.selectra_planned_run
    name: Price
    type: column
    data_generator: |
      return entity.attributes.prices.map(p => [new Date(p.start).getTime(), p.price]);

๐Ÿ“ก Data Source & API Access

All electricity pricing data is provided by the Selectra Electricity Planning API.

This integration requires an API token. To get one:

  1. Visit the Selectra Electricity Planning API registration page.
  2. Follow the instructions to request your free API key.
  3. Paste the token during the integration's setup (first step).

Need help? Contact us at support.home-assistant@selectra.info.

โ“ FAQ & Troubleshooting

"Reconfiguration Required" notification appears / entities show as unavailable. Your contract details need to be refreshed (e.g. your provider changed something). Open Settings โ†’ Devices & Services โ†’ Selectra โ†’ Reconfigure and re-run the setup. Entities come back automatically once reconfiguration succeeds.

"Invalid or missing API key" during setup. Double-check the token, or register for a free one at the API page. Still stuck? Email support.home-assistant@selectra.info.

"Too many requests" / rate limited. The Selectra API applies rate limits. Wait a few minutes and try again โ€” the integration also backs off automatically and retries on its own.

Current Price or Planned Run shows unknown / no data. This can happen when no price data is available yet for the current day. The integration polls regularly and will populate the values as soon as data is published.

How often does it update? Polling is dynamic: the integration follows the API's next_update hint (at most once a minute, ~every 15 minutes by default) and recalculates the Planned Run state locally at each period boundary โ€” so transitions are on time without hammering the API.

๐Ÿค Contributing

We welcome contributions of all kinds! Here's how you can help:

  • ๐Ÿ› Report bugs โ€” Open an issue with steps to reproduce.
  • ๐Ÿ’ก Suggest features โ€” We're very open to ideas and requests. Tell us what would make this integration more useful for you.
  • ๐Ÿ”ง Submit a PR โ€” Fork the repo, make your changes, and open a pull request.

๐Ÿ“„ License

This project is licensed under the Apache License 2.0.


Made with โšก by Selectra

About

An electricity price integration for Home Assistant from Selectra. Allows turning devices on and off based on the price of electricity. Perfect for off-peak, demand-response and dynamic offers.

Topics

Resources

License

Security policy

Stars

5 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors

Languages