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

Apiet krashar vid hämtning av usage data #26

Open
mrfrostfire opened this issue Jun 1, 2022 · 9 comments
Open

Apiet krashar vid hämtning av usage data #26

mrfrostfire opened this issue Jun 1, 2022 · 9 comments
Labels
bug Something isn't working

Comments

@mrfrostfire
Copy link

Följande felmeddelande kastas när jag försöker hämta ut usage.
När jag testar anropet via postman till https://api2.greenely.com/v3/data/2022/05/30/usage fungerar det, men med tom data.
Det kan vara relaterat till att jag har 2 hem i greenely, där det gamla jag flyttat från för över ett år sedan ligger kvar som "primär".

`greenely: Error on device update!
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 174, in _new_conn
conn = connection.create_connection(
File "/usr/local/lib/python3.9/site-packages/urllib3/util/connection.py", line 72, in create_connection
for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
File "/usr/local/lib/python3.9/socket.py", line 954, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name does not resolve

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 703, in urlopen
httplib_response = self._make_request(
File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 386, in _make_request
self._validate_conn(conn)
File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 1040, in _validate_conn
conn.connect()
File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 358, in connect
self.sock = conn = self._new_conn()
File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 186, in _new_conn
raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x7fec890416a0>: Failed to establish a new connection: [Errno -2] Name does not resolve

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/requests/adapters.py", line 440, in send
resp = conn.urlopen(
File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 785, in urlopen
retries = retries.increment(
File "/usr/local/lib/python3.9/site-packages/urllib3/util/retry.py", line 592, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api2.greenely.com', port=443): Max retries exceeded with url: /v3/data/2022/5/30/usage (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fec890416a0>: Failed to establish a new connection: [Errno -2] Name does not resolve'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 431, in _async_add_entity
await entity.async_device_update(warning=False)
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 736, in async_device_update
await task
File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/greenely/sensor.py", line 244, in update
response = self._api.get_usage(str(previous_day.year), str(previous_day.month), str(previous_day.day))
File "/config/custom_components/greenely/api.py", line 55, in get_usage
response = requests.get(url, headers = self._headers)
File "/usr/local/lib/python3.9/site-packages/requests/api.py", line 75, in get
return request('get', url, params=params, **kwargs)
File "/usr/local/lib/python3.9/site-packages/requests/api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 529, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 645, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python3.9/site-packages/requests/adapters.py", line 519, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='api2.greenely.com', port=443): Max retries exceeded with url: /v3/data/2022/5/30/usage (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fec890416a0>: Failed to establish a new connection: [Errno -2] Name does not resolve'))`

@linsvensson
Copy link
Owner

Hmm okej, det låter ju som ett väldigt specifikt fel.
Finns det något sätt att se facility id i appen? Kan du på något sätt ändra vilket hem som är "primär"?

@linsvensson linsvensson added the bug Something isn't working label Jun 25, 2022
@mrfrostfire
Copy link
Author

mrfrostfire commented Jun 27, 2022 via email

@linsvensson
Copy link
Owner

Jag antar att jag skulle kunna lägga till ett fält för vilket facility id man har (om man vet det, annars använder den det primära). Kan kika på det ikväll!

@mrfrostfire
Copy link
Author

mrfrostfire commented Jun 27, 2022 via email

@linsvensson
Copy link
Owner

Har du möjlighet att kolla vilka anrop som hämtar ut data?
Jag ser bara t.ex
https://api2.greenely.com/v1/facilities/74562/consumption?from=2022-05-01&to=2022-05-02&resolution=hourly&unit=usage&operation=sum
Och den visar helt annan data än https://api2.greenely.com/v3/data/

@linsvensson
Copy link
Owner

Hittade en lösning som jag hoppas fungerar, let me know!

@mrfrostfire
Copy link
Author

mrfrostfire commented Jun 29, 2022 via email

@mrfrostfire
Copy link
Author

mrfrostfire commented Jul 1, 2022

Får det inte att fungera tyvärr..

Logger: homeassistant.components.sensor
Source: custom_components/greenely/sensor.py:373
Integration: Sensor ([documentation](https://www.home-assistant.io/integrations/sensor), [issues](https://github.com/home-assistant/home-assistant/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+sensor%22))
First occurred: 21:59:05 (1 occurrences)
Last logged: 21:59:05


greenely: Error on device update!
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 431, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 736, in async_device_update
    await task
  File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/greenely/sensor.py", line 351, in update
    data = self.make_attributes(datetime.now(), response)
  File "/config/custom_components/greenely/sensor.py", line 373, in make_attributes
    self._state = usage / 1000 if usage != 0 else 0
TypeError: unsupported operand type(s) for /: 'NoneType' and 'int'

Min konfig är:

  • platform: greenely
    email: MINEMAIL
    password: MITTLÖSEN
    facility_id: '223902'
    hourly_usage: true
    prices: true
    sold: false

@linsvensson
Copy link
Owner

linsvensson commented Jul 1, 2022

Laddar upp en ny release nu!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants