GithubHelp home page GithubHelp logo

ldotlopez / ha-ideenergy Goto Github PK

View Code? Open in Web Editor NEW
73.0 13.0 13.0 1.03 MB

ideenergy integration for home-assistant

License: GNU General Public License v3.0

Python 100.00%
home-assistant home-assistant-component energy automation spain energy-consumption

ha-ideenergy's Introduction

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

hacs_badge hassfest validation HACS validation

GitHub Release (latest SemVer including pre-releases) CodeQL Code style: black

ideenergy integration for home-assistant

i-DE (Iberdrola Distribución) Custom Integration for Home Assistant, providing sensors for Spanish Energy Distributor i-DE.

This integration requires an advanced user profile on i-DE website.

⚠️ Make sure to read the 'FAQ', 'Dependencies' and 'Warning' sections

Features

  • Integration with the Home Assistant Energy Panel.

  • Accumulated and Instant consumption sensors.

  • Historical sensors (both consumption and solar generation) with better (sub-kWh) precision. This data is not realtime and usually has a 24-hour to 48-hour offset.

  • Support for multiple contracts (service points).

  • Configuration through Home Assistant Interface without the need to edit YAML files.

  • Update algorithm to read the meter near the end of each hourly period (between minute 50 and 59) with a better representation of consumption in the Home Assistant energy panel.

  • Fully asynchronous and integrated with HomeAssistant.

Dependencies

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

It also necessary to have an "Advanced User" profile. Should you not have one already, you need to fill the request for from your Profile Area.

Installation

Using HACS (recommended)

  1. Copy this repository URL: https://github.com/ldotlopez/ha-ideenergy

  2. In the HACS section, add this repository as a custom one:

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

Custom repositorysitory

  1. Restart HA

  2. Configure the integration

  • (Option A) Click the "Add integration" button → Open your Home Assistant instance and start setting up a new integration.

  • (Option B) Go to "Settings" "Devices & Services" and click "+ ADD INTEGRATION" and select "i-de.es energy sensors".
    image

  1. Follow the configuration steps: provide your credentials for access to i-DE and select the contract that you want to monitor. (Should you need to add more contracts, just follow the previous step as many times as needed).

Manually

  1. Download/clone this repository: https://github.com/ldotlopez/ha-ideenergy

  2. Copy the custom_components/ideenergy folder into your custom_components folder into your HA installation

  3. Restart HA

  4. Configure the integration

  • (Option A) Click on this button → Open your Home Assistant instance and start setting up a new integration.
  • (Option B) Go to "Settings" → "Devices & Services" and click "+ ADD INTEGRATION" and select "i-de.es energy sensors".
    image
  1. Follow the configuration steps: provide your credentials for access to i-DE and select the contract that you want to monitor. (Should you need to add more contracts, just follow the previous step as many times as needed).

Snapshots

Accumulated energy sensor

snapshot

Historical energy sensor

snapshot

Configuration wizard

snapshot snapshot

Warnings

This extension provides a 'historical' sensor to incorporate past data into your Home Assistant database. For safety reasons, the sensor is disabled by default and must be enabled manually.

☠️ The historical sensor is based on a highly experimental hack and could corrupt your database and/or statistics. Use with extreme caution and at your own risk.

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.

ha-ideenergy's People

Contributors

ad-ha avatar aguilaair avatar juliocc avatar kikediazfernandez avatar ldotlopez avatar lopezl avatar luca-angemi avatar sumolari 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  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  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  avatar  avatar  avatar  avatar  avatar  avatar

ha-ideenergy's Issues

Since 4th of December no updates anymore.

My installation was satisfactory until the 4th of October, around noon. Since then, no further data is coming in. I have re-downloaded 2.0.2, but that did not help.

Home Assistant 2023.10.1
Supervisor 2023.10.0
Operating System 11.0.rc1
Frontend 20231005.0 - latest

No tengo acceso a los datos?

Desde hace unos días veo que no tengo acceso a los datos incluso reiniciando, y de hecho ahora he quitado la integración y ahora no me deja entrar.

He cambiado la contraseña en la web de i-de y nada...

Por la web sí puedo ver todo, pero en la integración nada de nada...

Me dice algo de la autenticación

Possible bug after upgrade from old version

I have detected some problems with dirty (vs. fresh installs) due new statistics calculation method.
This error is related to upgraded installations from previous version, not fresh ones.

Errors logs shows exceptions like KeyError related to 'sum' or incompatible types in '+' operator.

While I work on a stable solution here are some tips if you're confident with command line. Each one is individual, if option A works for you just stop mangling things. If not, try next option if you understand what are you doing.

Remember to backup everything before proceed. I can't give support beyond fixing the upgrade path, recovering from failed attempt to fix is outside limits.

A. Try to update to v2.0.1

B. Clean up your database:

  • Write down related historical sensors: everything like sensor.esXXXX_historical
  • Stop homeassistant
  • Open the sqlite prompt
    sqlite 'config/home-assistant_v2.db'
  • Get the metadata_id of each sensor:
    select id from statistics_meta where statistic_id = 'sensor.esXXXXX_historical;' (mine is 114)
  • Update statistics_meta:
    update statistics_meta set has_mean=1, has_sum=1 where id = <your_id>; (remember to replace <your_id> with yours)
  • Delete incorrect values from statistics:
    delete from statistics where (mean is null or sum is null or state is null) and metadata_id = <your_id>;
  • Start home-assistant

C. Wipe database: Just delete (ore temporally rename) the config/home-assistant_v2.db file, you will lose some history and stats, but anything else will stay.

D. Wait. Statistics are a complex stuff and importing data from past makes it worse. I'm trying my best to fix upgrade path

Provide an energy return sensor (solar panels)

Basically title.

I don't have access to any contract with energy return, so I need some information from people with any kind of energy generation installation.

Please send me logs with information.

  • Option A: from homeassistant:

Activate debug from ideenegy, in configuration.yaml insert this:

logger:
  logs:
    ideenergy: debug
    custom_components.ideenergy: debug

Send me lines with this type of info:

ha-core | 2022-05-11 03:52:35 DEBUG (MainThread) [custom_components.ideenergy.api] Got reply, raw data: {'valMagnitud': '80.0', 'valInterruptor': '1', 'valEstado': '09', 'valLecturaContador': '45882', 'codSolicitudTGT': '011445362000'}
  • Option B: using ideenergy command line
  1. Download and install ideenergy pyth on module (pip install ideenergy or whatever suits you)
  2. Send me the output of running python -m ideenergy --username xxxxx --password xxxxx --get-measure --retries 3

I-de does not download the daily history of the counter

Hello.

I have been observing for several days that the historical data of the counter is not recovered, that is, the daily hourly graph that is obtained the next day.

I have this error in the log:

Este error se originó a partir de una integración personalizada.

Logger: homeassistant
Source: custom_components/ideenergy/historical_sensor.py:190
Integration: i-DE Energy Monitor (documentation, issues)
First occurred: 09:56:08 (126 occurrences)
Last logged: 19:28:46

Error doing job: Future exception was never retrieved
Traceback (most recent call last):
File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/ideenergy/historical_sensor.py", line 190, in _save_states_into_recorder
cutoff = latest_db_state.last_updated.replace(tzinfo=timezone.utc)
AttributeError: 'NoneType' object has no attribute 'replace'

Does it happen to anyone else?

Not working again

I un- and reinstalled the old version and then finally it was back working.
Then I saw there's an actualization to 2.0
Did that enthusiastically and at first it worked, but after a few hours the updates stopped. Now I'm without new data for about 2 days again.
I uninstalled the new version completely, restarted hass, installed it again, but that doesn't change anything.
Where can I find information for debugging?

'HistoricalState' object has no attribute 'when'

