Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Datos históricos: generación de energía #3

Closed
ldotlopez opened this issue May 15, 2022 · 1 comment
Closed

Datos históricos: generación de energía #3

ldotlopez opened this issue May 15, 2022 · 1 comment
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@ldotlopez
Copy link
Owner

ldotlopez commented May 15, 2022

Para poder integrar los datos de generación de energía necesitamos información de usuarios que tengan este tipo de instalación en su casa.

He creado unas pequeñas instrucciones para obtener estos registros.

Creación de un entorno controlado de python

Desde la linea de comandos ejecutar los siguientes comandos:

(python3.9 -m venv /tmp/ide-test || echo "Version incorrecta de python"; false ) && /tmp/ide-test/bin/pip install --quiet ideenergy==1.0.0a1 ipython && /tmp/ide-test/bin/ipython

Si el comando anterior muestra "Version incorrecta de python" prueba a cambiar python3.9 por python3.8 o python3.7. Si ninguna opción funciona deberías buscar la manera de poder instalar python3.9 y probar de nuevo

En caso de éxito nos aparecerá un mensaje similar a esto:

$ /tmp/ide-test/bin/ipython
Python 3.9.7 (default, Sep 10 2021, 14:59:43) 
Type 'copyright', 'credits' or 'license' for more information
IPython 8.3.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: 

Ejecución de un pequeño script en ipython

Sustituyendo USERNAME y PASSWORD por los valores adecuados pegar y ejecutar el código siguiente en el interprete del paso anterior:

USERNAME = "user@example.com"
PASSWORD = "******"

from datetime import date, timedelta

import ideenergy
from ideenergy.client import _GENERATION_PERIOD_ENDPOINT

from pprint import pprint

end = date.today()
start = end - timedelta(days=7)
url = _GENERATION_PERIOD_ENDPOINT.format(start=start.strftime("%d-%m-%Y"), end=end.strftime("%d-%m-%Y"))

api = ideenergy.Client(await ideenergy.get_session(), USERNAME, PASSWORD)
await api.login()
resp = await api.raw_request('GET', url)

pprint({
    'url': url,
    'status': resp.status,
    'content': await resp.content.read(),
    'content_disposition': resp.content_disposition,
    'content_type': resp.content_type
    })

exit

Información obtenida

La salida de ese comando es lo que necesitamos.

@ldotlopez ldotlopez added enhancement New feature or request help wanted Extra attention is needed labels May 15, 2022
@ldotlopez ldotlopez pinned this issue May 15, 2022
@ldotlopez ldotlopez changed the title Datos sobre generación de energía Datos históricos: generación de energía May 15, 2022
@ldotlopez
Copy link
Owner Author

Implementado en commit b422c60

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant