This website uses Google Analytics and Advertising cookies, used to generate statistical data on how visitors uses this website (with IP anonymization) and to deliver personalized ads based on user prior visits to this website or other websites. [read more]
These cookies are disabled by default until your Accept/Reject Consent.
The Consent can be changed at any time by accesing the ePrivacy button located at the bottom of every page. Enjoy your visit!



iHidro: Hidroelectrica Integration for Home Assistant

One might ask about the benefits of a custom Home Assistant integration when official iOS, Android, and web applications already exist for Hidroelectrica accounts. For me, it comes down to convenience and centralized tracking. It gives me an automated way to submit self-read meter index updates—whether I'm away on vacation or simply don't want to check the meter manually. More importantly, it keeps both monthly and total energy consumption metrics clean and visible directly on my custom Home Assistant dashboard.

To bridge this gap without relying on manual app entry, I built two complementary projects: iHidroGo (a standalone Go client/library that interfaces directly with Hidroelectrica's SEW API server) and iHidroHA (the custom HACS integration that brings those API capabilities natively into Home Assistant as actionable services).

Pairing Hidroelectrica Index Submissions with Home Assistant Power Meters

Of course, to get the full benefit of this setup, adding a dedicated smart power meter like a Shelly PM to your Home Assistant ecosystem is ideal. When you're away on vacation, having an automated "digital" index ready to submit to Hidroelectrica makes all the difference—and a device like the Shelly PM tracks that continuous usage for you.

While a physical smart meter isn't strictly required to use the integration, installing a Shelly monitor in my main breaker panel (TGBT) is what actually sparked this project, allowing me to fully automate and benefit from the entire solution.

Integrating iHidroHA with Home Assistant

Instead of continuous background polling, iHidroHA introduces native Home Assistant actions (services) that give you direct, programmatic control over index submissions and history retrieval:

  • ihidro.submit_index: Submits your current index reading directly to the iHidro API.
  • ihidro.get_index_history: Fetches historical meter readings associated with your contract.

Installation via HACS

  1. Open HACS in Home Assistant → Click the three dots menu (top right) → Select Custom repositories.
  2. Add https://github.com/b247/iHidroHA with the category (Type) set to Integration.
  3. Click Download. HACS will trigger a system notification letting you know that Home Assistant needs a restart to load the integration.
  4. Navigate to SettingsDevices & ServicesAdd Integration → Search for iHidro.
  5. Enter your iHidro/Hidroelectrica account credentials and your UAN (Contract Number).

Automation Example: Automated Submission & Meter Reset

Here is how to automate the submission using a numeric helper (input_number). When the helper state updates, Home Assistant submits the index value via ihidro.submit_index. If the API call succeeds, it resets the local utility meter and fires a notification:

info Pro Tip: For a quick test drive, you can temporarily comment out the utility_meter.reset action and swap the trigger entity_id with your own Input Number helper (created via Settings → Devices & Services → Helpers).

alias: Submit iHidro index and Reset Shelly Monthly Meter
description: ""
triggers:
  - entity_id: input_number.shellypluspmminitgbt_em_offset
    trigger: state
conditions:
  - condition: template
    value_template: "{{ trigger.from_state.state not in ['unavailable', 'unknown'] }}"
  - condition: template
    value_template: "{{ trigger.to_state.state not in ['unavailable', 'unknown'] }}"
actions:
  - action: ihidro.submit_index
    data:
      value: "{{ trigger.to_state.state | int }}"
    response_variable: api_result

  - if:
      - condition: template
        value_template: "{{ api_result.success }}"
    then:
      - action: utility_meter.reset
        target:
          entity_id: sensor.hallway_shellypluspmminitgbt_meter
      - action: persistent_notification.create
        data:
          title: "iHidro Submission Success"
          message: "{{ api_result.output }}"
    else:
      - action: persistent_notification.create
        data:
          title: "iHidro Submission Failed"
          message: "{{ api_result.output }}"
mode: single

Setting Up Your Helpers and Custom Dashboard Card

Before adding the UI card to your Lovelace dashboard, you need to create three core helpers under Settings → Devices & Services → Helpers:

  1. Input Number (input_number.shellypluspmminitgbt_em_offset): Holds the submission trigger value. Updating this number fires the ihidro.submit_index action.
  2. Template Sensor (sensor.hallway_shellypluspmminitgbt_index): Computes your current physical index reading by combining your baseline offset with live Shelly meter accumulation. Use {{ (states('input_number.shellypluspmminitgbt_em_offset') | float(0) + states('sensor.hallway_shellypluspmminitgbt_meter') | float(0)) | round(2) }} but with your own IDs.
  3. Utility Meter (sensor.hallway_shellypluspmminitgbt_meter): Tracks your current cycle's energy consumption (kWh). It automatically resets back to zero upon a successful iHidro submission.
info Note on Entity Names: Be sure to adjust the entity IDs in the YAML snippet below (e.g., changing hallway_shellypluspmminitgbt) to match the actual names you assigned to your helpers and Shelly entities in Home Assistant.

Custom Dashboard Card UI

To pull everything together into a clean interface, pair your power meter metrics and interactive helper triggers using a custom:stack-in-card layout:

Home Assistant energy custom card showing real-time, monthly, and total meters with an interactive submission button.
type: custom:stack-in-card
title: ""
mode: horizontal
cards:
  - type: gauge
    entity: sensor.hallway_shellypluspmminitgbt_power
    name: ""
    min: 0
    max: 4500
    needle: true
    severity:
      green: 0
      yellow: 900
      red: 2300
    card_mod:
      style: |
        ha-card {
          border-top: 0;
          border-bottom: 0;
        }
  - type: vertical-stack
    cards:
      - type: button
        entity: sensor.hallway_shellypluspmminitgbt_index
        show_name: false
        show_state: true
        show_icon: false
        icon: mdi:transmission-tower
        tap_action:
          action: more-info
        name: ShellyPlusPMMiniTGBT EM Index
        color: var(--secondary-text-color)
        card_mod:
          style: |
            ha-card {
              border:0;
              padding-block-end:unset!important
            }
            ha-card span[class='state'] {
                color: #ffffff;
              }
      - type: button
        entity: input_number.shellypluspmminitgbt_em_offset
        show_name: false
        show_state: false
        show_icon: true
        icon: mdi:transmission-tower-export
        tap_action:
          action: more-info
        name: ShellyPlusPMMiniTGBT EM sync iHidro Oltenitei77 and send Index
        color: var(--secondary-text-color)
        card_mod:
          style: |
            ha-card {
              border: 0;
              padding-block:unset!important
            }
             ha-state-icon {
              color: var(--disabled-text-color) !important;
            }
      - type: button
        entity: sensor.hallway_shellypluspmminitgbt_meter
        show_name: false
        show_state: true
        show_icon: false
        tap_action:
          action: more-info
        name: ShellyPlusPMMiniTGBT Monthly Electricity Consumption Meter
        card_mod:
          style: |
            ha-card {
              border: 0;
              padding-block-start:unset!important
            }
            ha-card span[class='state'] {
              {% set m_kWh = states('sensor.hallway_shellypluspmminitgbt_meter') | float %}
              {% if m_kWh < 90 %}
                color: #4CAF50;  /* Green */
              {% elif m_kWh < 120 %}
                color: #FFB347;  /* Orange */
              {% else %}
                color: #F98787;  /* Red */
              {% endif %}
            }
  - type: gauge
    entity: sensor.hallway_shellypluspmminitgbt_current
    name: ""
    min: 0
    max: 16
    needle: true
    severity:
      green: 0
      yellow: 2
      red: 10
    card_mod:
      style: |
        ha-card {
          border-top: 0;
          border-bottom: 0;
        }

Happy hacking!

label_outline

Share this post on your favorite networks.
© Copyright 2017 b247.eu.org | Just another information technology blog - All Rights Reserved