Describe the bug
When starting HA, the following error log appears:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/homeassistant_historical_sensor/sensor.py", line 155, in async_write_ha_historical_states
    await self._async_save_states_into_statistics(hist_states)
  File "/usr/local/lib/python3.10/site-packages/homeassistant_historical_sensor/sensor.py", line 203, in _async_save_states_into_statistics
    statistics_data = await self.async_calculate_statistic_data(
  File "/config/custom_components/ideenergy/sensor.py", line 107, in async_calculate_statistic_data
    hist_states = [x for x in hist_states if x.when >= latest["end"]]
  File "/config/custom_components/ideenergy/sensor.py", line 107, in <listcomp>
    hist_states = [x for x in hist_states if x.when >= latest["end"]]
AttributeError: 'HistoricalState' object has no attribute 'when'

To Reproduce

  1. I had wip/historical-sensor branch running. It stopped working when I updated HA to 2023.3.X due to changes in DB.
  2. As mentioned in #34, I pulled the main branch, changed the HISTORICAL_PERIOD_LENGHT constant to timedelta(days=15), and restarted everything.

Environment

  • HomeAssistant version: 2023.3.4
  • ideenergy integration version: main branch, commit 288ab92
  • Instalation method: docker
  • i-de.es advanced user: yes
  • Did I read the FAQ?: of course 😅

Expected behavior
After restarting HA, I expected the integration to download past consumption data and import it into Energy dashboard.

Logs
Working on it to avoid leaking data

Screenshots
N/A

Additional context
Like said, I came from wip/historical-sensor branch due to #34. I have 2 contracts, one is "disabled" but it has never been an issue before.

Sensor en tiempo real

Hola buenas, primero que nada agradecer tu trabajo. Leyendo el readme, veo que indicas que hay un sensor en tiempo real de consumo, y viendo el archivo sensors.yaml, veo que también está, pero al añadir la integración no me aparece. Es un problema conocido o es algo mío particular?

Instalación

Hola:
He instalado el componente en Homeassistant a través de HACS.
Sin embargo, al reiniciar no sé cómo tengo que continuar para enlazar con i-DE. Como saco el wizard para conectar?
Tampoco me parece ningún sensor nuevo…
He probado a reinstalar y reiniciar de nuevo…

Error in historical dat MariaDB

Before filling a bug please provide as much as information as possible.
Not all information is required but the more the better.

Stick to English if bug is about code, Spanish is OK if bug is about configuration.

Describe the bug
Since updating HA to 2023.2 I am getting this errors on logs.
Today I found that since 14/2/23 it has occurred more than 5.000 times

Logger: homeassistant.components.recorder.util
Source: components/recorder/util.py:125
Integration: Recorder (documentation, issues)
First occurred: 22:53:42 (4 occurrences)
Last logged: 22:58:23

Error executing query: (MySQLdb.IntegrityError) (1451, 'Cannot delete or update a parent row: a foreign key constraint fails (`homeassistant`.`states`, CONSTRAINT `states_ibfk_2` FOREIGN KEY (`old_state_id`) REFERENCES `states` (`state_id`))') [SQL: DELETE FROM states WHERE states.entity_id = %s AND states.last_updated_ts >= %s] [parameters: ('sensor.icp_esXXXXXXX64sp_historical', 1676160000.0)] (Background on this error at: https://sqlalche.me/e/14/gkpj)
Error executing query: (MySQLdb.IntegrityError) (1451, 'Cannot delete or update a parent row: a foreign key constraint fails (`homeassistant`.`states`, CONSTRAINT `states_ibfk_2` FOREIGN KEY (`old_state_id`) REFERENCES `states` (`state_id`))') [SQL: DELETE FROM states WHERE states.entity_id = %s AND states.last_updated_ts >= %s] [parameters: ('sensor.es00XXXXXXX4sp_historical_power_demand', 1596146400.0)] (Background on this error at: https://sqlalche.me/e/14/gkpj)

To Reproduce
Steps to reproduce the behavior:
I do nothing. The error just appears.

Environment

  • HomeAssistant version 2023.2.5
  • ideenergy integration version 1.0.3
  • Instalation method HassOS
  • i-de.es advanced user [yes / no] Not sure what this is
  • Did I read the FAQ?: yes

Expected behavior
No error should appear

Logs
Pasted above

Screenshots
No aplicable

Additional context
2023.2 has introduced some changes in recorder and database. Maybe it has something to do with it.
I have disabled the historical sensors, but I thoght I had to report this.

Error en histórico experimental

Al intentar añadir el histórico me salta el siguiente error:

2022-08-18 19:45:20 DEBUG (MainThread) [custom_components.ideenergy.historical_state] Got 168 measures from sensor
2022-08-18 19:45:20 DEBUG (MainThread) [custom_components.ideenergy.historical_state] Executor job set to write them
2022-08-18 19:45:20 DEBUG (MainThread) [custom_components.ideenergy.historical_state] sensor.icp_es00000000000mw_historical: updating each 21600.0 seconds
2022-08-18 19:45:20 DEBUG (DbWorker_2) [custom_components.ideenergy.historical_state] Writing states on recorder
2022-08-18 19:45:21 ERROR (DbWorker_2) [homeassistant.components.recorder.util] Error executing query: (sqlite3.IntegrityError) FOREIGN KEY constraint failed
[SQL: DELETE FROM states WHERE states.state_id = ?]
[parameters: (708,)]

Mismo valor en dos contratos diferentes

Buenos días!
Tengo dos contratos con Iberdrola y en los dos me muestra el mismo valor.
He probado teniendo sólo el sensor 1, teniendo sólo el sensor 2 y teniendo simultáneamente sensor 1 y 2.
Captura de pantalla 2022-05-19 123109

Setup failed for custom integration ideenergy: Unable to import component: Exception importing custom_components.ideenergy

Using Home Assistant Core 2023.1.3, HACS v1.29.1, I-DE Energy Monitor v1.0.1 on a Raspberry pi 3B+ with bullseye 64b and python 3.9.2

HASS loads, HACS loads but the ideenergy sensor fails setup.

Full text for exception raised in HASS log is:

Jan 11 23:59:34 TEST01 hass[104948]: 2023-01-11 23:59:34.626 ERROR (MainThread) [homeassistant.loader] Unexpected exception importing component custom_components.ideenergy
Jan 11 23:59:34 TEST01 hass[104948]: Traceback (most recent call last):
Jan 11 23:59:34 TEST01 hass[104948]:   File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/loader.py", line 725, in get_component
Jan 11 23:59:34 TEST01 hass[104948]:     cache[self.domain] = importlib.import_module(self.pkg_path)
Jan 11 23:59:34 TEST01 hass[104948]:   File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module
Jan 11 23:59:34 TEST01 hass[104948]:     return _bootstrap._gcd_import(name[level:], package, level)
Jan 11 23:59:34 TEST01 hass[104948]:   File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
Jan 11 23:59:34 TEST01 hass[104948]:   File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
Jan 11 23:59:34 TEST01 hass[104948]:   File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
Jan 11 23:59:34 TEST01 hass[104948]:   File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
Jan 11 23:59:34 TEST01 hass[104948]:   File "<frozen importlib._bootstrap_external>", line 790, in exec_module
Jan 11 23:59:34 TEST01 hass[104948]:   File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
Jan 11 23:59:34 TEST01 hass[104948]:   File "/home/homeassistant/.homeassistant/custom_components/ideenergy/__init__.py", line 34, in <module>
Jan 11 23:59:34 TEST01 hass[104948]:     from .barrier import TimeDeltaBarrier, TimeWindowBarrier  # NoopBarrier,
Jan 11 23:59:34 TEST01 hass[104948]:   File "/home/homeassistant/.homeassistant/custom_components/ideenergy/barrier.py", line 49, in <module>
Jan 11 23:59:34 TEST01 hass[104948]:     param: str | int, default_tzinfo=datetime.timezone.utc, optional=False
Jan 11 23:59:34 TEST01 hass[104948]: TypeError: unsupported operand type(s) for |: 'type' and 'type'
Jan 11 23:59:34 TEST01 hass[104948]: 2023-01-11 23:59:34.632 ERROR (MainThread) [homeassistant.setup] Setup failed for custom integration ideenergy: Unable to import component: Exception importing custom_components.ideenergy

Precio Energia

La integración de ide-api (https://github.com/ad-ha/ide_api) disponía de la posibilidad de calcular los precios de los consumos, dado que dicha integración se ha deprecado en favor de esta, y para evitar tener las dos simultáneas, haciendo llamadas api en paralelo provocando baneos, sería muy interesante la posibilidad de migrar esos sensores a esta integración.

Un saludo y gracias por el trabajo, es fantástico!

issue after update to Home Assistant 2023.1.0

Home Assistant 2023.1.0 Supervisor 2022.12.1 Operating System 9.4 Frontend 20230104.0 - latest

Logger: homeassistant.util.package
Source: util/package.py:98
First occurred: 9:10:36 AM (3 occurrences)
Last logged: 9:10:53 AM

Unable to install package ideenergy==1.0.0rc1: ERROR: Cannot install ideenergy==1.0.0rc1 because these package versions have conflicting dependencies. ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts [notice] A new release of pip available: 22.3 -> 22.3.1 [notice] To update, run: pip install --upgrade pip

User is not logged or session is too old

Buenas,

Desde ayer, incluso después de reiniciar HA, me ha empezado a salir este mensaje de error:

image

Que me imagino que vendrá relacionado con esto:

image

Un saludo

Stopped working yesterday

My installation worked for many months without issues. It stopped reading the latest data on the 31st of May. I still can log in to my account with the mobile app and current data is shown there.

Any ideas?

Still interruptions with every update of HA and losing data

Hi,
There was an update of HA core today and after the restart ide-energy does not work anymore. Isn’t there a way to have a smooth update policy as this happens with every update of HA? Plus I lost all my data from last year with the update to 1.0.1 from 1.0.rc2.

Any ideas what might me wrong in my HACS installation and how to fix this?

Problems after 2022.3 HA update

Hi!

I just updated to Home Assistant 2022.3 and this integration is no longer working for me. This is what I can tell from the logs:

Logger: homeassistant.setup
Source: setup.py:298
First occurred: 7 de marzo de 2022 23:59:36 (1 occurrences)
Last logged: 7 de marzo de 2022 23:59:36

Unable to prepare setup for platform ideenergy.sensor: Platform not found (cannot import name 'MappingProxyType' from 'homeassistant.core' (/usr/src/homeassistant/homeassistant/core.py)).

Have tried to restart HA some times, but didn't seem to fix the issue.

Any ideas?

Posibilidad de usar los utility meters / usage of utility-meters

Aqui:
https://github.com/ad-ha/ide_api
se utilizan utility-meters con varios helpers para calcular el consumo mensual, semanal, diario...ademas del coste

Es posible integrarlo de algún modo en la extensión para no tener que meterlo desde el yaml?


Here:
https://github.com/ad-ha/ide_api
Utility meters with various helpers are used to calculate monthly, weekly, daily consumption...as well as the cost.

Is it possible to integrate it in some way in the extension so as not to have to add it from the yaml?

Add Additional 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)

This would add to the already provided instant consumption attribute.

I-de meter reading down or broken?

Hello,

Not a problem directly related to this integration, but I don't get any meter reading in HA.

When I try to use PostMan to do the API calls myself, I get an error: "Se ha producido un error. No se puede completar la operación solicitada."

When I check the i-de site with my account, I see no readings after 7th of july and with "monitor de consumo" > "Consult potencia en tiempo real" I get an "Error de conexión".

Anybody else having this problem? My account is still an "Usuario Avanzado."

Thanks

Alain

Incorrect value

Only the accumulated_consumption gives me a reading at all, the other sensors are ‚unknown‘. But even this is not correct, it reports a ‚state‘ of 2765.0 kWh whereas the thing I‘d actually want to see is the ‚last power reading‘ which is 80 (just got a new meter intalled). I don‘t think I can mess up a lot myself?
BTW also tried using the other meter I have in my account but they get totally mixed up.

Data 1 hour off?

I have v1.0.4 with only the historical sensor enabled and I see data is 1 hour off compared with data collected with Shelly EM.
Also, if you look at the history, and compares the graphic with the one that Iberdrola (not I-DE) shows, data from 11:00 to 12:00 for example is shown as the 12:00-13:00 interval in HA
The API seems to return the accumulated consumption in the previous hour. My last (redacted) log for 'successful' update:

2023-05-31 14:41:32.416 DEBUG (MainThread) [custom_components.ideenergy.datacoordinator] Updating data set: <DataSetType.HISTORICAL_CONSUMPTION: 2>
2023-05-31 14:41:32.416 DEBUG (MainThread) [custom_components.ideenergy.datacoordinator] HISTORICAL_CONSUMPTION update allowed
2023-05-31 14:41:33.314 DEBUG (MainThread) [custom_components.ideenergy.datacoordinator] HISTORICAL_CONSUMPTION successfully updated
2023-05-31 14:41:33.314 DEBUG (MainThread) [custom_components.ideenergy.datacoordinator] Finished fetching [email protected]/xxxxxxxx coordinator data in 0.898 seconds (success: True)
2023-05-31 14:41:33.316 DEBUG (MainThread) [custom_components.ideenergy.historical_sensor] sensor.es0021xxxxxxxxxxxxxxsg_historical_consumption: Got 168 historical states from API
2023-05-31 14:41:33.389 DEBUG (DbWorker_0) [custom_components.ideenergy.historical_sensor] Deleted 0 invalid states
2023-05-31 14:41:33.399 DEBUG (DbWorker_0) [custom_components.ideenergy.historical_sensor] sensor.es0021xxxxxxxxxxxxxxsg_historical_consumption: lastest state found: 0.439 @ 2023-05-30 22:00:00+00:00
2023-05-31 14:41:33.399 DEBUG (DbWorker_0) [custom_components.ideenergy.historical_sensor] sensor.es0021xxxxxxxxxxxxxxsg_historical_consumption: no new states from API

The latest state, corresponding to 23:00-24:00, is collected as 00:00 (22:00 UTC)
"Successful" because yesterday's data still does not appear, by the way.

Originally posted by @kikediazfernandez in #34 (comment)

Request for testing

Hi,

I just uploaded a new branch: wip/historical-sensor

In this branch I splited the current hack for historical sensors to a new repository: https://github.com/ldotlopez/ha-historical-sensor.

But.. why? This new module is reusable for other projects and other household supplies, like water or gas (check HomeAssistant historical sensor README) and, the more important, is capable of generating statistics. (See #25)

In our case this means that we can have float-precision readings (but not in real time) and a more resilent updates. Realtime sensor (Accumulated consumption) can be disabled and relay solely on the Historical sensor (Historical consumption) which is more precise, resilent and doesn't require the "advance user".

I'm asking for some testing. Expect weird and broken stuff and data loss, backup your data.

Thanks.

Captura desde 2023-01-17 13-48-57

Captura desde 2023-01-17 13-48-39

Obtener valor de potencia

Hola, ahora mismo esta integración de i-de para HA solo obtiene el valor del contador para integrarlo con el panel de energía de HA, muchas veces las peticiones a i-de fallan por lo que el contador en la grafica de HA tiene "saltos", imagino que por peticiones que no dan respuesta... una pena, pero mi propoesta es la de añadir otros valores como la potencia consumida en el momento.

Según he visto en las peticiones de la app, se hacen a https://www.i-de.es/consumidores/rest/escenarioNew/obtenerMedicionOnline/24 con los headers de cookie...etc

Y se obtiene una respuesta de este tipo:

{
  "valMagnitud": "240.0",
  "valInterruptor": "1",
  "valEstado": "09",
  "valLecturaContador": "17147",
  "codSolicitudTGT": "0125*******900"
}

Sería posible almacenar el valor de valMagnitud en un sensor de tal manera que podamos ver que consumo instantaneo hay en la vivienda?
No se que límites permite la API de i-de... parece fallar mas que una escopeta de feria, pero sería ideal obtener este valor una vez por minuto por ejemplo.

Gracias!

No puedo agregar el repositorio con la url

Buenas;

En primer lugar agradecer el trabajo realizado en este proyecto. Espero poder probarlo pronto porque tiene muy buena pinta.

El tema es que he tratado de agregar el repositorio en complementos de mi HA pero dice que no es un addon correcto.

https://github.com/ldotlopez/ideenergy is not a valid add-on repository

He buscado en otras opciones de los menús pero el único sitio donde puedo agregar repositorios es en complementos pero no me deja.

¿sabrías darme alguna pista para ver que estoy haciendo mal o debo ir a la opción de copia manual?

Gracias

Estado desarrollo

Hola Luis, que tal va el desarrollo de esta integracion? Estaba mirando para hacer la mia pero veo que tu ya te pusiste manos a la obra, te agradeceria si pudieras completar el README con la info sobre como usar la integracion, como y donde añadir nuestros datos user/pass, MQTT, y otras cosas que consideres necesarias

Accumulated Consumption Unknown

Hello,

I had the other intregatios working and I had to change the e-mail. The procedure from iberdrola required me to delete that account and create another one.

I created a new account wit iberdrola and I have deleted the old integration. When I tried to re installed I have noticed thata new integration replaced the old one. This one was easier to intstall, no need to use the configuration yaml, I have two contracts, it let me choose one but when I create the dashboard i get two errors:

statistics_not_defined
sensor.es******************_accumulated_consumption

Entity unavailable
The state of these configured entities are currently not available:
sensor.es*********************************_accumulated_consumption (unknown)

Could you help? Am I doing something wrong. I have waited several days before I write this note.

Thanks in advance.

Before filling a bug please provide as much as information as possible.
Not all information is required but the more the better.

Stick to English if bug is about code, Spanish is OK if bug is about configuration.

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Environment

  • HomeAssistant version [e.g. 2023.2.1]
  • ideenergy integration version [e.g 1.0.0, main]
  • Instalation method [HassOS, docker, pip, pipenv]
  • i-de.es advanced user [yes / no]
  • Did I read the FAQ?: no

Expected behavior
A clear and concise description of what you expected to happen.

Logs

  • Enable debug level for ideenergy and custom_components.ideenergy. See HomeAssistant docs
  • Paste or reference (via gist or pastebin) relevant info.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

I-DE logs in correctly, but data does not show up in energy dashboard (had corruputed database)

Since the 4th of October, my energy dashboard and the I-DE consumption have not worked anymore. Probably, this has been caused by an update on the beta channel that corrupted my SQLite database. Multiple re-installations of SQLite, MariaDB, and I-DE did not bring back data to the energy dashboard. The energy dashboard is empty, and both relevant sensors show the data from the 4th. I can see that the I-DE energy plugin logs in correctly, but data needs to be written to the correct tables.

Describe the bug
Data should show up as it did before the corrupt database.

To Reproduce
I have deleted and reinstalled databases (Sqlite, MariaDB) or I-DE and have yet to return the energy board data successfully.

Environment
Raspi 4 - no docker
Home Assistant 2023.10.2
Supervisor 2023.10.0
Operating System 10.5
Frontend 20231005.0 - latest

Expected behavior
Data written into the energy dashboard

Logs
2023-10-13 09:54:19.720 INFO (MainThread) [ideenergy] <ideenergy.Client username=[email protected], contract=215315583>: '215315583' contract selected
2023-10-13 09:54:19.720 INFO (MainThread) [ideenergy] <ideenergy.Client username=[email protected], contract=215315583>: successful authentication
2023-10-13 09:58:50.476 INFO (MainThread) [ideenergy] <ideenergy.Client username=[email protected], contract=215315583>: '215315583' contract selected
2023-10-13 09:58:50.477 INFO (MainThread) [ideenergy] <ideenergy.Client username=[email protected], contract=215315583>: successful authentication

Improve README

Improve README documentation, with further details on installation and HACS support.

Platform ideenergy does not generate unique IDs.

Good morning, after installing ideenergy and creating several contracts, by adding integration again, only the first contract show values. Second and third contracts do not show values for accumulated consumption.

E5034B5F-C180-4922-AD57-2F25F67E27D8_4_5005_c

On HA log the following lines appear:

2023-02-02 13:56:19.348 ERROR (MainThread) [homeassistant.components.sensor] Platform ideenergy does not generate unique IDs. ID accumulated-consumption already exists - ignoring sensor.es0021*******_accumulated_consumption
2023-02-02 13:57:49.128 ERROR (MainThread) [homeassistant.components.sensor] Platform ideenergy does not generate unique IDs. ID accumulated-consumption already exists - ignoring sensor.es0021*******_accumulated_consumption
2023-02-02 14:01:28.681 ERROR (MainThread) [homeassistant.components.sensor] Platform ideenergy does not generate unique IDs. ID accumulated-consumption already exists - ignoring sensor.es0021*******_accumulated_consumption
2023-02-02 14:01:28.683 ERROR (MainThread) [homeassistant.components.sensor] Platform ideenergy does not generate unique IDs. ID historical-consumption already exists - ignoring sensor.es0021*******_historical_consumption

No hay forma que cargue, antes funcionaba perfectamente

Pensaba que se trataba por la nueva actualización de HA pero no. Esto es lo que pone en los logs de error:

Este error se originó a partir de una integración personalizada.

Logger: homeassistant.config_entries
Source: custom_components/ideenergy/init.py:67
Integration: i-DE Energy Monitor (documentation, issues)
First occurred: 11:31:35 (2 occurrences)
Last logged: 11:32:35

Error setting up entry Iberdrola Distribución España - meter reading for ideenergy
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 387, in async_setup
result = await component.async_setup_entry(hass, self)
File "/config/custom_components/ideenergy/init.py", line 67, in async_setup_entry
contract_details = await api.get_contract_details()
File "/usr/local/lib/python3.10/site-packages/ideenergy/client.py", line 65, in _wrap
await client.login()
File "/usr/local/lib/python3.10/site-packages/ideenergy/client.py", line 188, in login
data = await self.request_json("POST", _LOGIN_ENDPOINT, json=payload)
File "/usr/local/lib/python3.10/site-packages/ideenergy/client.py", line 144, in request_json
buff = await self.request_bytes(method, url, **kwargs)
File "/usr/local/lib/python3.10/site-packages/ideenergy/client.py", line 149, in request_bytes
resp = await self._request(method, url, **kwargs)
File "/usr/local/lib/python3.10/site-packages/ideenergy/client.py", line 158, in _request
resp = await self._sess.request(method, url, **kwargs)
File "/usr/local/lib/python3.10/site-packages/aiohttp/client.py", line 536, in _request
conn = await self._connector.connect(
File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 540, in connect
proto = await self._create_connection(req, traces, timeout)
File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 901, in _create_connection
_, proto = await self._create_direct_connection(req, traces, timeout)
File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 1175, in _create_direct_connection
transp, proto = await self._wrap_create_connection(
File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 980, in _wrap_create_connection
return await self._loop.create_connection(*args, **kwargs) # type: ignore[return-value] # noqa
File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1060, in create_connection
sock = await self._connect_sock(
File "/usr/local/lib/python3.10/asyncio/base_events.py", line 969, in _connect_sock
await self.sock_connect(sock, address)
File "/usr/local/lib/python3.10/asyncio/selector_events.py", line 501, in sock_connect
return await fut
asyncio.exceptions.CancelledError

Espero que se pueda solucionar, muchas gracias de antemano por tu fantástico trabajo

Database corrupted after activating historical sensors.

First, I would like to thank the author for this wonderful integration.
I installed it and the two active sensors worked perfectly (accumulated consumption and instant power).
After enabled the three historical sensors and waiting some time, the database got corrupted. After restarting ha, it worked well, without historical data. I have disabled the historical sensors and got no more database corrupteion.

  • HomeAssistant version : 2023.12.1 supervised.
  • ideenergy integration version 2.0.4
  • Instalation method HACS
  • i-de.es advanced user yes
  • Did I read the FAQ? (You should): yes
  • Did I enable debug before posting any log as it's required? (see Logs section below): yes

logs:
`
2023-12-12 07:50:46.771 DEBUG (MainThread) [custom_components.ideenergy.datacoordinator] Request update for datasets: MEASURE
2023-12-12 07:50:46.772 DEBUG (MainThread) [custom_components.ideenergy.datacoordinator] update allowed for MEASURE
2023-12-12 07:50:47.361 INFO (MainThread) [ideenergy] <ideenergy.Client username=[email protected], contract=987654321>: '987654321' contract selected
2023-12-12 07:50:47.361 INFO (MainThread) [ideenergy] <ideenergy.Client username=[email protected], contract=987654321>: successful authentication
2023-12-12 07:50:47.361 DEBUG (MainThread) [ideenergy] Requesting data to the ICP, may take up to a minute.
2023-12-12 07:52:18.217 DEBUG (MainThread) [ideenergy] Got reply, raw data: {'valMagnitud': 'XXXX', 'valInterruptor': 'X', 'valEstado': 'XX', 'valLecturaContador': 'XXXX', 'codSolicitudTGT': 'XXXXXXXX', 'tipPot': ''}
2023-12-12 07:52:18.217 INFO (MainThread) [ideenergy] <ideenergy.Client username=[email protected], contract=987654321>: ICP measure reading successful
2023-12-12 07:52:18.217 DEBUG (MainThread) [custom_components.ideenergy.barrier] success registered
2023-12-12 07:52:18.217 DEBUG (MainThread) [custom_components.ideenergy.datacoordinator] update successful for MEASURE
2023-12-12 07:52:18.218 DEBUG (MainThread) [custom_components.ideenergy.datacoordinator] Finished fetching [email protected]/987654321 coordinator data in 91.446 seconds (success: True)
2023-12-12 07:56:47.772 DEBUG (MainThread) [custom_components.ideenergy.datacoordinator] Request update for datasets: MEASURE
2023-12-12 07:56:47.772 DEBUG (MainThread) [custom_components.ideenergy.datacoordinator] update denied for MEASURE: last success is too recent (269.554893 seconds, min: 540 seconds)
2023-12-12 07:56:47.772 DEBUG (MainThread) [custom_components.ideenergy.datacoordinator] Finished fetching [email protected]/987654321 coordinator data in 0.001 seconds (success: True)
2023-12-12 08:01:17.772 DEBUG (MainThread) [custom_components.ideenergy.datacoordinator] Request update for datasets: MEASURE
2023-12-12 08:01:17.772 DEBUG (MainThread) [custom_components.ideenergy.datacoordinator] update denied for MEASURE: update window is closed
2023-12-12 08:01:17.772 DEBUG (MainThread) [custom_components.ideenergy.datacoordinator] Finished fetching [email protected]/987654321 coordinator data in 0.001 seconds (success: True)
2023-12-12 08:05:47.772 DEBUG (MainThread) [custom_components.ideenergy.datacoordinator] Request update for datasets: MEASURE
2023-12-12 08:05:47.772 DEBUG (MainThread) [custom_components.ideenergy.datacoordinator] update denied for MEASURE: update window is closed
2023-12-12 08:05:47.772 DEBUG (MainThread) [custom_components.ideenergy.datacoordinator] Finished fetching [email protected]/987654321 coordinator data in 0.001 seconds (success: True)
2023-12-12 08:10:17.772 DEBUG (MainThread) [custom_components.ideenergy.datacoordinator] Request update for datasets: MEASURE
2023-12-12 08:10:17.772 DEBUG (MainThread) [custom_components.ideenergy.datacoordinator] update denied for MEASURE: update window is closed
2023-12-12 08:10:17.772 DEBUG (MainThread) [custom_components.ideenergy.datacoordinator] Finished fetching [email protected]/987654321 coordinator data in 0.001 seconds (success: True)
2023-12-12 08:13:52.939 DEBUG (MainThread) [custom_components.ideenergy.datacoordinator] Unregistered sensor 'AccumulatedConsumption'
2023-12-12 08:13:52.940 DEBUG (MainThread) [custom_components.ideenergy.datacoordinator] Unregistered sensor 'InstantPowerDemand'
2023-12-12 08:13:53.545 INFO (MainThread) [ideenergy] <ideenergy.Client username=[email protected], contract=987654321>: '987654321' contract selected
2023-12-12 08:13:53.545 INFO (MainThread) [ideenergy] <ideenergy.Client username=[email protected], contract=987654321>: successful authentication
2023-12-12 08:13:53.692 DEBUG (MainThread) [custom_components.ideenergy.entity] sensor.es0021000004673459jv_historical_consumption: cleaned 0 invalid states
2023-12-12 08:13:53.692 DEBUG (MainThread) [custom_components.ideenergy.datacoordinator] Registered sensor 'HistoricalConsumption'
2023-12-12 08:13:53.692 DEBUG (MainThread) [custom_components.ideenergy.datacoordinator] Request update for datasets: HISTORICAL_CONSUMPTION
2023-12-12 08:13:53.692 DEBUG (MainThread) [custom_components.ideenergy.datacoordinator] update allowed for HISTORICAL_CONSUMPTION
2023-12-12 08:13:53.694 DEBUG (MainThread) [custom_components.ideenergy.entity] sensor.es0021000004673459jv_historical_power_demand: cleaned 0 invalid states
2023-12-12 08:13:53.694 DEBUG (MainThread) [custom_components.ideenergy.datacoordinator] Registered sensor 'HistoricalPowerDemand'
2023-12-12 08:13:53.699 DEBUG (MainThread) [custom_components.ideenergy.entity] sensor.es0021000004673459jv_historical_generation: cleaned 0 invalid states
2023-12-12 08:13:53.699 DEBUG (MainThread) [custom_components.ideenergy.datacoordinator] Registered sensor 'HistoricalGeneration'
2023-12-12 08:13:53.705 DEBUG (DbWorker_0) [custom_components.ideenergy.fixes] sensor.es0021000004673459jv_historical_generation: no statistics found, nothing to fix
2023-12-12 08:13:53.722 DEBUG (MainThread) [custom_components.ideenergy.entity] sensor.es0021000004673459jv_accumulated_consumption: cleaned 1 invalid states
2023-12-12 08:13:53.722 DEBUG (MainThread) [custom_components.ideenergy.datacoordinator] Registered sensor 'AccumulatedConsumption'
2023-12-12 08:13:53.725 DEBUG (MainThread) [custom_components.ideenergy.entity] sensor.es0021000004673459jv_instant_power_demand: cleaned 1 invalid states
2023-12-12 08:13:53.726 DEBUG (MainThread) [custom_components.ideenergy.datacoordinator] Registered sensor 'InstantPowerDemand'
2023-12-12 08:13:54.122 DEBUG (MainThread) [custom_components.ideenergy.datacoordinator] update successful for HISTORICAL_CONSUMPTION
2023-12-12 08:13:54.123 DEBUG (MainThread) [custom_components.ideenergy.datacoordinator] Finished fetching [email protected]/987654321 coordinator data in 0.430 seconds (success: True)
2023-12-12 08:13:54.133 DEBUG (MainThread) [homeassistant_historical_sensor.sensor] sensor.es0021000004673459jv_historical_consumption: 144 historical states present in sensor
2023-12-12 08:13:54.133 DEBUG (MainThread) [homeassistant_historical_sensor.sensor] sensor.es0021000004673459jv_historical_power_demand: 0 historical states present in sensor
2023-12-12 08:13:54.134 DEBUG (MainThread) [homeassistant_historical_sensor.sensor] sensor.es0021000004673459jv_historical_generation: 0 historical states present in sensor
2023-12-12 08:13:54.139 DEBUG (DbWorker_2) [homeassistant_historical_sensor.sensor] sensor.es0021000004673459jv_historical_consumption: cleaned 0 invalid states
2023-12-12 08:13:54.147 DEBUG (DbWorker_3) [custom_components.ideenergy.fixes] sensor.es0021000004673459jv_historical_consumption: no statistics found, nothing to fix
2023-12-12 08:13:54.155 DEBUG (DbWorker_2) [homeassistant_historical_sensor.sensor] sensor.es0021000004673459jv_historical_consumption: no previous state found
2023-12-12 08:13:54.155 DEBUG (DbWorker_2) [homeassistant_historical_sensor.sensor] sensor.es0021000004673459jv_historical_consumption: found 144 new states
2023-12-12 08:13:54.399 DEBUG (MainThread) [homeassistant_historical_sensor.sensor] sensor.es0021000004673459jv_historical_consumption: 144 states written into the database
2023-12-12 08:13:54.403 DEBUG (MainThread) [custom_components.ideenergy.sensor] sensor.es0021000004673459jv_historical_consumption: calculating statistics using 0 as base accumulated (registed at 1970-01-01 01:00:00+01:00)
2023-12-12 08:13:54.406 DEBUG (MainThread) [homeassistant_historical_sensor.sensor] sensor.es0021000004673459jv_historical_consumption: 144 statistics points written into database
2023-12-12 08:13:54.411 ERROR (Recorder) [homeassistant.components.recorder.core] Unrecoverable sqlite3 database corruption detected: (sqlite3.IntegrityError) UNIQUE constraint failed: states_meta.entity_id
[SQL: INSERT INTO states_meta (entity_id) VALUES (?) RETURNING metadata_id]
[parameters: ('sensor.es0021000004673459jv_historical_consumption',)]
(Background on this error at: https://sqlalche.me/e/20/gkpj)
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 2112, in _exec_insertmany_context
dialect.do_execute(
File "/usr/local/lib/python3.11/site-packages/sqlalchemy/engine/default.py", line 922, in do_execute
cursor.execute(statement, parameters)
sqlite3.IntegrityError: UNIQUE constraint failed: states_meta.entity_id

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/recorder/core.py", line 911, in _process_one_task_or_recover
self._commit_event_session_or_retry()
File "/usr/src/homeassistant/homeassistant/components/recorder/core.py", line 1163, in _commit_event_session_or_retry
self._commit_event_session()
File "/usr/src/homeassistant/homeassistant/components/recorder/core.py", line 1183, in _commit_event_session
session.commit()
File "/usr/local/lib/python3.11/site-packages/sqlalchemy/orm/session.py", line 1969, in commit
trans.commit(_to_root=True)
File "", line 2, in commit
File "/usr/local/lib/python3.11/site-packages/sqlalchemy/orm/state_changes.py", line 139, in _go
ret_value = fn(self, *arg, **kw)
^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/sqlalchemy/orm/session.py", line 1256, in commit
self._prepare_impl()
File "", line 2, in _prepare_impl
File "/usr/local/lib/python3.11/site-packages/sqlalchemy/orm/state_changes.py", line 139, in _go
ret_value = fn(self, *arg, **kw)
^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/sqlalchemy/orm/session.py", line 1231, in _prepare_impl
self.session.flush()
File "/usr/local/lib/python3.11/site-packages/sqlalchemy/orm/session.py", line 4312, in flush
self._flush(objects)
File "/usr/local/lib/python3.11/site-packages/sqlalchemy/orm/session.py", line 4447, in _flush
with util.safe_reraise():
File "/usr/local/lib/python3.11/site-packages/sqlalchemy/util/langhelpers.py", line 146, in exit
raise exc_value.with_traceback(exc_tb)
File "/usr/local/lib/python3.11/site-packages/sqlalchemy/orm/session.py", line 4408, in flush
flush_context.execute()
File "/usr/local/lib/python3.11/site-packages/sqlalchemy/orm/unitofwork.py", line 463, in execute
n.execute_aggregate(self, set
)
File "/usr/local/lib/python3.11/site-packages/sqlalchemy/orm/unitofwork.py", line 567, in execute_aggregate
self.execute(uow)
File "/usr/local/lib/python3.11/site-packages/sqlalchemy/orm/unitofwork.py", line 642, in execute
util.preloaded.orm_persistence.save_obj(
File "/usr/local/lib/python3.11/site-packages/sqlalchemy/orm/persistence.py", line 93, in save_obj
_emit_insert_statements(
File "/usr/local/lib/python3.11/site-packages/sqlalchemy/orm/persistence.py", line 1136, in _emit_insert_statements
result = connection.execute(
^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1416, in execute
return meth(
^^^^^
File "/usr/local/lib/python3.11/site-packages/sqlalchemy/sql/elements.py", line 516, in _execute_on_connection
return connection._execute_clauseelement(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1639, in _execute_clauseelement
ret = self._execute_context(
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1843, in _execute_context
return self._exec_insertmany_context(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 2120, in _exec_insertmany_context
self._handle_dbapi_exception(
File "/usr/local/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 2343, in _handle_dbapi_exception
raise sqlalchemy_exception.with_traceback(exc_info[2]) from e
File "/usr/local/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 2112, in _exec_insertmany_context
dialect.do_execute(
File "/usr/local/lib/python3.11/site-packages/sqlalchemy/engine/default.py", line 922, in do_execute
cursor.execute(statement, parameters)
sqlalchemy.exc.IntegrityError: (sqlite3.IntegrityError) UNIQUE constraint failed: states_meta.entity_id
[SQL: INSERT INTO states_meta (entity_id) VALUES (?) RETURNING metadata_id]
[parameters: ('sensor.es0021000004673459jv_historical_consumption',)]
(Background on this error at: https://sqlalche.me/e/20/gkpj)
2023-12-12 08:13:54.499 ERROR (Recorder) [homeassistant.components.recorder.util] The system will rename the corrupt database file //config/home-assistant_v2.db to //config/home-assistant_v2.db.corrupt.2023-12-12T07:13:54.498962+00:00 in order to allow startup to proceed
2023-12-12 08:18:23.634 DEBUG (MainThread) [custom_components.ideenergy.datacoordinator] Request update for datasets: ALL
2023-12-12 08:18:23.635 DEBUG (MainThread) [custom_components.ideenergy.datacoordinator] update denied for MEASURE: update window is closed`

Integración en Energy panel

Hola. Podriais indicar como integrarlo en el energy panel?
En "Configuration/Energy/Electricity Grid/Add consumption" aparece "icp_es_xxxx", pero no me deja escogerlo. Gracias
Energy

Falta configuración de los valores nuevos entregados

Tras los ultimos cambios los valores entregados "sensor.ideenergy_esXXXXXXXXXX_accumulated_consumption" y demas, no tienen el campo que los acredita como valor seleccionable para estadísticas. (total_increasing o measurement) y no son incluidos en el desplegable de selección de la tarjeta de energía.

De momento lo he apañado creando un nuevo valor con el nombre antiguo y vinculado al nuevo.

template:

  • sensor:
    • name: "icp_esXXXXXX_accumulated"
      unit_of_measurement: "kWh"
      state_class: total_increasing # measurement
      device_class: energy
      state: "{{ (states ('sensor.ideenergy_esXXXXXXX_accumulated_consumption')) }}"

Ya nos contaras.

Por cierto como perdí los valores he hice varias pruebas los de IDE me bloquearon el usuario, que ticquismiquis se han vuelto.

Historical sensors storing data with wrong timestamp

Since ~ 9 september data from historical sensors is stored with an offset of 2 hours. The energy dashboard shows the consumption with that offset.

Environment

  • HomeAssistant version 2023.10.1
  • ideenergy integration version v2.0.2
  • Instalation method docker
  • i-de.es advanced user yes
  • Did I read the FAQ?: yes

Expected behavior
Data is shown with the same values as i-de application

Logs

2023-10-12 14:40:14.171 DEBUG (MainThread) [custom_components.ideenergy.datacoordinator] Registered sensor 'HistoricalConsumption'
2023-10-12 14:40:14.172 DEBUG (MainThread) [custom_components.ideenergy.datacoordinator] Registered sensor 'HistoricalPowerDemand'
2023-10-12 14:40:14.178 DEBUG (MainThread) [custom_components.ideenergy.datacoordinator] Request update for datasets: HISTORICAL_CONSUMPTION, HISTORICAL_POWER_DEMAND
2023-10-12 14:40:14.178 DEBUG (MainThread) [custom_components.ideenergy.datacoordinator] update allowed for HISTORICAL_CONSUMPTION
2023-10-12 14:40:17.045 DEBUG (MainThread) [custom_components.ideenergy.datacoordinator] update successful for HISTORICAL_CONSUMPTION
2023-10-12 14:40:17.045 DEBUG (MainThread) [custom_components.ideenergy.datacoordinator] update allowed for HISTORICAL_POWER_DEMAND
2023-10-12 14:40:20.223 DEBUG (MainThread) [custom_components.ideenergy.datacoordinator] update error for HISTORICAL_POWER_DEMAND: **FIXME** handle HISTORICAL_POWER_DEMAND raised exception: AssertionError()
2023-10-12 14:40:20.223 DEBUG (MainThread) [custom_components.ideenergy.datacoordinator] Finished fetching [email protected]/776833388 coordinator data in 6.045 seconds (success: True)
2023-10-12 14:40:20.471 DEBUG (MainThread) [homeassistant_historical_sensor.sensor] sensor.esxxxxxxxxxxxxxxx_historical_consumption: 3384 historical states present in sensor
2023-10-12 14:40:20.471 DEBUG (MainThread) [homeassistant_historical_sensor.sensor] sensor.esxxxxxxxxxxxxxxx_historical_power_demand: 0 historical states present in sensor
2023-10-12 14:40:20.536 DEBUG (DbWorker_1) [homeassistant_historical_sensor.sensor] sensor.esxxxxxxxxxxxxxxx_historical_consumption: cleaned 0 invalid states
2023-10-12 14:40:20.554 DEBUG (DbWorker_1) [homeassistant_historical_sensor.sensor] sensor.esxxxxxxxxxxxxxxx_historical_consumption: lastest state found at 2023-10-11 20:00:00+00:00 (0.466)
2023-10-12 14:40:20.561 DEBUG (DbWorker_0) [custom_components.ideenergy.fixes] sensor.esxxxxxxxxxxxxxxx_historical_consumption: no problems found
2023-10-12 14:40:20.563 WARNING (MainThread) [homeassistant.components.energy.sensor] Found unexpected state_class None for sensor.esxxxxxxxxxxxxxxx_historical_consumption
2023-10-12 14:40:20.569 DEBUG (DbWorker_1) [homeassistant_historical_sensor.sensor] sensor.esxxxxxxxxxxxxxxx_historical_consumption: no new states
2023-10-12 14:40:20.569 DEBUG (MainThread) [homeassistant_historical_sensor.sensor] sensor.esxxxxxxxxxxxxxxx_historical_consumption: 0 states written into the database
2023-10-12 14:40:20.617 DEBUG (MainThread) [custom_components.ideenergy.sensor] sensor.esxxxxxxxxxxxxxxx_historical_consumption: calculating statistics using 1937.6460000000027 as base accumulated (registed at 2023-10-11 21:00:00+02:00)
2023-10-12 14:40:20.617 DEBUG (MainThread) [homeassistant_historical_sensor.sensor] sensor.esxxxxxxxxxxxxxxx_historical_consumption: 0 statistics points written into database
2023-10-12 14:44:50.681 DEBUG (MainThread) [custom_components.ideenergy.datacoordinator] Request update for datasets: HISTORICAL_CONSUMPTION, HISTORICAL_POWER_DEMAND
2023-10-12 14:44:50.681 DEBUG (MainThread) [custom_components.ideenergy.datacoordinator] update denied for HISTORICAL_CONSUMPTION: no max_age reached (0:04:33.636475 <= 6:00:00)
2023-10-12 14:44:50.681 DEBUG (MainThread) [custom_components.ideenergy.datacoordinator] update allowed for HISTORICAL_POWER_DEMAND
2023-10-12 14:44:54.064 DEBUG (MainThread) [custom_components.ideenergy.datacoordinator] update error for HISTORICAL_POWER_DEMAND: **FIXME** handle HISTORICAL_POWER_DEMAND raised exception: AssertionError()
2023-10-12 14:44:54.064 DEBUG (MainThread) [custom_components.ideenergy.datacoordinator] Finished fetching [email protected]/776833388 coordinator data in 3.384 seconds (success: True)
2023-10-12 14:44:54.084 DEBUG (MainThread) [homeassistant_historical_sensor.sensor] sensor.esxxxxxxxxxxxxxxx_historical_consumption: 3384 historical states present in sensor
2023-10-12 14:44:54.084 DEBUG (MainThread) [homeassistant_historical_sensor.sensor] sensor.esxxxxxxxxxxxxxxx_historical_power_demand: 0 historical states present in sensor
2023-10-12 14:44:54.108 DEBUG (DbWorker_1) [homeassistant_historical_sensor.sensor] sensor.esxxxxxxxxxxxxxxx_historical_consumption: cleaned 1 invalid states
...

Screenshots
image

Additional context
Exit from python -m ideenergy --get-historical-consumption -u xxx -p xxx
i-de.json

dump of datebase: sqlite3 home-assistant_v2.db 'select * from statistics;' > statistics
statistics.txt

ERROR (MainThread) [homeassistant.setup] Setup failed for custom integration ideenergy: Unable to import component: No module named 'custom_components.ideenergy-0'

Actualizando de la 0.2.2a a la 0.2.3, me empieza a aparecer este error y deja de funcionar.

ERROR (MainThread) [homeassistant.setup] Setup failed for custom integration ideenergy: Unable to import component: No module named 'custom_components.ideenergy-0'

Home Assistant 2022.8.6, en venv, en Debian 11 arm64 (Raspberry Pi)

ideenergy instalado en custom_components.

La 0.2.2a y alguna anterior funcionaba correctamente, pero si vuelvo ahora a la 0.2.2a, ya no funciona. Esto me da que pensar que el problema pueda tener que ver con algo que ha cambiado en el propio HA recientemente.

He intentado eliminar la integración completamente y empezar desde cero, pero hace lo mismo. Supongo que ese nombre de módulo está en la base de datos.

i-DE user blocked

I know this is not a "real" bug, but I have just received an SMS saying my user is blocked, I cannot log in to the i-DE website and even I cannot change my password or anything. They say my account is blocked due to improper use. But, what improper use? Maybe too many requests? I am using the account only for monitoring... And that is the goal of this service...

I have written a request to i-DE to reactivate the account but... I am waiting for a response.

Has anyone received the same SMS or has been blocked like me?

agregar captcha, para loggin

Loggin con captcha.

La web de i-DE muestra captha para logarme, por favor podrías agregar la funcionalidad y así poder usar el addon

P.D. Gran trabajo, Gracias.

Database gets corrupted after restart if integration is configured

Before filling a bug please provide as much as information as possible.
Not all information is required but the more the better.

Stick to English if bug is about code, Spanish is OK if bug is about configuration.

Describe the bug
Database gets corrupted after restart if integration is configured

To Reproduce
Steps to reproduce the behavior:
1- Simply install integration, configure (mail/pass), select one of the contracts (asked between 2 in my case) an restart
2-
After a restart, you will see error in integrations menu
imagen
3- Also, in file you'll see "/homeassistant/home-assistant_v2.db.corrupted" (or something like this)

Environment

Core - 2023.11.2
Supervisor - 2023.11.3
Operating System - 11.1
Frontend - 20231030.2

  • ideenergy v2.0.4
  • Instalation method - HassOS (installed from HACS)
  • i-de.es advanced user - yes
  • Did I read the FAQ? (You should): yes
  • Did I enable debug before posting any log as it's required? (see Logs section below): yes

Expected behavior
Not corrupting database...

Logs


2023-11-21 19:25:19.594 INFO (MainThread) [ideenergy] <ideenergy.Client [email protected], contract=xxxxxxxxxx>: 'xxxxxxxxxx' contract selected
2023-11-21 19:25:19.595 INFO (MainThread) [ideenergy] <ideenergy.Client [email protected], contract=xxxxxxxxxx>: successful authentication
2023-11-21 19:25:19.782 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.ideenergy
2023-11-21 19:25:19.842 DEBUG (MainThread) [custom_components.ideenergy.entity] sensor.esxxxxxxxxxxmp_instant_power_demand: cleaned 2 invalid states
2023-11-21 19:25:19.843 DEBUG (MainThread) [custom_components.ideenergy.datacoordinator] Registered sensor 'InstantPowerDemand'
2023-11-21 19:25:19.843 DEBUG (MainThread) [custom_components.ideenergy.datacoordinator] Request update for datasets: MEASURE
2023-11-21 19:25:19.844 DEBUG (MainThread) [custom_components.ideenergy.datacoordinator] update denied for MEASURE: update window is closed
2023-11-21 19:25:19.844 DEBUG (MainThread) [custom_components.ideenergy.datacoordinator] Finished fetching [email protected]/xxxxxxxxxx coordinator data in 0.001 seconds (success: True)
2023-11-21 19:25:19.852 DEBUG (MainThread) [custom_components.ideenergy.sensor] sensor.esxxxxxxxxxxmp_instant_power_demand: restore state failed (unknown)
2023-11-21 19:25:19.872 DEBUG (MainThread) [custom_components.ideenergy.entity] sensor.esxxxxxxxxxxmp_accumulated_consumption: cleaned 2 invalid states
2023-11-21 19:25:19.872 DEBUG (MainThread) [custom_components.ideenergy.datacoordinator] Registered sensor 'AccumulatedConsumption'
2023-11-21 19:25:19.873 DEBUG (MainThread) [custom_components.ideenergy.sensor] sensor.esxxxxxxxxxxmp_accumulated_consumption: restore state failed (unknown)
2023-11-21 19:25:21.072 ERROR (Recorder) [homeassistant.components.recorder.core] Unrecoverable sqlite3 database corruption detected: (sqlite3.IntegrityError) FOREIGN KEY constraint failed
[SQL: INSERT INTO states (entity_id, state, attributes, event_id, last_changed, last_changed_ts, last_updated, last_updated_ts, old_state_id, attributes_id, context_id, context_user_id, context_parent_id, origin_idx, context_id_bin, context_user_id_bin, context_parent_id_bin, metadata_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING state_id]
[parameters: (None, 'unknown', None, None, None, None, None, 1700591119.84527, 1133, 308, None, None, None, 0, <memory at 0x7f620e1e40>, None, None, 350)]
(Background on this error at: https://sqlalche.me/e/20/gkpj)
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 2112, in _exec_insertmany_context
    dialect.do_execute(
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/engine/default.py", line 922, in do_execute
    cursor.execute(statement, parameters)
sqlite3.IntegrityError: FOREIGN KEY constraint failed

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/recorder/core.py", line 912, in _process_one_task_or_recover
    return task.run(self)
           ^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/recorder/tasks.py", line 305, in run
    instance._commit_event_session_or_retry()
  File "/usr/src/homeassistant/homeassistant/components/recorder/core.py", line 1163, in _commit_event_session_or_retry
    self._commit_event_session()
  File "/usr/src/homeassistant/homeassistant/components/recorder/core.py", line 1183, in _commit_event_session
    session.commit()
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/orm/session.py", line 1967, in commit
    trans.commit(_to_root=True)
  File "<string>", line 2, in commit
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/orm/state_changes.py", line 139, in _go
    ret_value = fn(self, *arg, **kw)
                ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/orm/session.py", line 1256, in commit
    self._prepare_impl()
  File "<string>", line 2, in _prepare_impl
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/orm/state_changes.py", line 139, in _go
    ret_value = fn(self, *arg, **kw)
                ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/orm/session.py", line 1231, in _prepare_impl
    self.session.flush()
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/orm/session.py", line 4310, in flush
    self._flush(objects)
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/orm/session.py", line 4445, in _flush
    with util.safe_reraise():
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/util/langhelpers.py", line 146, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/orm/session.py", line 4406, in _flush
    flush_context.execute()
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/orm/unitofwork.py", line 466, in execute
    rec.execute(self)
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/orm/unitofwork.py", line 642, in execute
    util.preloaded.orm_persistence.save_obj(
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/orm/persistence.py", line 93, in save_obj
    _emit_insert_statements(
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/orm/persistence.py", line 1136, in _emit_insert_statements
    result = connection.execute(
             ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1416, in execute
    return meth(
           ^^^^^
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/sql/elements.py", line 516, in _execute_on_connection
    return connection._execute_clauseelement(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1639, in _execute_clauseelement
    ret = self._execute_context(
          ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1843, in _execute_context
    return self._exec_insertmany_context(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 2120, in _exec_insertmany_context
    self._handle_dbapi_exception(
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 2343, in _handle_dbapi_exception
    raise sqlalchemy_exception.with_traceback(exc_info[2]) from e
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 2112, in _exec_insertmany_context
    dialect.do_execute(
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/engine/default.py", line 922, in do_execute
    cursor.execute(statement, parameters)
sqlalchemy.exc.IntegrityError: (sqlite3.IntegrityError) FOREIGN KEY constraint failed
[SQL: INSERT INTO states (entity_id, state, attributes, event_id, last_changed, last_changed_ts, last_updated, last_updated_ts, old_state_id, attributes_id, context_id, context_user_id, context_parent_id, origin_idx, context_id_bin, context_user_id_bin, context_parent_id_bin, metadata_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING state_id]
[parameters: (None, 'unknown', None, None, None, None, None, 1700591119.84527, 1133, 308, None, None, None, 0, <memory at 0x7f620e1e40>, None, None, 350)]
(Background on this error at: https://sqlalche.me/e/20/gkpj)
2023-11-21 19:25:21.285 INFO (Recorder) [homeassistant.components.recorder.pool.RecorderPool] Pool recreating
2023-11-21 19:25:21.287 ERROR (Recorder) [homeassistant.components.recorder.util] The system will rename the corrupt database file //config/home-assistant_v2.db to //config/home-assistant_v2.db.corrupt.2023-11-21T18:25:21.286964+00:00 in order to allow startup to proceed
2023-11-21 19:25:21.578 WARNING (MainThread) [homeassistant.helpers.entity] Update of vacuum.aspiradora is taking over 10 seconds
2023-11-21 19:25:29.853 DEBUG (MainThread) [custom_components.ideenergy.datacoordinator] Request update for datasets: MEASURE
2023-11-21 19:25:29.855 DEBUG (MainThread) [custom_components.ideenergy.datacoordinator] update denied for MEASURE: update window is closed
2023-11-21 19:25:29.855 DEBUG (MainThread) [custom_components.ideenergy.datacoordinator] Finished fetching [email protected]/xxxxxxxxxx coordinator data in 0.002 seconds (success: True)

Screenshots
After reloading integration:
imagen

Additional context
I've found there
home-assistant/core#101466
that maybe inserting statistics rows in old format can corrupt database

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.