A Home Assistant custom integration to fetch energy consumption data from E-REDES (Portuguese electricity distribution network operator).
- Fetches 15-minute interval energy consumption data
- Imports up to 2 years of historical data
- Compatible with Home Assistant's Energy Dashboard
- Automatic re-authentication flow when token expires
- Multi-language support (English, Portuguese)
| Sensor | Description | Unit |
|---|---|---|
sensor.eredes_energy_total |
Cumulative energy consumption | kWh |
sensor.eredes_energy_today |
Energy consumed today | kWh |
sensor.eredes_energy_yesterday |
Energy consumed yesterday | kWh |
sensor.eredes_power_current |
Current power (15-min average) | W |
- Open HACS in Home Assistant
- Click the three dots menu and select "Custom repositories"
- Add
https://github.com/mrfyda/ha-eredeswith category "Integration" - Click "Install"
- Restart Home Assistant
- Download the latest release from GitHub
- Copy
custom_components/eredesto your Home Assistantconfig/custom_components/directory - Restart Home Assistant
This integration requires a session token from the E-REDES portal. Due to CAPTCHA protection on the login page, automatic authentication is not possible.
- Log into balcaodigital.e-redes.pt in your browser
- Open browser developer tools (F12)
- Go to Application > Cookies >
https://balcaodigital.e-redes.pt - Copy the value of the
aatcookie
- Go to Settings > Devices & Services
- Click Add Integration
- Search for "E-REDES"
- Enter your configuration:
- AAT Token: The
aatcookie value from your browser - CPE Code: Your electricity meter CPE code (e.g.,
PT0002000012345678AB)
- AAT Token: The
The token will expire after some time (typically when you log out or after extended inactivity). When this happens:
- Home Assistant will show a re-authentication notification
- Log into the E-REDES portal again
- Copy the new
aatcookie value - Enter it in the re-authentication form
After installation, add the integration to your Energy Dashboard:
- Go to Settings > Dashboards > Energy
- Under "Grid consumption", click Add consumption
- Select
sensor.eredes_energy_total
| Limitation | Description |
|---|---|
| Manual token | Due to CAPTCHA, tokens must be obtained manually from browser |
| Token expiry | Token expires and requires periodic manual refresh |
| Data delay | E-REDES data is typically 1-2 hours behind real-time |
| Resolution | Data is provided in 15-minute intervals only |
| Real-time | For real-time monitoring, use a dedicated energy monitor (e.g., Shelly) |
If you see a token error:
- Obtain a fresh token by logging into balcaodigital.e-redes.pt
- Copy the new
aatcookie value - Reconfigure or re-authenticate the integration
If sensors show "Unknown" or no data:
- E-REDES may have a delay in processing data (wait 1-2 hours)
- Check the integration logs for errors
- Verify your CPE code is correct
# Clone the repository
git clone https://github.com/mrfyda/ha-eredes.git
cd ha-eredes
# Install development dependencies (using uv)
uv venv
source .venv/bin/activate
uv pip install -r requirements_test.txt
# Run tests
pytest tests/ -v
# Run linting
ruff check .
mypy custom_components/eredes --strictMIT License - see LICENSE for details.
This integration is not affiliated with or endorsed by E-REDES. Use at your own risk.