Git Product home page Git Product logo

ide_api's Introduction

hacs_badge GitHub Release (latest SemVer including pre-releases) GitHub release (by tag)

i-DE (Iberdrola Distribución) API for Home Assistant

i-DE (Iberdrola Distribución) Home Assistant Custom Integration, providing realtime energy meter readings

Description

Adds integration with i-DE in Home Assistant

This sensor will update every hour.

Important: Keep in mind that each reading is done directly to your home meter, and it takes sometime to return a result. As per i-DE it may take up to 2 minutes to get a reading. This delay will also lead to Home Assistant starting slowly until a response from the meter is obtained.

Known Issues

  • By the moment, this integration is limited to one contract. Should you have more then one contract with i-DE, the integration will obtain the data for the main contract only.
  • On HA start/booting, if the sensor fails to obtain a response from the meter, the sensor will fail to be setup and further updates will not be performed. In case this happens, it is recommended to restart HA until everything works well.
  • The reading is done directly to your meter. Due to connectivity issues or i-DE server issues, you may not always obtain readings as expected. Keep in mind that sometimes a delay on the reading may occurr.
  • The reading only returns integer values. If from the last reading your meter indicates a variance minor then 1 kWh, the integration will not reflect any variance and that will only be recorded once the variance from the previous reading is greater then 1.

Getting Started

Dependencies

You should have an i-DE username and access to the Clients' website. You may register here: Área Clientes | I-DE - Grupo Iberdrola.

Make sure to complement all information to have an "Advanced User" profile.

Installation

- Manual method

  • Download/clone this repo
  • Copy the custom_components/ide folder into your custom_components folder into your HA installation
  • Restart HA

- HACS method (recommended)

  • Copy this repo URL

  • In the HACS section, add this repo as a custom one:

    Custom repository

    • On the "Repository" field put the URL copied before
    • On the "Category" select "Integration"
    • Click the "Download" button and download latest version.
  • Restart HA

How to configure

  • Edit your configuration.yaml (or your sensor.yaml without sensor:) file to add this sensor:
sensor:
  - platform: ide
    username: <username>
    password: <password>

Use the <username> and <password> you use on the i-DE webpage. (It is recommended to use the HA secrets files for security pourposes)

  • Restart HA

Usage

Sensors

Utility Meter sensors inside configuration.yaml

How to configure hourly, daily and monthly costs sensors

  • Edit your configuration.yaml file to add this sensor:
# UTILITY METER #
utility_meter:
  # HOME ENERGY #
  home_energy_hourly:
    source: sensor.ide_meter_reading
    cycle: hourly

  home_energy_daily:
    source: sensor.ide_meter_reading
    cycle: daily

  home_energy_monthly:
    source: sensor.ide_meter_reading
    cycle: monthly

  home_energy_cost_hourly:
    source: sensor.home_energy_cost
    cycle: hourly

  home_energy_cost_daily:
    source: sensor.home_energy_cost
    cycle: daily

  home_energy_cost_monthly:
    source: sensor.home_energy_cost
    cycle: monthly

In the sensor.yaml file or under sensor in configuration.yaml

  • With the cost calculations template (inside your configuration.yaml file) as:
# ENERGY COST #
- platform: template
  sensors:
    home_energy_cost:
      friendly_name: "Home Energy Cost"
      unit_of_measurement: ""
      value_template: >
        {% if is_state_attr('sensor.pvpc', 'period', 'P1') %} {% set peaje=states('input_number.peaje_energia_p1') | float %}
        {% elif is_state_attr('sensor.pvpc', 'period', 'P2') %} {% set peaje=states('input_number.peaje_energia_p2') | float %}
        {% elif is_state_attr('sensor.pvpc', 'period', 'P3') %} {% set peaje=states('input_number.peaje_energia_p3') | float %}
        {% endif %}
        {{ (( states('sensor.home_energy_hourly') | float * (peaje + states('sensor.pvpc') | float) ) * states('input_number.impuesto_energia') | float * states('input_number.iva_energia') | float) | round(3) }}

To complement the cost calculation, I consider the costs of Toll, Energy Tax and VAT. For that create some "helpers" with input_number.

  • input_number.impuesto_energia (%) >> 1.051127
  • input_number.iva_energia (%) >> 1.10
  • input_number.peaje_energia_p1 (this what you have in the invoice)
  • input_number.peaje_energia_p2 (this what you have in the invoice)
  • input_number.peaje_energia_p3 (this what you have in the invoice)
  • input_number.peaje_energia_potencia_p1 (this what you have in the invoice)
  • input_number.peaje_energia_potencia_p2 (this what you have in the invoice)

Toll p1 Power p1

Once created, you can define the amounts in the box that appears in the details of each input_number or in Developer Tools / States

Version History

0.1.1
- Rename sensor to avoid breaking long-term statistics.
- Rename class to avoid name conflicts with other components.
0.1.0
- Changes to README.md
- Rename sensor call and class
- Update to production-ready for deployment on HACS, via Custom Repositories, with version control
0.0.3
- Update version number to 0.0.3
0.0.3a - Debug log Update and Security Fix
- Fix debug log target file, causing performance issues on HA
- Fix security issue, where login details to IDE where stored as plain text on the log file
- Update versioning across all files
- Update HACS release
0.0.2
- Removed b from versioning
0.0.1b - Initial Beta release
- Beta Release of iDE Energy Monitor Custom Integration for Home Assistant

Authors

Contributions

