Giter Site home page Giter Site logo

edistribucion's People

Contributors

andrsdt avatar arman103 avatar davidcm avatar duhow avatar moralespetit avatar trocotronic avatar

Stargazers

 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

edistribucion's Issues

Exception on "get_meas_interval()" -> 'lstData'

Hi,

I'm reading measurements data for a CUPS for 12/02/2023. "get_meas_interval()" raises an exception, whose text is 'lstData'.
Checking its data in edistribution website, I see that there is no data for that specific day.
See attached image and csv below (CUPS id has been replaced by 'ESXXXXXXXXX' for privacy). As you can see, there are no values for that day and first 3 hours of the following day (13/02/2023) for the field 'AE_kWh' in CSV file.

My question: Should it be interpreted as 0 kWh? Could it be done within the code of this repo?

Thank you.

ESXXXXXXXXX_20230101_20230220_Horario.csv

imagen

Add "setCredentials" and "logout" (or "dispose") methods

I'm using this API to access server using several credentials (different users).

Right now, credentials are "loaded" from 'credentials.py'. I need to change the credentials in runtime... Could it be possible to add a 'setCredentials(user, password)' method?
Also, if this 'setCredentials' method is defined (I've done it locally), when I call the 'login' method it keeps the previous session (for the previous credentials)... Could it be possible to add a 'logout' method? (or 'dispose' or 'close' ...)

Getting an login error

I've tried to use the script Sadly I do not have much python knowledge by the moment.

In the example, after updating user and password I always get as response:

EdistribucionAPI.EdisError: Unexpected error in loginForm. Cannot continue. The raw log is below:

I'm running this on an Arch installation with python3.8
'''
[21/08/2020 13:40:58] [INFO] Performing login routine
[21/08/2020 13:40:58] [DEBUG] https://zonaprivada.edistribucion.com:443 "POST /areaprivada/s/sfsites/aura?other.LightningLoginForm.login=1 HTTP/1.1" 200 None
[21/08/2020 13:40:58] [INFO] Sending POST request to https://zonaprivada.edistribucion.com/areaprivada/s/sfsites/aura?other.LightningLoginForm.login=1
[21/08/2020 13:40:58] [DEBUG] Parameters: https://zonaprivada.edistribucion.com/areaprivada/s/sfsites/aura?other.LightningLoginForm.login=1
[21/08/2020 13:40:58] [DEBUG] Headers: {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:77.0) Gecko/20100101 Firefox/77.0', 'Accept-Encoding': 'gzip, deflate', 'Accept': '/', 'Connection': 'keep-alive', 'Cookie': 'renderCtx=%7B%22pageId%22%3A%22ebdf870b-5acd-4526-a912-588b66f15b22%22%2C%22schema%22%3A%22Published%22%2C%22viewType%22%3A%22Published%22%2C%22brandingSetId%22%3A%2219645c47-34b5-4d50-9bc1-4424bb2f3ebe%22%2C%22audienceIds%22%3A%22%22%7D; sfdc-stream=!0Bj4G9jFS/P8Yo03d1xt/fnN1zETUfSEbyRJ6RWnzeYTR0mlBKVrhm1OsS0xPj/TC0ZHMn5XvR1Utco=', 'Content-Length': '803', 'Content-Type': 'application/x-www-form-urlencoded'}
[21/08/2020 13:40:58] [INFO] Response with code: 200
[21/08/2020 13:40:58] [DEBUG] Headers: {'Date': 'Fri, 21 Aug 2020 11:41:00 GMT', 'X-B3-TraceId': '11f69591cdb95917', 'X-B3-SpanId': '11f69591cdb95917', 'X-B3-Sampled': '0', 'Cache-Control': 'no-cache,must-revalidate,max-age=0,no-store,private', 'X-Content-Type-Options': 'nosniff', 'X-XSS-Protection': '1; mode=block', 'Referrer-Policy': 'origin-when-cross-origin', 'Expires': 'Tue, 07 Jul 2020 11:41:00 GMT', 'Content-Type': 'application/json;charset=UTF-8', 'Last-Modified': 'Tue, 07 Jul 2020 11:41:00 GMT', 'Vary': 'Accept-Encoding', 'Content-Encoding': 'gzip', 'Transfer-Encoding': 'chunked'}
[21/08/2020 13:40:58] [DEBUG] History: []
Traceback (most recent call last):
File "./example.py", line 15, in
edis.login()
File "/home/jagalindo/Documentos/Repositories/edistribucion/EdistribucionAPI.py", line 153, in login
return self.__force_login()
File "/home/jagalindo/Documentos/Repositories/edistribucion/EdistribucionAPI.py", line 182, in __force_login
raise EdisError('Unexpected error in loginForm. Cannot continue')
'''

error de API

[24/02/2024 21:13:59] [INFO] Response with code: 200
Traceback (most recent call last):
File "/home/jose/edistribucion/./contador.py", line 15, in
meter = edis.get_meter(cups)
^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/EdistribucionAPI/Edistribucion.py", line 395, in get_meter
return self.__run_action_command(action)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/EdistribucionAPI/Edistribucion.py", line 354, in __run_action_command
req = self.__command(f"other.{command}=1", post=data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/EdistribucionAPI/Edistribucion.py", line 219, in __command
if (jr['actions'][0]['state'] != 'SUCCESS'):
~~~~~~~~~~~~~^^^
IndexError: list index out of range

json como única salida.

Enhorabuena por este pedazo de scrapper y gracias por compartirlo.

¿hay alguna manera de hacer una ejecución 'poco verbosa' y que retorne solo el json final de {meter} ?

Gracias

Functions not working

Hi! I've been trying some functions such as get_cups and get_meter (as done in example.py). They work properly.
But, when I tried any other (get_list_cycles, get_meas, get_meas_interval, get_cups_info), I get always some error.

Can anybody try those methods again?

Thank you.

imagen

Seemingly can't login

Hi! At some point it started outputting this:
Can't get cups: token not found. Cannot continue
Looks like they changed the webpage or am I the only one?
Thanks.

Error connecting to e-Distribución

Hi,

I'm unable to connect to e-Distribución since Friday 28th April (5 days ago).
When running, within the call to Edistribution(), I got an error:
HTTPSConnectionPool(host='zonaprivada.edistribucion.com', port=443): Max retries exceeded with url: /areaprivada/s/login?ec=302&startURL=%2Fareaprivada%2Fs%2F (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1007)')))

I'm trying this code on Windows and Raspberry and same error appears. These are the versions of 'requests' package of my Windows:

  • requests 2.29.0
  • requests-oauthlib 1.3.1
  • requests-toolbelt 0.9.1

Does any of you have the same problem?

setting a rol

this functions able to change Rol, get authoriced persons and authoriced cups, in Edistribution when you have multiples Rols and represetantion profiles.

Add to EdistribucionAPI.py:

def set_rol(self, visId):
    action = EdistribucionMessageAction(
        595,
        "WP_ProfileMenu_CTRL/ACTION$saveRole",
        "WP_ProfileMenu",
        {"visId":""+visId+""}
    )
    r = self.__run_action_command(action)
    return r

def get_authorized(self):
    action = EdistribucionMessageAction(
        390,
        "WP_Monitor_CTRL/ACTION$getLoginInfo",
        "WP_Monitor",
        {"serviceNumber":"S001"}
    )
    r = self.__run_action_command(action)
    return r['authList']

def get_authorized_cups(self, id):
    action = EdistribucionMessageAction(
        339,
        "WP_Measure_v3_CTRL/ACTION$getListCups",
        "WP_Measure_List_v4",
        {"sIdentificador":""+id+""}
    )
    r = self.__run_action_command(action)
    return r

token methode as changed

in def __force_login(self, recursive=False):

change:
self.__context = '{"mode":"PROD","fwuid":"LU1oNENmckdVUXNqVGtLeG5odmktZ2Rkdk8xRWxIam5GeGw0LU1mRHRYQ3cyNDYuMTUuMS0zLjAuNA","app":"siteforce:communityApp","loaded":{"APPLICATION@markup://siteforce:communityApp":"8srl03VqKMnukxbiM5O73w"},"dn":[],"globals":{},"uad":false}'

by:
self.__context = '{"mode":"PROD","fwuid":"LU1oNENmckdVUXNqVGtLeG5odmktZ2Rkdk8xRWxIam5GeGw0LU1mRHRYQ3cyNDYuMTUuMS0zLjAuNA","app":"siteforce:communityApp2","loaded":{"APPLICATION@markup://siteforce:communityApp2":"8srl03VqKMnukxbiM5O73w"},"dn":[],"globals":{},"uad":false}'

now authenticate but still have issues

New funtion to get data between two dates.

please add to EdistribucionAPI.py

def  get_meas_dates(self, cont, start, end):
    action = EdistribucionMessageAction(
        965,
        "WP_Measure_v3_CTRL/ACTION$getChartPointsByRange",
        "WP_Measure_Detail_Filter_Advanced_v3",
        {"contId":""+cont['Id']+"","type":"4","startDate":""+start+"","endDate":""+end+""}
    )
    r = self.__run_action_command(action)
    if 'data' in r.keys():
        if 'lstData' in r['data'].keys():
            return r['data']['lstData']
    return []

Changes in the ENDESA web page. login fail

Hello,

Something has change in the login page. Now it fails to connect:

requests.exceptions.ConnectionError: HTTPSConnectionPool(host='zonaprivada.edistribucion.comhttps', port=443): Max retries exceeded with url: //static.lightning.force.com/eu25/auraFW/javascript/Vo_clYDmAijdWOzW3-3Mow/aura_prod.js (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f48225ec160>: Failed to establish a new connection: [Errno -2] Name or service not known'))

If I try to visit with a web browser https://static.lightning.force.com/ I got this error:

Service Unavailable - DNS failure
The server is temporarily unable to service your request. Please try again later.
Reference #11.de497b5c.1675415417.3a97c1

Really I dont know how to help to fix this error so I reported to you

Thanks

Meter metrics not working anymore

Since some days ago the system does not obtain any meter when doing the call to the consultarContador=1 endpoint in the e-distribution API:

root@082c6f328eba:/edistribucion# ./example.py
[12/08/2021 23:39:33] [INFO] Loging
[12/08/2021 23:39:33] [INFO] Preparing command: other.WP_ContadorICP_CTRL.getCUPSReconectarICP=1
[12/08/2021 23:39:34] [INFO] Sending POST request to https://zonaprivada.edistribucion.com/areaprivada/s/sfsites/aura?other.WP_ContadorICP_CTRL.getCUPSReconectarICP=1
[12/08/2021 23:39:34] [INFO] Response with code: 200
Cups:  XXXXXXXXXXXXX
[12/08/2021 23:39:34] [INFO] Preparing command: other.WP_ContadorICP_CTRL.consultarContador=1
[12/08/2021 23:39:34] [INFO] Sending POST request to https://zonaprivada.edistribucion.com/areaprivada/s/sfsites/aura?other.WP_ContadorICP_CTRL.consultarContador=1
[12/08/2021 23:39:34] [INFO] Response with code: 200
Meter:  None

As you may see in the logs the call returns a 200 OK code but instead of obtain the usual data it gets an empty value. Could it be related to a change in the API? Do you have any documentation about how the API works?

I could dedicate some time, not so much, and provide a PR.

Error <<argument of type 'NoneType' is not iterable>>

Buenas tardes,
Llevo unos 3-4 días con problemas en la ultima version (0.7.0), ¿os ocurre tambien a vosotros?

_> [INFO] Loading token scripts

Traceback (most recent call last):
File "c:\temp\edistribucion-master20231016\example.py", line 11, in
edis = Edistribucion()
File "c:\temp\edistribucion-master20231016\src\EdistribucionAPI\Edistribucion.py", line 133, in init
self.login()
File "c:\temp\edistribucion-master20231016\src\EdistribucionAPI\Edistribucion.py", line 240, in login
return self.__force_login()
File "c:\temp\edistribucion-master20231016\src\EdistribucionAPI\Edistribucion.py", line 312, in __force_login
self.__token = self.__get_token()
File "c:\temp\edistribucion-master20231016\src\EdistribucionAPI\Edistribucion.py", line 249, in _get_token
if ('auraConfig' in s.string):
TypeError: argument of type 'NoneType' is not iterable

Adjunto fichero con log completo.

Gracias por la ayuda.

Un saludo.
log_edistribucion.txt

Force Login Error

First of all, thanks for your project 🙏

I'm using the fork from @jagalindo to integrate your script with my Home Assistant. I receive this error quite often and I was wondering if you were aware of this issue.

Logger: homeassistant.helpers.entity
Source: custom_components/edistribucion/backend/EdistribucionAPI.py:192

Update for sensor.eds_power_consumption fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 278, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 482, in async_device_update
    await task
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/edistribucion/sensor.py", line 51, in update
    meter = edis.get_meter(cups)
  File "/config/custom_components/edistribucion/backend/EdistribucionAPI.py", line 247, in get_meter
    r = self.__command('other.WP_ContadorICP_CTRL.consultarContador=1', post=data)
  File "/config/custom_components/edistribucion/backend/EdistribucionAPI.py", line 134, in __command
    self.__force_login()
  File "/config/custom_components/edistribucion/backend/EdistribucionAPI.py", line 192, in __force_login
    raise EdisError('Unexpected error in loginForm. Cannot continue')
custom_components.edistribucion.backend.EdistribucionAPI.EdisError: Unexpected error in loginForm. Cannot continue

EdistribucionAPI.Edistribucion.EdisError: token not found. Cannot continue

Hello! Since a few days I get the following error:

[04/11/2023 22:35:21] [INFO] Response with code: 200 [04/11/2023 22:35:21] [INFO] Accessing to landing page [04/11/2023 22:35:21] [INFO] Sending GET request to https://zonaprivada.edistribucion.com/areaprivada/s/ [04/11/2023 22:35:21] [INFO] Response with code: 200 [04/11/2023 22:35:21] [INFO] Loading token scripts Traceback (most recent call last): File "/usr/local/bin/edistribucion2/example.py", line 11, in <module> edis = Edistribucion() File "/usr/local/lib/python3.9/dist-packages/EdistribucionAPI/Edistribucion.py", line 133, in __init__ self.login() File "/usr/local/lib/python3.9/dist-packages/EdistribucionAPI/Edistribucion.py", line 240, in login return self.__force_login() File "/usr/local/lib/python3.9/dist-packages/EdistribucionAPI/Edistribucion.py", line 314, in __force_login raise EdisError('token not found. Cannot continue') EdistribucionAPI.Edistribucion.EdisError: token not found. Cannot continue

Any ideas? Thanks!

Errores en la página de Endesa?

Más de la mitad de las peticiones acaba así:

Traceback (most recent call last):
File "/home/albert/edistribucion/example.py", line 19, in
meter = edis.get_meter(cups)
File "/NAS/home/albert/edistribucion/EdistribucionAPI.py", line 248, in get_meter
r = self.__command('other.WP_ContadorICP_CTRL.consultarContador=1', post=data)
File "/NAS/home/albert/edistribucion/EdistribucionAPI.py", line 135, in __command
self.__force_login()
File "/NAS/home/albert/edistribucion/EdistribucionAPI.py", line 193, in __force_login
raise EdisError('Unexpected error in loginForm. Cannot continue')
EdistribucionAPI.EdisError: Unexpected error in loginForm. Cannot continue

Aunque algunas 'acaban bien' :). Supongo que es culpa de la página, ¿no?

Endesa PT

Buenas,

¿Sabes si esto funciona con Endesa PT, que es una empresa del mismo grupo?
Podría intentar ayudar y probar si es posible.

registro

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.