In smart home configurations, managing utility consumption is crucial for budget control and scheduling resource usage.
This post explains how to integrate your E.ON Romania account (Myline portal) with Home Assistant and your developer AI assistant, Antigravity (agy).
1. Prerequisites and Installation
To retrieve active billing and index data, we use the community custom integration developed for E.ON Myline.
- Add Custom Repository:
In HACS (Home Assistant Community Store), navigate to Integrations ➔ select the three dots (⋮) in the top-right corner ➔ select Custom repositories ➔ add:
- URL:
https://github.com/cnecrea/eonromania - Category:
Integration
- Install & Restart: Search for E·ON România, click install, and restart Home Assistant.
- Configure: Go to Settings ➔ Devices & Services ➔ Add Integration ➔ Search for E·ON România ➔ Enter your Myline login credentials.
Home Assistant will automatically discover all utility contracts and create the base sensors.
2. Creating Numeric Custom Sensors
The default integration returns the balance state simply as "Da" (Yes) or "Nu" (No) and hides the actual numeric value inside the attributes. To expose the actual outstanding amounts directly as main sensor states, add the following Template Sensors to your configuration.yaml:
template:
- sensor:
- name: "EON Balance 568"
state: >
{% set val = state_attr('sensor.eonromania_000000000068_sold_factura', 'Sold') %}
{{ val | replace(' lei', '') | replace(',', '.') | float if val is not none else 0.0 }}
unit_of_measurement: "RON"
device_class: monetary
icon: mdi:cash
- name: "EON Balance 597"
state: >
{% set val = state_attr('sensor.eonromania_000000000068_sold_factura', 'Sold') %}
{{ val | replace(' lei', '') | replace(',', '.') | float if val is not none else 0.0 }}
unit_of_measurement: "RON"
device_class: monetary
icon: mdi:cash
3. Lovelace Custom Dashboard Cards
To display your payment archive as a formatted table rather than standard attributes, use a Markdown Card with Jinja templating. The literal block scalar (| or |-) is required in the YAML configuration to preserve newlines and render the markdown table correctly:
type: markdown
title: Istoric Plăți E.ON Gas (597)
content: |-
| Descriere Plată | Sumă |
| :--- | :--- |
{% for key, value in states.sensor.eonromania_000000000068_arhiva_plati_2026.attributes.items() -%}
{% if 'Plat' in key -%}
| {{ key }} | **{{ value }}** |
{% endif -%}
{% endfor %}
---
**Total Plătit în 2026**: {{ state_attr('sensor.eonromania_000000000068_arhiva_plati_2026', 'Sumă totală') }}
4. Antigravity (agy) CLI Integration
To query these states, agy runs the local Home Assistant API query script located at get_ha_sensor.sh. Here is the full bash script source code:
#!/usr/bin/env bash
# =============================================================================
# Home Assistant Sensor CLI Bridge
# Queries the local REST API for device status
# =============================================================================
set -eo pipefail
ENTITY_ID=$1
if [[ -z "$ENTITY_ID" ]]; then
echo "Usage: $0 <entity_id>"
exit 1
fi
TOKEN_FILE="/home/gvoina/homeassistant/api_token.txt"
if [[ ! -f "$TOKEN_FILE" ]]; then
echo "Error: API token not found at $TOKEN_FILE."
echo "Please save your Long-Lived Access Token to that file."
exit 1
fi
TOKEN=$(cat "$TOKEN_FILE" | tr -d '\r\n[:space:]')
RESPONSE=$(curl -s -X GET \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
"http://localhost:8123/api/states/$ENTITY_ID")
if echo "$RESPONSE" | jq -e '.state' >/dev/null 2>&1; then
STATE=$(echo "$RESPONSE" | jq -r '.state')
UNIT=$(echo "$RESPONSE" | jq -r '.attributes.unit_of_measurement // ""')
NAME=$(echo "$RESPONSE" | jq -r '.attributes.friendly_name // ""')
if [[ -n "$UNIT" && "$UNIT" != "null" ]]; then
echo "$NAME: $STATE $UNIT"
else
echo "$NAME: $STATE"
fi
else
echo "Error: Failed to fetch state for entity '$ENTITY_ID'."
echo "API Response: $RESPONSE"
exit 1
fi
Document the entity IDs in your workspace custom rules at .agents/AGENTS.md so the agent knows they exist:
### 1. Home Assistant State & Control
You can retrieve the live state of any Home Assistant entity:
* **Query sensor/device state**: `bash /home/gvoina/scripts/get_ha_sensor.sh <entity_id>`
* *Tip*: Use this to check:
* **E.ON Romania**: `sensor.eon_balance_568` or `sensor.eonromania_000000000068_citire_permisa`
Now you can check your gas metrics off-grid or from your terminal with:
agy "What is my current E.ON gas balance?"
agy will execute the query script and tell you the exact value!