Credits

  • hectorespert - The base API used for the sensor is the python-oligo package developed by him.

License

This project is licensed under the GNU General Public License v3.0 License - see the LICENSE file for details

Disclaimer

THIS PROJECT IS NOT IN ANY WAY ASSOCIATED WITH OR RELATED TO THE IBERDROLA GROUP COMPANIES OR ANY OTHER. The information here and online is for educational and resource purposes only and therefore the developers do not endorse or condone any inappropriate use of it, and take no legal responsibility for the functionality or security of your devices.

ide_api's People

Contributors

aaronfc avatar ad-ha avatar alessbarb avatar davefx avatar hectorespert avatar ricardoletosa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

ide_api's Issues

Platform error sensor.ide - No module named 'dateutil'

Hi!

I'm looking to update Home Assistant to new version 2022.2, but when passing the Check Configuration tool, I get this error in the log:

Platform error sensor.ide - No module named 'dateutil'

Do you know how can I solve it? It's safe to update anyway?

Posibilidad de crear un sensor para los kwh exportados

Acabo de ver la integración y la he instalado. Me parece una maravilla.
No sé si es posible pero sería interesante que también pudieramos obtener los datos de la energía exportada, para el caso de quienes tienen instalaciones fotovoltaicas conectadas a la red.
Gracias por vuestro trabajo.

README

Fantástico trabajo el vuestro. Sólo pediros una cosa, cuando tengáis un momento actualizad README para incluir lo que bien indicáis en este post: https://community.home-assistant.io/t/iberdrola-distribucion-i-de-energy-monitor-beta-custom-component-released/326602/38

Facilitará la implementación. Yo me lo acabo de bajar de HACS integrando tu repositorio como nuevo repositorio de Integración y ahora voy a configurar configuration.yaml añadiendo lo que indicas en el post.

Si surge cualquier cosa te aviso con una nueva issue.

Si necesitas cualquier ayuda estoy disponible, mis conocimientos de programación son limitados, pero lo que pueda te ayudo.

De nuevo, fantástico trabajo. ¡Muchas gracias!

Tiempo de Escaneo

Buenos días,

¿Se podría añadir el tiempo de escaneo como variable externa? Es decir , sino pongo la variable en yaml por defecto por ejemplo 60 minutos, pero también tener la opción de informarla mediante yaml

Add multicontract capabilities

Related with #18

Add possibility to have readings for multiple contracts. Should support multi-entries to configuration and multi-sensors.

version 0.2 beta1 sensor no disponible

Tengo instalada la version beta1 de la nueva version de codigo pero sigue apareciendo como sensor no disponible. aparentemente mi cuenta no esta baneada ya que desde la pagina de I-De accedo sin problemas con mis credenciales.
Alguna idea?

Add Sensor Attributes

Currently the sensor only shows the meter readings. Would be good to include further sensors or attributes:

  • No. Contrato
  • CUPS
  • Telegestionado
  • Fecha última actualización
  • Potencia máxima (contratada)

Restore previous state on HA Restart

If the reading from i-De fails on restart, the sensor is not deployed and will be unavailable.

Change sensor to RestoreEntity and add the necessary processes, so if the reading fails the sensor is available and tries to update whenever possible

Problem after first update

After first configuration and first update of the value, i got this error on the consecuents calls...

Let me know if you need more information

PS: great job, please, let me know if you need help developing or debuggin!

image

Logger: homeassistant.helpers.entity
Source: custom_components/ide/ide_api.py:160
Integration: i-DE Energy Monitor (documentation, issues)
First occurred: 12:54:11 (1 occurrences)
Last logged: 12:54:11

Update for sensor.ide_meter_reading fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 487, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 699, in async_device_update
    await task
  File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/ide/sensor.py", line 149, in update
    meter = ides.watthourmeter()
  File "/config/custom_components/ide/ide_api.py", line 169, in watthourmeter
    return self.measurement()["meter"]
  File "/config/custom_components/ide/ide_api.py", line 160, in measurement
    "id": json_response["codSolicitudTGT"],
KeyError: 'codSolicitudTGT'

Obtener consumo en W en vez de kW

Hay alguna posibidad de añadir la opción de obtener en W en vez de en KW el consumo del contador?

Actualmente no admite decimales la lectura, pero si en lugar de obtener los kW obtenemos los W, y luego mediante un Template lo convertimos en kW o lo que queramos, si que podríamos tener los consumos más realistas con kW con decimales

Actualmente a mi está consulta de Oligo me devuelve en W en vez de kW (hay que quitar la fecha, ya que lo tengo para que me dé el consumo desde el día 1), creo que lo postee también en uno de los comentarios del Git de Oligo

package = "oligo"
try:
	     __import__(package)
except:
		os.system("pip install "+ package)
#
from oligo import Iber
from datetime import date, timedelta
#
connection = Iber()
connection.login("[email protected]", "xxxxxxxx")
#
from_date = date.today().replace(day=1)
#until_date = date.today() - timedelta(days=2)
until_date = date.today()
#
consumo = connection.consumption(from_date, until_date)
#
#print(consumo)
quitanone = [i for i in consumo if i] 
#Damos en Watios
suma=sum(quitanone)
#Convertimos en Kw
enkw=(suma)/1000
#print("Hasta", (until_date))
print(suma)

Add contract number to configuration and sensor readings

Currently, the reading on i-DE is retrieved for the last contract checked on the web (if more then one is available), so the configuration should include a contract number to ensure that the correct reading is obtained and not mixed with other contract

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.