hardbyte / ha-evnex

A cloud-polling Home Assistant component to integrate with an Evnex Charger
MIT License
12 stars 1 forks source link

Addon not connecting: Retrying setup #4

Open zorruno opened 2 years ago

zorruno commented 2 years ago

Great work to create this thanks.

Summary Installed with HACS Home Assistant 2022.9.7 Supervisor 2022.09.1 Operating System 9.0 Frontend 20220907.2 - latest

Checked my Evnex uname/pass with the phone app and that is connecting fine. Username is an email address, and a complex pw.

HA Logs:

This error originated from a custom integration.

Logger: custom_components.evnex
Source: custom_components/evnex/__init__.py:205
Integration: Evnex EV Charger (documentation, issues)
First occurred: 23:06:15 (32 occurrences)
Last logged: 23:23:08

Unhandled exception while updating evnex info

Logger: homeassistant.config_entries
Source: config_entries.py:1073
First occurred: 23:09:07 (2 occurrences)
Last logged: 23:12:56

Config entry 'my-email@address-username' for evnex integration not ready yet; Retrying in background
hardbyte commented 2 years ago

Thanks for the bug report @zorruno and hopefully I can get the integration going for you.

What you've posted isn't quite enough of a clue for me to know what is going wrong. I've had a look and found one issue - potentially the issue you were running into... It was when the charge point is offline the HA integration would never finish setting up. I've released a new version which fixes that issue, but of course it may be something else going on.

If you update and still have an issue could you help me work out what is going on by enabling more detailed logging? To enable debug logging, add the following to your configuration.yaml and restart HA:

logger:
  default: info
  logs:
    custom_components.hacs: debug
    custom_components.evnex: debug
    evnex: debug
zorruno commented 2 years ago

thanks @hardbyte - of course, happy to get whatever debugging info needed - will grab more logs a bit later. Was playing with https://github.com/ankohanse/EVNEX and I added some MQTT support, but proper HA integration will be fantastic

zorruno commented 2 years ago
2022-10-03 19:33:36.879 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration evnex which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2022-10-03 19:33:45.026 INFO (MainThread) [homeassistant.bootstrap] Setting up stage 2: {'blueprint', 'zone', 'trace', 'esphome', 'person', 'application_credentials', 'openweathermap', 'coronavirus', 'input_button', 'sun', 'input_number', 'default_config', 'media_player', 'config', 'scene', 'repairs', 'search', 'tautulli', 'nodered', 'automation', 'mqtt', 'hardware', 'motioneye', 'xiaomi_ble', 'openmediavault', 'panasonic_viera', 'hacs', 'logbook', 'tplink_deco', 'homeassistant_alerts', 'dlna_dms', 'plex', 'tts', 'brother', 'lovelace', 'onboarding', 'map', 'dlna_dmr', 'google', 'cast', 'analytics', 'mobile_app', 'input_datetime', 'device_automation', 'input_select', 'sensor', 'rest_command', 'moon', 'system_health', 'grocy', 'history', 'counter', 'image', 'tag', 'nut', 'diagnostics', 'energy', 'ipp', 'auth', 'tuya', 'evnex', 'tasmota', 'var', 'persistent_notification', 'file_upload', 'group', 'ffmpeg', 'script', 'waze_travel_time', 'timer', 'pushover', 'panel_custom', 'schedule', 'my', 'spotify', 'input_boolean', 'device_tracker', 'edgeos', 'input_text', 'media_source', 'browser_mod'}
2022-10-03 19:33:46.330 INFO (MainThread) [homeassistant.setup] Setting up evnex
2022-10-03 19:33:46.330 INFO (MainThread) [homeassistant.setup] Setup of domain evnex took 0.0 seconds
2022-10-03 19:33:46.411 INFO (MainThread) [custom_components.evnex] Version 0.1.0 is starting, if you have any issues please report them here: https://github.com/hardbyte/ha-evnex/issues
2022-10-03 19:33:46.411 INFO (MainThread) [custom_components.evnex] Retrieving session token from: /config/evnex_session.json
2022-10-03 19:33:46.416 DEBUG (SyncWorker_10) [evnex.api] Creating evnex api instance
2022-10-03 19:33:48.609 INFO (MainThread) [custom_components.evnex] Getting evnex user detail
2022-10-03 19:33:48.947 INFO (MainThread) [custom_components.evnex] Persisting session tokens to /config/evnex_session.json
2022-10-03 19:33:48.948 INFO (MainThread) [custom_components.evnex] Getting evnex charge points for Vector CPO
2022-10-03 19:33:48.948 DEBUG (MainThread) [evnex.api] Listing org charge points
2022-10-03 19:33:49.240 DEBUG (MainThread) [evnex.api] Getting org insight
2022-10-03 19:33:49.603 INFO (MainThread) [custom_components.evnex] Getting evnex charge point data for View Road
2022-10-03 19:33:53.179 ERROR (MainThread) [custom_components.evnex] Unhandled exception while updating evnex info
2022-10-03 19:33:53.180 DEBUG (MainThread) [custom_components.evnex] Finished fetching evnex data in 4.571 seconds (success: False)
2022-10-03 19:33:53.180 WARNING (MainThread) [homeassistant.config_entries] Config entry '<REDACTED>' for evnex integration not ready yet; Retrying in background
zorruno commented 2 years ago

note, this is after latest update

zorruno commented 2 years ago

More info - just to make sure there are no setup issues on my system, I

hardbyte commented 2 years ago

Thanks! Still not sure what is going on. To help narrow it down I've added in some more debugging calls and have made sure we now log the details on that "unhandled exception" in this pre-release https://github.com/hardbyte/ha-evnex/releases/tag/v0.2.5-beta.1

If you wouldn't mind updating and capturing the logs again... hopefully we get a solid lead this time.

zorruno commented 2 years ago

a bit of hope - definitely some more targeted info in there


2022-10-07 15:30:59.305 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration evnex which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2022-10-07 15:31:06.492 INFO (MainThread) [homeassistant.bootstrap] Setting up stage 2: {'waze_travel_time', 'system_health', 'rest_command', 'analytics', 'tplink_deco', 'plex', 'schedule', 'script', 'onboarding', 'my', 'trace', 'mqtt', 'counter', 'nzbget', 'openmediavault', 'tasmota', 'diagnostics', 'coronavirus', 'ipp', 'tautulli', 'automation', 'zone', 'var', 'input_select', 'browser_mod', 'google', 'tag', 'hardware', 'device_automation', 'map', 'openweathermap', 'application_credentials', 'ffmpeg', 'dlna_dmr', 'media_source', 'spotify', 'sensor', 'blueprint', 'input_number', 'cast', 'persistent_notification', 'tts', 'evnex', 'default_config', 'nut', 'nodered', 'logbook', 'history', 'grocy', 'input_datetime', 'file_upload', 'edgeos', 'image', 'input_button', 'device_tracker', 'timer', 'panasonic_viera', 'panel_custom', 'mobile_app', 'pushover', 'dlna_dms', 'hacs', 'auth', 'homeassistant_alerts', 'media_player', 'lovelace', 'tuya', 'motioneye', 'brother', 'xiaomi_ble', 'config', 'moon', 'repairs', 'group', 'input_text', 'person', 'input_boolean', 'search', 'energy', 'scene', 'sun', 'esphome'}
2022-10-07 15:31:07.353 INFO (MainThread) [homeassistant.setup] Setting up evnex
2022-10-07 15:31:07.353 INFO (MainThread) [homeassistant.setup] Setup of domain evnex took 0.0 seconds
2022-10-07 15:31:07.364 INFO (MainThread) [custom_components.evnex] Version 0.1.0 is starting, if you have any issues please report them here: https://github.com/hardbyte/ha-evnex/issues
2022-10-07 15:31:07.364 INFO (MainThread) [custom_components.evnex] Retrieving session token from: /config/evnex_session.json
2022-10-07 15:31:07.369 DEBUG (SyncWorker_3) [evnex.api] Creating evnex api instance
2022-10-07 15:31:09.592 INFO (MainThread) [custom_components.evnex] Getting evnex user detail
2022-10-07 15:31:09.939 INFO (MainThread) [custom_components.evnex] Persisting session tokens to /config/evnex_session.json
2022-10-07 15:31:09.940 INFO (MainThread) [custom_components.evnex] Getting evnex charge points for 'Vector CPO'
2022-10-07 15:31:09.940 DEBUG (MainThread) [evnex.api] Listing org charge points
2022-10-07 15:31:10.101 DEBUG (MainThread) [custom_components.evnex] Getting evnex org insights for Vector CPO
2022-10-07 15:31:10.101 DEBUG (MainThread) [evnex.api] Getting org insight
2022-10-07 15:31:10.440 DEBUG (MainThread) [custom_components.evnex] Getting evnex charge point data for 'View Road'
2022-10-07 15:31:11.058 DEBUG (MainThread) [custom_components.evnex] Getting evnex charge point transactions for 'View Road'
2022-10-07 15:31:11.402 DEBUG (MainThread) [custom_components.evnex] Getting evnex charge point override for 'View Road'
2022-10-07 15:31:13.866 ERROR (MainThread) [custom_components.evnex] Unhandled exception while updating evnex info
File "/config/custom_components/evnex/__init__.py", line 174, in async_update_data
charge_point_override: EvnexChargePointOverrideConfig = await evnex_client.get_charge_point_override(
File "/usr/local/lib/python3.10/site-packages/evnex/api.py", line 257, in get_charge_point_override
return EvnexChargePointOverrideConfig(**json_data)
pydantic.error_wrappers.ValidationError: 1 validation error for EvnexChargePointOverrideConfig
2022-10-07 15:31:13.868 DEBUG (MainThread) [custom_components.evnex] Finished fetching evnex data in 4.276 seconds (success: False)
2022-10-07 15:31:13.868 WARNING (MainThread) [homeassistant.config_entries] Config entry 'redacted@domain' for evnex integration not ready yet; Retrying in background
2022-10-07 15:31:42.405 INFO (MainThread) [custom_components.evnex] Version 0.1.0 is starting, if you have any issues please report them here: https://github.com/hardbyte/ha-evnex/issues
2022-10-07 15:31:42.405 INFO (MainThread) [custom_components.evnex] Retrieving session token from: /config/evnex_session.json
2022-10-07 15:31:42.412 DEBUG (SyncWorker_4) [evnex.api] Creating evnex api instance
2022-10-07 15:31:45.029 INFO (MainThread) [custom_components.evnex] Getting evnex user detail
2022-10-07 15:31:45.869 INFO (MainThread) [custom_components.evnex] Persisting session tokens to /config/evnex_session.json
2022-10-07 15:31:45.870 INFO (MainThread) [custom_components.evnex] Getting evnex charge points for 'Vector CPO'
2022-10-07 15:31:45.870 DEBUG (MainThread) [evnex.api] Listing org charge points
2022-10-07 15:31:46.088 DEBUG (MainThread) [custom_components.evnex] Getting evnex org insights for Vector CPO
2022-10-07 15:31:46.088 DEBUG (MainThread) [evnex.api] Getting org insight
2022-10-07 15:31:46.319 DEBUG (MainThread) [custom_components.evnex] Getting evnex charge point data for 'View Road'
2022-10-07 15:31:46.613 DEBUG (MainThread) [custom_components.evnex] Getting evnex charge point transactions for 'View Road'
2022-10-07 15:31:46.931 DEBUG (MainThread) [custom_components.evnex] Getting evnex charge point override for 'View Road'
2022-10-07 15:31:49.618 ERROR (MainThread) [custom_components.evnex] Unhandled exception while updating evnex info
File "/config/custom_components/evnex/__init__.py", line 174, in async_update_data
charge_point_override: EvnexChargePointOverrideConfig = await evnex_client.get_charge_point_override(
File "/usr/local/lib/python3.10/site-packages/evnex/api.py", line 257, in get_charge_point_override
return EvnexChargePointOverrideConfig(**json_data)
pydantic.error_wrappers.ValidationError: 1 validation error for EvnexChargePointOverrideConfig
2022-10-07 15:31:49.619 DEBUG (MainThread) [custom_components.evnex] Finished fetching evnex data in 4.590 seconds (success: False)
2022-10-07 15:31:52.788 DEBUG (MainThread) [custom_components.hacs] <Integration hardbyte/ha-evnex> Getting repository information
2022-10-07 15:31:53.477 DEBUG (MainThread) [custom_components.hacs] <Integration hardbyte/ha-evnex> Running checks against v0.2.4
2022-10-07 15:31:59.620 INFO (MainThread) [custom_components.evnex] Version 0.1.0 is starting, if you have any issues please report them here: https://github.com/hardbyte/ha-evnex/issues
2022-10-07 15:31:59.620 INFO (MainThread) [custom_components.evnex] Retrieving session token from: /config/evnex_session.json
2022-10-07 15:31:59.621 DEBUG (SyncWorker_0) [evnex.api] Creating evnex api instance
2022-10-07 15:32:01.634 INFO (MainThread) [custom_components.evnex] Getting evnex user detail
2022-10-07 15:32:01.876 INFO (MainThread) [custom_components.evnex] Persisting session tokens to /config/evnex_session.json
2022-10-07 15:32:01.877 INFO (MainThread) [custom_components.evnex] Getting evnex charge points for 'Vector CPO'
2022-10-07 15:32:01.878 DEBUG (MainThread) [evnex.api] Listing org charge points
2022-10-07 15:32:02.162 DEBUG (MainThread) [custom_components.evnex] Getting evnex org insights for Vector CPO
2022-10-07 15:32:02.163 DEBUG (MainThread) [evnex.api] Getting org insight
2022-10-07 15:32:02.333 DEBUG (MainThread) [custom_components.evnex] Getting evnex charge point data for 'View Road'
2022-10-07 15:32:02.615 DEBUG (MainThread) [custom_components.evnex] Getting evnex charge point transactions for 'View Road'
2022-10-07 15:32:02.995 DEBUG (MainThread) [custom_components.evnex] Getting evnex charge point override for 'View Road'
2022-10-07 15:32:05.642 ERROR (MainThread) [custom_components.evnex] Unhandled exception while updating evnex info
File "/config/custom_components/evnex/__init__.py", line 174, in async_update_data
charge_point_override: EvnexChargePointOverrideConfig = await evnex_client.get_charge_point_override(
File "/usr/local/lib/python3.10/site-packages/evnex/api.py", line 257, in get_charge_point_override
return EvnexChargePointOverrideConfig(**json_data)
pydantic.error_wrappers.ValidationError: 1 validation error for EvnexChargePointOverrideConfig
2022-10-07 15:32:05.643 DEBUG (MainThread) [custom_components.evnex] Finished fetching evnex data in 4.009 seconds (success: False)```
zorruno commented 2 years ago

Hmm, do I manually need to install the python evnex library

zorruno commented 2 years ago

using HAOS, the evnex library is installed at /usr/lib/python3.10/site-packages/evnex

zorruno commented 2 years ago

I'm still guessing here, as I don't really know the HA environment and no idea if the library is pulled with the HACS addon. The platform is the minimal HAOS so I installed py-pip and the evnex library (which pulled a bunch of dependencies). Logs don't change, and the only thing I can't determine is why it would be referencing /usr/local/lib/python3.10/site-packages/evnex/api.py when the api is at /usr/lib/python3.10/site-packages/evnex/api.py

zorruno commented 2 years ago

FYI, now on 0.3.0 with new pull via HACS, reinstall. Pretty much same errors in logs. Would love to get this working... I thought my HA setup was pretty standard.


2022-10-28 21:57:02.841 INFO (MainThread) [custom_components.evnex] Retrieving session token from: /config/evnex_session.json
2022-10-28 21:57:02.843 DEBUG (SyncWorker_4) [evnex.api] Creating evnex api instance
2022-10-28 21:57:04.858 INFO (MainThread) [custom_components.evnex] Getting evnex user detail
2022-10-28 21:57:05.152 INFO (MainThread) [custom_components.evnex] Persisting session tokens to /config/evnex_session.json
2022-10-28 21:57:05.154 INFO (MainThread) [custom_components.evnex] Getting evnex charge points for 'Vector CPO'
2022-10-28 21:57:05.154 DEBUG (MainThread) [evnex.api] Listing org charge points
2022-10-28 21:57:05.396 DEBUG (MainThread) [custom_components.evnex] Getting evnex org insights for Vector CPO
2022-10-28 21:57:05.396 DEBUG (MainThread) [evnex.api] Getting org insight
2022-10-28 21:57:05.716 DEBUG (MainThread) [custom_components.evnex] Getting evnex charge point data for 'View Road'
2022-10-28 21:57:06.092 ERROR (MainThread) [custom_components.evnex] Unhandled exception while updating evnex info
File "/config/custom_components/evnex/__init__.py", line 165, in async_update_data
api_v3_response = await evnex_client.get_charge_point_detail_v3(charge_point_id=charge_point.id)
File "/usr/local/lib/python3.10/site-packages/evnex/api.py", line 226, in get_charge_point_detail_v3
return EvnexV3APIResponse[EvnexChargePointDetailV3](**json_data)
pydantic.error_wrappers.ValidationError: 1 validation error for EvnexV3APIResponse[EvnexChargePointDetail]
2022-10-28 21:57:06.093 DEBUG (MainThread) [custom_components.evnex] Finished fetching evnex data in 1.235 seconds (success: False)```
hardbyte commented 2 years ago

Hey @zorruno - the bug doesn't seem to related to the home assistant integration.

Can I get you to try run this standalone python script I wrote in the python-evnex library examples/get_charge_point_detail.py.

Checkout the library with git, or download the zip file and we should first be able to reproduce the error without home assistant by running:

export EVNEX_CLIENT_USERNAME=you@example.com
export EVNEX_CLIENT_PASSWORD=<your password>

python -m examples.get_charge_point_detail

(You can also edit the example file to hard code in your login details instead of environment variables if you prefer)

After hopefully getting the same error message (perhaps with more context about how the validation failed), lets add a line to log exactly what comes back from evnex:

If you add this line into the api.py file, on line 151

logger.debug(f"Raw get charge point detail response.\n{r.status_code}\n{r.text}")

So that _check_api_response function looks like this: image

zorruno commented 2 years ago

thanks @hardbyte. Using a different machine (ubuntu)

It doesn't get to that debug line...


User: me@<redacted> me@<redacted>  f123456-bc44-491a-a10c-e123456c
Getting charge points for 'Vector CPO'
View Road ONLINE AB19340617 1b4d1066-22c8-470e-bcd4-5778e08a40ae
charge point details (API V3)
Traceback (most recent call last):
  File "/home/me/python-evnex-main/evnex/../examples/get_charge_point_detail.py", line 91, in <module>
    asyncio.run(main())
  File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete
    return future.result()
  File "/home/me/python-evnex-main/evnex/../examples/get_charge_point_detail.py", line 44, in main
    charge_point_detail = await evnex.get_charge_point_detail_v3(
  File "/home/me/.local/lib/python3.10/site-packages/tenacity/_asyncio.py", line 86, in async_wrapped
    return await fn(*args, **kwargs)
  File "/home/me/.local/lib/python3.10/site-packages/tenacity/_asyncio.py", line 48, in __call__
    do = self.iter(retry_state=retry_state)
  File "/home/me/.local/lib/python3.10/site-packages/tenacity/__init__.py", line 351, in iter
    return fut.result()
  File "/usr/lib/python3.10/concurrent/futures/_base.py", line 451, in result
    return self.__get_result()
  File "/usr/lib/python3.10/concurrent/futures/_base.py", line 403, in __get_result
    raise self._exception
  File "/home/me/.local/lib/python3.10/site-packages/tenacity/_asyncio.py", line 51, in __call__
    result = await fn(*args, **kwargs)
  File "/home/me/.local/lib/python3.10/site-packages/evnex/api.py", line 226, in get_charge_point_detail_v3
    return EvnexV3APIResponse[EvnexChargePointDetailV3](**json_data)
  File "pydantic/main.py", line 342, in pydantic.main.BaseModel.__init__
pydantic.error_wrappers.ValidationError: 1 validation error for EvnexV3APIResponse[EvnexChargePointDetail]
data -> attributes -> connectors -> 0 -> meter -> currentL1
  field required (type=value_error.missing)
hardbyte commented 2 years ago

I missed a step in my instructions - That debug line will only print out if we change the logging level at the top of the example script. Should be logging.basicConfig(level=logging.DEBUG)

But at last we have a solid lead. I've read up on the evnex website and it looks like not all installations monitor the current on the installed phase.

90% of Evnex EV chargers installed in residential spaces include a power sensor

I'm assuming that your setup doesn't have this and that would explain why there is no currentL1. There might be other attributes that are optional too.

I've marked currentL1 as optional in https://github.com/hardbyte/python-evnex/commit/4116ad584803cd2795e81ff270676398e5154583 - we may have to do the same with power or voltageL1N. Perhaps you want to try run the script and adding Optional to the attributes that are missing (in evnex/schema/v3/charge_points.py -> EvnexChargePointConnectorMeter)

zorruno commented 2 years ago

I set, in ./evnex/schema/v3/charge_points.py

currentL1: Optional[float] power: Optional[float]

voltageL1N was already set as Optional

I note on the Evnex cloud site & app I am get these parameters (charging at the moment): EVSE ID Power type AC_1_PHASE Connector type IEC_62196_T2 Connector format SOCKET Maximum current 32A Maximum voltage 240V Power 0.63 kW Voltage 231.6 V Current 2.855 A Frequency 50.04 Hz

here is the full debug log (hopefully everything relevant redacted) - looks like the same error?


me@mycomputer:~/python-evnex-main/examples$ python -m get_charge_point_detail

DEBUG:asyncio:Using selector: EpollSelector
DEBUG:evnex.api:Creating evnex api instance
DEBUG:botocore.hooks:Changing event name from creating-client-class.iot-data to creating-client-class.iot-data-plane
DEBUG:botocore.hooks:Changing event name from before-call.apigateway to before-call.api-gateway
DEBUG:botocore.hooks:Changing event name from request-created.machinelearning.Predict to request-created.machine-learning.Predict
DEBUG:botocore.hooks:Changing event name from before-parameter-build.autoscaling.CreateLaunchConfiguration to before-parameter-build.auto-scaling.CreateLaunchConfiguration
DEBUG:botocore.hooks:Changing event name from before-parameter-build.route53 to before-parameter-build.route-53
DEBUG:botocore.hooks:Changing event name from request-created.cloudsearchdomain.Search to request-created.cloudsearch-domain.Search
DEBUG:botocore.hooks:Changing event name from docs.*.autoscaling.CreateLaunchConfiguration.complete-section to docs.*.auto-scaling.CreateLaunchConfiguration.complete-section
DEBUG:botocore.hooks:Changing event name from before-parameter-build.logs.CreateExportTask to before-parameter-build.cloudwatch-logs.CreateExportTask
DEBUG:botocore.hooks:Changing event name from docs.*.logs.CreateExportTask.complete-section to docs.*.cloudwatch-logs.CreateExportTask.complete-section
DEBUG:botocore.hooks:Changing event name from before-parameter-build.cloudsearchdomain.Search to before-parameter-build.cloudsearch-domain.Search
DEBUG:botocore.hooks:Changing event name from docs.*.cloudsearchdomain.Search.complete-section to docs.*.cloudsearch-domain.Search.complete-section
DEBUG:botocore.utils:IMDS ENDPOINT: http://169.254.169.254/
DEBUG:botocore.credentials:Looking for credentials via: env
DEBUG:botocore.credentials:Looking for credentials via: assume-role
DEBUG:botocore.credentials:Looking for credentials via: assume-role-with-web-identity
DEBUG:botocore.credentials:Looking for credentials via: sso
DEBUG:botocore.credentials:Looking for credentials via: shared-credentials-file
DEBUG:botocore.credentials:Looking for credentials via: custom-process
DEBUG:botocore.credentials:Looking for credentials via: config-file
DEBUG:botocore.credentials:Looking for credentials via: ec2-credentials-file
DEBUG:botocore.credentials:Looking for credentials via: boto-config
DEBUG:botocore.credentials:Looking for credentials via: container-role
DEBUG:botocore.credentials:Looking for credentials via: iam-role
DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): 169.254.169.254:80
DEBUG:botocore.utils:Caught retryable HTTP exception while making metadata service request to http://169.254.169.254/latest/api/token: Connect timeout on endpoint URL: "http://169.254.169.254/latest/api/token"
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 169, in _new_conn
    conn = connection.create_connection(
  File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 96, in create_connection
    raise err
  File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 86, in create_connection
    sock.connect(sa)
TimeoutError: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/me/.local/lib/python3.10/site-packages/botocore/httpsession.py", line 455, in send
    urllib_response = conn.urlopen(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 755, in urlopen
    retries = retries.increment(
  File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 507, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/usr/lib/python3/dist-packages/six.py", line 719, in reraise
    raise value
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 699, in urlopen
    httplib_response = self._make_request(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 394, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 234, in request
    super(HTTPConnection, self).request(method, url, body=body, headers=headers)
  File "/usr/lib/python3.10/http/client.py", line 1282, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/home/me/.local/lib/python3.10/site-packages/botocore/awsrequest.py", line 94, in _send_request
    rval = super()._send_request(
  File "/usr/lib/python3.10/http/client.py", line 1328, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.10/http/client.py", line 1277, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/home/me/.local/lib/python3.10/site-packages/botocore/awsrequest.py", line 123, in _send_output
    self.send(msg)
  File "/home/me/.local/lib/python3.10/site-packages/botocore/awsrequest.py", line 218, in send
    return super().send(str)
  File "/usr/lib/python3.10/http/client.py", line 975, in send
    self.connect()
  File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 200, in connect
    conn = self._new_conn()
  File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 174, in _new_conn
    raise ConnectTimeoutError(
urllib3.exceptions.ConnectTimeoutError: (<botocore.awsrequest.AWSHTTPConnection object at 0x7fe5aa5c6860>, 'Connection to 169.254.169.254 timed out. (connect timeout=1)')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/me/.local/lib/python3.10/site-packages/botocore/utils.py", line 456, in _fetch_metadata_token
    response = self._session.send(request.prepare())
  File "/home/me/.local/lib/python3.10/site-packages/botocore/httpsession.py", line 490, in send
    raise ConnectTimeoutError(endpoint_url=request.url, error=e)
botocore.exceptions.ConnectTimeoutError: Connect timeout on endpoint URL: "http://169.254.169.254/latest/api/token"
DEBUG:urllib3.connectionpool:Starting new HTTP connection (2): 169.254.169.254:80
DEBUG:botocore.utils:Caught retryable HTTP exception while making metadata service request to http://169.254.169.254/latest/meta-data/iam/security-credentials/: Connect timeout on endpoint URL: "http://169.254.169.254/latest/meta-data/iam/security-credentials/"
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 169, in _new_conn
    conn = connection.create_connection(
  File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 96, in create_connection
    raise err
  File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 86, in create_connection
    sock.connect(sa)
TimeoutError: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/me/.local/lib/python3.10/site-packages/botocore/httpsession.py", line 455, in send
    urllib_response = conn.urlopen(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 755, in urlopen
    retries = retries.increment(
  File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 507, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/usr/lib/python3/dist-packages/six.py", line 719, in reraise
    raise value
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 699, in urlopen
    httplib_response = self._make_request(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 394, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 234, in request
    super(HTTPConnection, self).request(method, url, body=body, headers=headers)
  File "/usr/lib/python3.10/http/client.py", line 1282, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/home/me/.local/lib/python3.10/site-packages/botocore/awsrequest.py", line 94, in _send_request
    rval = super()._send_request(
  File "/usr/lib/python3.10/http/client.py", line 1328, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.10/http/client.py", line 1277, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/home/me/.local/lib/python3.10/site-packages/botocore/awsrequest.py", line 123, in _send_output
    self.send(msg)
  File "/home/me/.local/lib/python3.10/site-packages/botocore/awsrequest.py", line 218, in send
    return super().send(str)
  File "/usr/lib/python3.10/http/client.py", line 975, in send
    self.connect()
  File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 200, in connect
    conn = self._new_conn()
  File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 174, in _new_conn
    raise ConnectTimeoutError(
urllib3.exceptions.ConnectTimeoutError: (<botocore.awsrequest.AWSHTTPConnection object at 0x7fe5aa5c71c0>, 'Connection to 169.254.169.254 timed out. (connect timeout=1)')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/me/.local/lib/python3.10/site-packages/botocore/utils.py", line 509, in _get_request
    response = self._session.send(request.prepare())
  File "/home/me/.local/lib/python3.10/site-packages/botocore/httpsession.py", line 490, in send
    raise ConnectTimeoutError(endpoint_url=request.url, error=e)
botocore.exceptions.ConnectTimeoutError: Connect timeout on endpoint URL: "http://169.254.169.254/latest/meta-data/iam/security-credentials/"
DEBUG:botocore.utils:Max number of attempts exceeded (1) when attempting to retrieve data from metadata service.
DEBUG:botocore.loaders:Loading JSON file: /home/me/.local/lib/python3.10/site-packages/botocore/data/endpoints.json
DEBUG:botocore.loaders:Loading JSON file: /home/me/.local/lib/python3.10/site-packages/botocore/data/sdk-default-configuration.json
DEBUG:botocore.hooks:Event choose-service-name: calling handler <function handle_service_name_alias at 0x7fe5aab2f400>
DEBUG:botocore.loaders:Loading JSON file: /home/me/.local/lib/python3.10/site-packages/botocore/data/cognito-idp/2016-04-18/service-2.json
DEBUG:botocore.loaders:Loading JSON file: /home/me/.local/lib/python3.10/site-packages/botocore/data/cognito-idp/2016-04-18/endpoint-rule-set-1.json.gz
DEBUG:botocore.loaders:Loading JSON file: /home/me/.local/lib/python3.10/site-packages/botocore/data/partitions.json
DEBUG:botocore.hooks:Event creating-client-class.cognito-identity-provider: calling handler <function add_generate_presigned_url at 0x7fe5aaddb010>
DEBUG:botocore.endpoint:Setting cognito-idp timeout as (60, 60)
DEBUG:botocore.loaders:Loading JSON file: /home/me/.local/lib/python3.10/site-packages/botocore/data/_retry.json
DEBUG:botocore.client:Registering retry handlers for service: cognito-idp
DEBUG:evnex.api:Starting cognito auth flow
DEBUG:evnex.api:Authenticating to EVNEX cloud api
DEBUG:botocore.regions:Calling endpoint provider with parameters: {'Region': 'ap-southeast-2', 'UseDualStack': False, 'UseFIPS': False}
DEBUG:botocore.regions:Endpoint provider result: https://cognito-idp.ap-southeast-2.amazonaws.com
DEBUG:botocore.hooks:Event before-parameter-build.cognito-identity-provider.InitiateAuth: calling handler <function generate_idempotent_uuid at 0x7fe5aab4cca0>
DEBUG:botocore.hooks:Event before-call.cognito-identity-provider.InitiateAuth: calling handler <function add_recursion_detection_header at 0x7fe5aab4c940>
DEBUG:botocore.hooks:Event before-call.cognito-identity-provider.InitiateAuth: calling handler <function inject_api_version_header_if_needed at 0x7fe5aab4e4d0>
DEBUG:botocore.endpoint:Making request for OperationModel(name=InitiateAuth) with params: {'url_path': '/', 'query_string': '', 'method': 'POST', 'headers': {'X-Amz-Target': 'AWSCognitoIdentityProviderService.InitiateAuth', 'Content-Type': 'application/x-amz-json-1.1', 'User-Agent': 'Boto3/1.26.0 Python/3.10.6 Linux/5.15.0-52-generic Botocore/1.29.0'}, 'body': b'{"AuthFlow": "USER_SRP_AUTH", "AuthParameters": {"USERNAME": "myemail@address.redacted", "SRP_A": "REDACTED"}, "ClientId": "rol3lsv2vg41783550i18r7vi"}', 'url': 'https://cognito-idp.ap-southeast-2.amazonaws.com/', 'context': {'client_region': 'ap-southeast-2', 'client_config': <botocore.config.Config object at 0x7fe5a9d288b0>, 'has_streaming_input': False, 'auth_type': 'none'}}
DEBUG:botocore.hooks:Event request-created.cognito-identity-provider.InitiateAuth: calling handler <bound method RequestSigner.handler of <botocore.signers.RequestSigner object at 0x7fe5a9d28760>>
DEBUG:botocore.hooks:Event choose-signer.cognito-identity-provider.InitiateAuth: calling handler <function set_operation_specific_signer at 0x7fe5aab4cb80>
DEBUG:botocore.hooks:Event request-created.cognito-identity-provider.InitiateAuth: calling handler <function add_retry_headers at 0x7fe5aab4eb90>
DEBUG:botocore.endpoint:Sending http request: <AWSPreparedRequest stream_output=False, method=POST, url=https://cognito-idp.ap-southeast-2.amazonaws.com/, headers={'X-Amz-Target': b'AWSCognitoIdentityProviderService.InitiateAuth', 'Content-Type': b'application/x-amz-json-1.1', 'User-Agent': b'Boto3/1.26.0 Python/3.10.6 Linux/5.15.0-52-generic Botocore/1.29.0', 'amz-sdk-invocation-id': b'e9210523-126b-48a0-967b-9e7530e3e17d', 'amz-sdk-request': b'attempt=1', 'Content-Length': '909'}>
DEBUG:botocore.httpsession:Certificate path: /etc/ssl/certs/ca-certificates.crt
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): cognito-idp.ap-southeast-2.amazonaws.com:443
DEBUG:urllib3.connectionpool:https://cognito-idp.ap-southeast-2.amazonaws.com:443 "POST / HTTP/1.1" 200 2703
DEBUG:botocore.parsers:Response headers: {'Date': 'Fri, 11 Nov 2022 03:05:51 GMT', 'Content-Type': 'application/x-amz-json-1.1', 'Content-Length': '2703', 'Connection': 'keep-alive', 'x-amzn-RequestId': 'REDACTED'}
DEBUG:botocore.parsers:Response body:
b'{"ChallengeName":"PASSWORD_VERIFIER","ChallengeParameters":{"SALT":"REDACTED","SECRET_BLOCK":"REDACTED","SRP_B":"REDACTED","USERNAME":"myemail@address.redacted","USER_ID_FOR_SRP":"myemail@address.redacted"}}'
DEBUG:botocore.hooks:Event needs-retry.cognito-identity-provider.InitiateAuth: calling handler <botocore.retryhandler.RetryHandler object at 0x7fe5a9d29b70>
DEBUG:botocore.retryhandler:No retry needed.
DEBUG:botocore.regions:Calling endpoint provider with parameters: {'Region': 'ap-southeast-2', 'UseDualStack': False, 'UseFIPS': False}
DEBUG:botocore.regions:Endpoint provider result: https://cognito-idp.ap-southeast-2.amazonaws.com
DEBUG:botocore.hooks:Event before-parameter-build.cognito-identity-provider.RespondToAuthChallenge: calling handler <function generate_idempotent_uuid at 0x7fe5aab4cca0>
DEBUG:botocore.hooks:Event before-call.cognito-identity-provider.RespondToAuthChallenge: calling handler <function add_recursion_detection_header at 0x7fe5aab4c940>
DEBUG:botocore.hooks:Event before-call.cognito-identity-provider.RespondToAuthChallenge: calling handler <function inject_api_version_header_if_needed at 0x7fe5aab4e4d0>
DEBUG:botocore.endpoint:Making request for OperationModel(name=RespondToAuthChallenge) with params: {'url_path': '/', 'query_string': '', 'method': 'POST', 'headers': {'X-Amz-Target': 'AWSCognitoIdentityProviderService.RespondToAuthChallenge', 'Content-Type': 'application/x-amz-json-1.1', 'User-Agent': 'Boto3/1.26.0 Python/3.10.6 Linux/5.15.0-52-generic Botocore/1.29.0'}, 'body': b'{"ClientId": "rol3lsv2vg41783550i18r7vi", "ChallengeName": "PASSWORD_VERIFIER", "ChallengeResponses": {"TIMESTAMP": "Fri Nov 11 03:05:51 UTC 2022", "USERNAME": "myemail@address.redacted", "PASSWORD_CLAIM_SECRET_BLOCK": "REDACTED", "PASSWORD_CLAIM_SIGNATURE": "DcRTimbDGjQPkwll5EItjFdR3lsVjn1ri4NzoXBLZuM="}}', 'url': 'https://cognito-idp.ap-southeast-2.amazonaws.com/', 'context': {'client_region': 'ap-southeast-2', 'client_config': <botocore.config.Config object at 0x7fe5a9d288b0>, 'has_streaming_input': False, 'auth_type': 'none'}}
DEBUG:botocore.hooks:Event request-created.cognito-identity-provider.RespondToAuthChallenge: calling handler <bound method RequestSigner.handler of <botocore.signers.RequestSigner object at 0x7fe5a9d28760>>
DEBUG:botocore.hooks:Event choose-signer.cognito-identity-provider.RespondToAuthChallenge: calling handler <function set_operation_specific_signer at 0x7fe5aab4cb80>
DEBUG:botocore.hooks:Event request-created.cognito-identity-provider.RespondToAuthChallenge: calling handler <function add_retry_headers at 0x7fe5aab4eb90>
DEBUG:botocore.endpoint:Sending http request: <AWSPreparedRequest stream_output=False, method=POST, url=https://cognito-idp.ap-southeast-2.amazonaws.com/, headers={'X-Amz-Target': b'AWSCognitoIdentityProviderService.RespondToAuthChallenge', 'Content-Type': b'application/x-amz-json-1.1', 'User-Agent': b'Boto3/1.26.0 Python/3.10.6 Linux/5.15.0-52-generic Botocore/1.29.0', 'amz-sdk-invocation-id': b'f5703c00-588c-450e-8937-12d12b142324', 'amz-sdk-request': b'attempt=1', 'Content-Length': '2021'}>
DEBUG:botocore.httpsession:Certificate path: /etc/ssl/certs/ca-certificates.crt
DEBUG:urllib3.connectionpool:https://cognito-idp.ap-southeast-2.amazonaws.com:443 "POST / HTTP/1.1" 200 3938
DEBUG:botocore.parsers:Response headers: {'Date': 'Fri, 11 Nov 2022 03:05:51 GMT', 'Content-Type': 'application/x-amz-json-1.1', 'Content-Length': '3938', 'Connection': 'keep-alive', 'x-amzn-RequestId': '8a7045fb-e19f-41c2-ad6c-d85dc5628b5c'}
DEBUG:botocore.parsers:Response body:
b'{"AuthenticationResult":{"AccessToken":"REDACTED","ExpiresIn":3600,"IdToken":"REDACTED","TokenType":"Bearer"},"ChallengeParameters":{}}'
DEBUG:botocore.hooks:Event needs-retry.cognito-identity-provider.RespondToAuthChallenge: calling handler <botocore.retryhandler.RetryHandler object at 0x7fe5a9d29b70>
DEBUG:botocore.retryhandler:No retry needed.
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): cognito-idp.ap-southeast-2.amazonaws.com:443
DEBUG:urllib3.connectionpool:https://cognito-idp.ap-southeast-2.amazonaws.com:443 "GET /ap-southeast-2_zWnqo6ASv/.well-known/jwks.json HTTP/1.1" 200 916
DEBUG:httpx._client:HTTP Request: GET https://client-api.evnex.io/v2/apps/user "HTTP/1.1 200 OK"
User: myemail@address.redacted myemail@address.redacted fef105f7-bc44-491a-a10c-e94f9d45008c
Getting charge points for 'Vector CPO'
DEBUG:evnex.api:Listing org charge points
DEBUG:httpx._client:HTTP Request: GET https://client-api.evnex.io/v2/apps/organisations/497ed299-8b92-4add-b56f-317dbcfa1a3d/charge-points "HTTP/1.1 200 OK"
Redacted Charger Name ONLINE AB-REDACTED REDACTED
charge point details (API V3)
DEBUG:httpx._client:HTTP Request: GET https://client-api.evnex.io/v3/charge-points/1b4d1066-22c8-470e-bcd4-5778e08a40ae "HTTP/1.1 200 OK"
Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/me/python-evnex-main/examples/get_charge_point_detail.py", line 91, in <module>
    asyncio.run(main())
  File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete
    return future.result()
  File "/home/me/python-evnex-main/examples/get_charge_point_detail.py", line 44, in main
    charge_point_detail = await evnex.get_charge_point_detail_v3(
  File "/home/me/.local/lib/python3.10/site-packages/tenacity/_asyncio.py", line 86, in async_wrapped
    return await fn(*args, **kwargs)
  File "/home/me/.local/lib/python3.10/site-packages/tenacity/_asyncio.py", line 48, in __call__
    do = self.iter(retry_state=retry_state)
  File "/home/me/.local/lib/python3.10/site-packages/tenacity/__init__.py", line 351, in iter
    return fut.result()
  File "/usr/lib/python3.10/concurrent/futures/_base.py", line 451, in result
    return self.__get_result()
  File "/usr/lib/python3.10/concurrent/futures/_base.py", line 403, in __get_result
    raise self._exception
  File "/home/me/.local/lib/python3.10/site-packages/tenacity/_asyncio.py", line 51, in __call__
    result = await fn(*args, **kwargs)
  File "/home/me/.local/lib/python3.10/site-packages/evnex/api.py", line 226, in get_charge_point_detail_v3
    return EvnexV3APIResponse[EvnexChargePointDetailV3](**json_data)
  File "pydantic/main.py", line 342, in pydantic.main.BaseModel.__init__
pydantic.error_wrappers.ValidationError: 1 validation error for EvnexV3APIResponse[EvnexChargePointDetail]
data -> attributes -> connectors -> 0 -> meter -> currentL1
  field required (type=value_error.missing)
hardbyte commented 2 years ago

I think you're running an installed version of the evnex libary (prior to my change last week). Let's try run the current main branch code in git, then the currentL1 missing error should go away and perhaps there will be others.

See in this last bit of the output:

  File "/home/me/.local/lib/python3.10/site-packages/evnex/api.py", line 226, in get_charge_point_detail_v3
    return EvnexV3APIResponse[EvnexChargePointDetailV3](**json_data)
  File "pydantic/main.py", line 342, in pydantic.main.BaseModel.__init__
pydantic.error_wrappers.ValidationError: 1 validation error for EvnexV3APIResponse[EvnexChargePointDetail]
data -> attributes -> connectors -> 0 -> meter -> currentL1
  field required (type=value_error.missing)

File "/home/me/.local/lib/python3.10/site-packages/evnex/api.py", line 226, in get_charge_point_detail_v3 should be pointing at the git code rather than into site-packages. Could you try running the example from the project directory (~/python-evnex-main)?

python -m examples.get_charge_point_detail

zorruno commented 2 years ago

note I'm away for a week, so will have to check again in a week's time.

Re evnex & pydantic installed with pip - these are the versions below (I also pulled python-evnex-main again)

Requirement already satisfied: evnex in /home/me/.local/lib/python3.10/site-packages (0.3.1)
Requirement already satisfied: pydantic<2.0,>=1.10 in /home/me/.local/lib/python3.10/site-packages (from evnex) (1.10.2)

I ran get_charge_point_detail from the project directory, and yes errors are different. I am assuming you mean python -m get_charge_point_detail

NOT python -m examples.get_charge_point_detail


me@mycomputer:~/python-evnex-main$ pwd
/home/me/python-evnex-main
me@mycomputer:~/python-evnex-main$ python -m get_charge_point_detail

DEBUG:asyncio:Using selector: EpollSelector
DEBUG:evnex.api:Creating evnex api instance
DEBUG:botocore.hooks:Changing event name from creating-client-class.iot-data to creating-client-class.iot-data-plane
DEBUG:botocore.hooks:Changing event name from before-call.apigateway to before-call.api-gateway
DEBUG:botocore.hooks:Changing event name from request-created.machinelearning.Predict to request-created.machine-learning.Predict
DEBUG:botocore.hooks:Changing event name from before-parameter-build.autoscaling.CreateLaunchConfiguration to before-parameter-build.auto-scaling.CreateLaunchConfiguration
DEBUG:botocore.hooks:Changing event name from before-parameter-build.route53 to before-parameter-build.route-53
DEBUG:botocore.hooks:Changing event name from request-created.cloudsearchdomain.Search to request-created.cloudsearch-domain.Search
DEBUG:botocore.hooks:Changing event name from docs.*.autoscaling.CreateLaunchConfiguration.complete-section to docs.*.auto-scaling.CreateLaunchConfiguration.complete-section
DEBUG:botocore.hooks:Changing event name from before-parameter-build.logs.CreateExportTask to before-parameter-build.cloudwatch-logs.CreateExportTask
DEBUG:botocore.hooks:Changing event name from docs.*.logs.CreateExportTask.complete-section to docs.*.cloudwatch-logs.CreateExportTask.complete-section
DEBUG:botocore.hooks:Changing event name from before-parameter-build.cloudsearchdomain.Search to before-parameter-build.cloudsearch-domain.Search
DEBUG:botocore.hooks:Changing event name from docs.*.cloudsearchdomain.Search.complete-section to docs.*.cloudsearch-domain.Search.complete-section
DEBUG:botocore.utils:IMDS ENDPOINT: http://169.254.169.254/
DEBUG:botocore.credentials:Looking for credentials via: env
DEBUG:botocore.credentials:Looking for credentials via: assume-role
DEBUG:botocore.credentials:Looking for credentials via: assume-role-with-web-identity
DEBUG:botocore.credentials:Looking for credentials via: sso
DEBUG:botocore.credentials:Looking for credentials via: shared-credentials-file
DEBUG:botocore.credentials:Looking for credentials via: custom-process
DEBUG:botocore.credentials:Looking for credentials via: config-file
DEBUG:botocore.credentials:Looking for credentials via: ec2-credentials-file
DEBUG:botocore.credentials:Looking for credentials via: boto-config
DEBUG:botocore.credentials:Looking for credentials via: container-role
DEBUG:botocore.credentials:Looking for credentials via: iam-role
DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): 169.254.169.254:80
DEBUG:botocore.utils:Caught retryable HTTP exception while making metadata service request to http://169.254.169.254/latest/api/token: Connect timeout on endpoint URL: "http://169.254.169.254/latest/api/token"
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 169, in _new_conn
    conn = connection.create_connection(
  File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 96, in create_connection
    raise err
  File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 86, in create_connection
    sock.connect(sa)
TimeoutError: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/me/.local/lib/python3.10/site-packages/botocore/httpsession.py", line 455, in send
    urllib_response = conn.urlopen(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 755, in urlopen
    retries = retries.increment(
  File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 507, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/usr/lib/python3/dist-packages/six.py", line 719, in reraise
    raise value
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 699, in urlopen
    httplib_response = self._make_request(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 394, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 234, in request
    super(HTTPConnection, self).request(method, url, body=body, headers=headers)
  File "/usr/lib/python3.10/http/client.py", line 1282, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/home/me/.local/lib/python3.10/site-packages/botocore/awsrequest.py", line 94, in _send_request
    rval = super()._send_request(
  File "/usr/lib/python3.10/http/client.py", line 1328, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.10/http/client.py", line 1277, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/home/me/.local/lib/python3.10/site-packages/botocore/awsrequest.py", line 123, in _send_output
    self.send(msg)
  File "/home/me/.local/lib/python3.10/site-packages/botocore/awsrequest.py", line 218, in send
    return super().send(str)
  File "/usr/lib/python3.10/http/client.py", line 975, in send
    self.connect()
  File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 200, in connect
    conn = self._new_conn()
  File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 174, in _new_conn
    raise ConnectTimeoutError(
urllib3.exceptions.ConnectTimeoutError: (<botocore.awsrequest.AWSHTTPConnection object at 0x7fcd8868e920>, 'Connection to 169.254.169.254 timed out. (connect timeout=1)')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/me/.local/lib/python3.10/site-packages/botocore/utils.py", line 456, in _fetch_metadata_token
    response = self._session.send(request.prepare())
  File "/home/me/.local/lib/python3.10/site-packages/botocore/httpsession.py", line 490, in send
    raise ConnectTimeoutError(endpoint_url=request.url, error=e)
botocore.exceptions.ConnectTimeoutError: Connect timeout on endpoint URL: "http://169.254.169.254/latest/api/token"
DEBUG:urllib3.connectionpool:Starting new HTTP connection (2): 169.254.169.254:80
DEBUG:botocore.utils:Caught retryable HTTP exception while making metadata service request to http://169.254.169.254/latest/meta-data/iam/security-credentials/: Connect timeout on endpoint URL: "http://169.254.169.254/latest/meta-data/iam/security-credentials/"
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 169, in _new_conn
    conn = connection.create_connection(
  File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 96, in create_connection
    raise err
  File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 86, in create_connection
    sock.connect(sa)
TimeoutError: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/me/.local/lib/python3.10/site-packages/botocore/httpsession.py", line 455, in send
    urllib_response = conn.urlopen(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 755, in urlopen
    retries = retries.increment(
  File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 507, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/usr/lib/python3/dist-packages/six.py", line 719, in reraise
    raise value
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 699, in urlopen
    httplib_response = self._make_request(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 394, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 234, in request
    super(HTTPConnection, self).request(method, url, body=body, headers=headers)
  File "/usr/lib/python3.10/http/client.py", line 1282, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/home/me/.local/lib/python3.10/site-packages/botocore/awsrequest.py", line 94, in _send_request
    rval = super()._send_request(
  File "/usr/lib/python3.10/http/client.py", line 1328, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.10/http/client.py", line 1277, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/home/me/.local/lib/python3.10/site-packages/botocore/awsrequest.py", line 123, in _send_output
    self.send(msg)
  File "/home/me/.local/lib/python3.10/site-packages/botocore/awsrequest.py", line 218, in send
    return super().send(str)
  File "/usr/lib/python3.10/http/client.py", line 975, in send
    self.connect()
  File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 200, in connect
    conn = self._new_conn()
  File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 174, in _new_conn
    raise ConnectTimeoutError(
urllib3.exceptions.ConnectTimeoutError: (<botocore.awsrequest.AWSHTTPConnection object at 0x7fcd8868f250>, 'Connection to 169.254.169.254 timed out. (connect timeout=1)')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/me/.local/lib/python3.10/site-packages/botocore/utils.py", line 509, in _get_request
    response = self._session.send(request.prepare())
  File "/home/me/.local/lib/python3.10/site-packages/botocore/httpsession.py", line 490, in send
    raise ConnectTimeoutError(endpoint_url=request.url, error=e)
botocore.exceptions.ConnectTimeoutError: Connect timeout on endpoint URL: "http://169.254.169.254/latest/meta-data/iam/security-credentials/"
DEBUG:botocore.utils:Max number of attempts exceeded (1) when attempting to retrieve data from metadata service.
DEBUG:botocore.loaders:Loading JSON file: /home/me/.local/lib/python3.10/site-packages/botocore/data/endpoints.json
DEBUG:botocore.loaders:Loading JSON file: /home/me/.local/lib/python3.10/site-packages/botocore/data/sdk-default-configuration.json
DEBUG:botocore.hooks:Event choose-service-name: calling handler <function handle_service_name_alias at 0x7fcd88bfb250>
DEBUG:botocore.loaders:Loading JSON file: /home/me/.local/lib/python3.10/site-packages/botocore/data/cognito-idp/2016-04-18/service-2.json
DEBUG:botocore.loaders:Loading JSON file: /home/me/.local/lib/python3.10/site-packages/botocore/data/cognito-idp/2016-04-18/endpoint-rule-set-1.json.gz
DEBUG:botocore.loaders:Loading JSON file: /home/me/.local/lib/python3.10/site-packages/botocore/data/partitions.json
DEBUG:botocore.hooks:Event creating-client-class.cognito-identity-provider: calling handler <function add_generate_presigned_url at 0x7fcd88eaee60>
DEBUG:botocore.endpoint:Setting cognito-idp timeout as (60, 60)
DEBUG:botocore.loaders:Loading JSON file: /home/me/.local/lib/python3.10/site-packages/botocore/data/_retry.json
DEBUG:botocore.client:Registering retry handlers for service: cognito-idp
DEBUG:evnex.api:Starting cognito auth flow
DEBUG:evnex.api:Authenticating to EVNEX cloud api
DEBUG:botocore.regions:Calling endpoint provider with parameters: {'Region': 'ap-southeast-2', 'UseDualStack': False, 'UseFIPS': False}
DEBUG:botocore.regions:Endpoint provider result: https://cognito-idp.ap-southeast-2.amazonaws.com
DEBUG:botocore.hooks:Event before-parameter-build.cognito-identity-provider.InitiateAuth: calling handler <function generate_idempotent_uuid at 0x7fcd88c18af0>
DEBUG:botocore.hooks:Event before-call.cognito-identity-provider.InitiateAuth: calling handler <function add_recursion_detection_header at 0x7fcd88c18790>
DEBUG:botocore.hooks:Event before-call.cognito-identity-provider.InitiateAuth: calling handler <function inject_api_version_header_if_needed at 0x7fcd88c1a320>
DEBUG:botocore.endpoint:Making request for OperationModel(name=InitiateAuth) with params: {'url_path': '/', 'query_string': '', 'method': 'POST', 'headers': {'X-Amz-Target': 'AWSCognitoIdentityProviderService.InitiateAuth', 'Content-Type': 'application/x-amz-json-1.1', 'User-Agent': 'Boto3/1.26.0 Python/3.10.6 Linux/5.15.0-52-generic Botocore/1.29.0'}, 'body': b'{"AuthFlow": "USER_SRP_AUTH", "AuthParameters": {"USERNAME": "myemail@address", "SRP_A": "cedbea4d2eec6d8b947293990b72e05bbd0bbfdff40c9c199367680dc9683d7d21573064d4372d850609e65b6803dd43f4c9ac6d823a3d8aaa2744bd600a29ceaab809746a97b6c27444d181978763a06fd63ced8c16b45c25ddd1b1e5c8a2cabeb9b339662a7ecf68eea04d735e008f1630b2fbe87b60418d396736bcf4e4558c0757866595eb51cd81771ae552bcbbf7bbb16736d06b7e2a018744dc2db7ba3132bfadf46467802dde4a968405a967a196ac06b5c213f95c02cbb8c8f941477faad74ca1555639a341e3ff8a93c9208884a206145cecb77cacf8b4f353d56f713bc73df75e37ae607cb22eecde0f8a562425c25362d6211aac84bf0006bdefafc0beacc693bd71a2e9301e1204f906936c291cb79e140b0e0db0a57f0d133890da8eae3bdb75dd84044ddc163925c5f12e92d642070e428f51ea68b41f1f2484b25c211cd826b5ca8b8a33091a15b104bd2479879acee2918e11e23008ce6e6ad67d9e22df7a270ff4e6c6d00807e56e01488701291654a5e4eafd5e1ce927"}, "ClientId": "rol3lsv2vg41783550i18r7vi"}', 'url': 'https://cognito-idp.ap-southeast-2.amazonaws.com/', 'context': {'client_region': 'ap-southeast-2', 'client_config': <botocore.config.Config object at 0x7fcd88428940>, 'has_streaming_input': False, 'auth_type': 'none'}}
DEBUG:botocore.hooks:Event request-created.cognito-identity-provider.InitiateAuth: calling handler <bound method RequestSigner.handler of <botocore.signers.RequestSigner object at 0x7fcd884287f0>>
DEBUG:botocore.hooks:Event choose-signer.cognito-identity-provider.InitiateAuth: calling handler <function set_operation_specific_signer at 0x7fcd88c189d0>
DEBUG:botocore.hooks:Event request-created.cognito-identity-provider.InitiateAuth: calling handler <function add_retry_headers at 0x7fcd88c1a9e0>
DEBUG:botocore.endpoint:Sending http request: <AWSPreparedRequest stream_output=False, method=POST, url=https://cognito-idp.ap-southeast-2.amazonaws.com/, headers={'X-Amz-Target': b'AWSCognitoIdentityProviderService.InitiateAuth', 'Content-Type': b'application/x-amz-json-1.1', 'User-Agent': b'Boto3/1.26.0 Python/3.10.6 Linux/5.15.0-52-generic Botocore/1.29.0', 'amz-sdk-invocation-id': b'42d65b40-e806-49a6-a017-b4f3d1acb450', 'amz-sdk-request': b'attempt=1', 'Content-Length': '909'}>
DEBUG:botocore.httpsession:Certificate path: /etc/ssl/certs/ca-certificates.crt
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): cognito-idp.ap-southeast-2.amazonaws.com:443
DEBUG:urllib3.connectionpool:https://cognito-idp.ap-southeast-2.amazonaws.com:443 "POST / HTTP/1.1" 200 2703
DEBUG:botocore.parsers:Response headers: {'Date': 'Sat, 12 Nov 2022 09:48:41 GMT', 'Content-Type': 'application/x-amz-json-1.1', 'Content-Length': '2703', 'Connection': 'keep-alive', 'x-amzn-RequestId': 'c660665b-2a58-4d75-a05a-29bcb142ee71'}
DEBUG:botocore.parsers:Response body:
b'{"ChallengeName":"PASSWORD_VERIFIER","ChallengeParameters":{"SALT":"REDACTED","SRP_B":"RED","USERNAME":"myemail@address","USER_ID_FOR_SRP":"myemail@address"}}'
DEBUG:botocore.hooks:Event needs-retry.cognito-identity-provider.InitiateAuth: calling handler <botocore.retryhandler.RetryHandler object at 0x7fcd88429c00>
DEBUG:botocore.retryhandler:No retry needed.
DEBUG:botocore.regions:Calling endpoint provider with parameters: {'Region': 'ap-southeast-2', 'UseDualStack': False, 'UseFIPS': False}
DEBUG:botocore.regions:Endpoint provider result: https://cognito-idp.ap-southeast-2.amazonaws.com
DEBUG:botocore.hooks:Event before-parameter-build.cognito-identity-provider.RespondToAuthChallenge: calling handler <function generate_idempotent_uuid at 0x7fcd88c18af0>
DEBUG:botocore.hooks:Event before-call.cognito-identity-provider.RespondToAuthChallenge: calling handler <function add_recursion_detection_header at 0x7fcd88c18790>
DEBUG:botocore.hooks:Event before-call.cognito-identity-provider.RespondToAuthChallenge: calling handler <function inject_api_version_header_if_needed at 0x7fcd88c1a320>
DEBUG:botocore.endpoint:Making request for OperationModel(name=RespondToAuthChallenge) with params: {'url_path': '/', 'query_string': '', 'method': 'POST', 'headers': {'X-Amz-Target': 'AWSCognitoIdentityProviderService.RespondToAuthChallenge', 'Content-Type': 'application/x-amz-json-1.1', 'User-Agent': 'Boto3/1.26.0 Python/3.10.6 Linux/5.15.0-52-generic Botocore/1.29.0'}, 'body': b'{"ClientId": "rol3lsv2vg41783550i18r7vi", "ChallengeName": "PASSWORD_VERIFIER", "ChallengeResponses": {"TIMESTAMP": "Sat Nov 12 09:48:41 UTC 2022", "USERNAME": "myemail@address", "PASSWORD_CLAIM_SECRET_BLOCK": "", "PASSWORD_CLAIM_SIGNATURE": ""}}', 'url': 'https://cognito-idp.ap-southeast-2.amazonaws.com/', 'context': {'client_region': 'ap-southeast-2', 'client_config': <botocore.config.Config object at 0x7fcd88428940>, 'has_streaming_input': False, 'auth_type': 'none'}}
DEBUG:botocore.hooks:Event request-created.cognito-identity-provider.RespondToAuthChallenge: calling handler <bound method RequestSigner.handler of <botocore.signers.RequestSigner object at 0x7fcd884287f0>>
DEBUG:botocore.hooks:Event choose-signer.cognito-identity-provider.RespondToAuthChallenge: calling handler <function set_operation_specific_signer at 0x7fcd88c189d0>
DEBUG:botocore.hooks:Event request-created.cognito-identity-provider.RespondToAuthChallenge: calling handler <function add_retry_headers at 0x7fcd88c1a9e0>
DEBUG:botocore.endpoint:Sending http request: <AWSPreparedRequest stream_output=False, method=POST, url=https://cognito-idp.ap-southeast-2.amazonaws.com/, headers={'X-Amz-Target': b'AWSCognitoIdentityProviderService.RespondToAuthChallenge', 'Content-Type': b'application/x-amz-json-1.1', 'User-Agent': b'Boto3/1.26.0 Python/3.10.6 Linux/5.15.0-52-generic Botocore/1.29.0', 'amz-sdk-invocation-id': b'2b7e5cc0-b309-4922-aae5-9e8a3f52e17c', 'amz-sdk-request': b'attempt=1', 'Content-Length': '2021'}>
DEBUG:botocore.httpsession:Certificate path: /etc/ssl/certs/ca-certificates.crt
DEBUG:urllib3.connectionpool:https://cognito-idp.ap-southeast-2.amazonaws.com:443 "POST / HTTP/1.1" 200 3938
DEBUG:botocore.parsers:Response headers: {'Date': 'Sat, 12 Nov 2022 09:48:42 GMT', 'Content-Type': 'application/x-amz-json-1.1', 'Content-Length': '3938', 'Connection': 'keep-alive', 'x-amzn-RequestId': '34741388-df73-47e2-a18a-533bbc84c482'}
DEBUG:botocore.parsers:Response body:
b'{"AuthenticationResult":{"AccessToken":"","TokenType":"Bearer"},"ChallengeParameters":{}}'
DEBUG:botocore.hooks:Event needs-retry.cognito-identity-provider.RespondToAuthChallenge: calling handler <botocore.retryhandler.RetryHandler object at 0x7fcd88429c00>
DEBUG:botocore.retryhandler:No retry needed.
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): cognito-idp.ap-southeast-2.amazonaws.com:443
DEBUG:urllib3.connectionpool:https://cognito-idp.ap-southeast-2.amazonaws.com:443 "GET /ap-southeast-2_zWnqo6ASv/.well-known/jwks.json HTTP/1.1" 200 916
DEBUG:httpx._client:HTTP Request: GET https://client-api.evnex.io/v2/apps/user "HTTP/1.1 200 OK"
User: myemail@address myemail@address fef105f7-bc44-491a-a10c-e94f9d45008c
Getting charge points for 'Vector CPO'
DEBUG:evnex.api:Listing org charge points
DEBUG:httpx._client:HTTP Request: GET https://client-api.evnex.io/v2/apps/organisations/1b4d1066-2/charge-points "HTTP/1.1 200 OK"
Redacted Charger Name ONLINE AB12345678 1b4d1066-2
charge point details (API V3)
DEBUG:httpx._client:HTTP Request: GET https://client-api.evnex.io/v3/charge-points/1b4d1066-2 "HTTP/1.1 200 OK"
data=EvnexV3Data[EvnexChargePointDetail](id='1b4d1066-2', type='chargePoints', attributes=EvnexChargePointDetail(connectors=[EvnexChargePointConnector(evseId='ENX-E1DEE70C6-1', connectorFormat='SOCKET', connectorType='IEC_62196_T2', ocppStatus='CHARGING', powerType='AC_1_PHASE', connectorId='1', ocppCode='NoError', updatedDate=datetime.datetime(2020, 10, 4, 12, 41, 31, 755000, tzinfo=datetime.timezone.utc), meter=EvnexChargePointConnectorMeter(currentL1=None, frequency=50.0, power=0.0, updatedDate=datetime.datetime(2022, 11, 12, 9, 46, 39, tzinfo=datetime.timezone.utc), voltageL1N=None), maxVoltage=240.0, maxAmperage=32.0)], createdDate=datetime.datetime(2019, 9, 25, 3, 28, 58, tzinfo=datetime.timezone.utc), electricityCost=EvnexElectricityCost(currency='NZD', tariffs=[EvnexElectricityTariff(start=0.0, rate=0.2, type='Flat')], tariffType='Flat', cost=0.2), firmware='1.4.1.D62DFF1', iccid='8964050087213569937', maxCurrent=32.0, model='R7-T2S-3G', name='Redacted Charger Name', networkStatus='ONLINE', networkStatusUpdatedDate=datetime.datetime(2022, 11, 12, 9, 48, 17, 268000, tzinfo=datetime.timezone.utc), ocppChargePointId='ENX-AB12345678', profiles=EvnexChargeProfile(chargeSchedule=EvnexChargeSchedule(enabled=True, chargingSchedulePeriods=[EvnexChargeSchedulePeriod(limit=32.0, startPeriod=0.0), EvnexChargeSchedulePeriod(limit=0.0, startPeriod=36000.0), EvnexChargeSchedulePeriod(limit=32.0, startPeriod=75660.0)])), serial='AB12345678', timeZone='Pacific/Auckland', tokenRequired=False, updatedDate=datetime.datetime(2022, 11, 12, 3, 28, 51, 645000, tzinfo=datetime.timezone.utc), vendor='Evnex'), relationships=EvnexRelationships(location=EvnexRelationshipWrapper(data=EvnexRelationship(id='1b4d1066-2', type='locations')), organisation=EvnexRelationshipWrapper(data=EvnexRelationship(id='1b4d1066-2', type='organisations')))) included=[EvnexV3Include(id='1b4d1066-2', type='locations', attributes={'name': 'REDACTED', 'address': {'address1': 'REDACTED', 'city': 'Auckland', 'country': 'NZ'}, 'coordinates': {'latitude': '', 'longitude': ''}, 'isPublic': False, 'updated': '2022-03-19T06:20:21.869Z', 'created': '-18T21:56:39.613Z'})]
Getting charge override setting
DEBUG:httpx._client:HTTP Request: POST https://client-api.evnex.io/v3/charge-points/-/commands/get-override "HTTP/1.1 200 OK"
Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/me/python-evnex-main/get_charge_point_detail.py", line 91, in <module>
    asyncio.run(main())
  File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete
    return future.result()
  File "/home/me/python-evnex-main/get_charge_point_detail.py", line 55, in main
    override = await evnex.get_charge_point_override(
  File "/home/me/.local/lib/python3.10/site-packages/tenacity/_asyncio.py", line 86, in async_wrapped
    return await fn(*args, **kwargs)
  File "/home/me/.local/lib/python3.10/site-packages/tenacity/_asyncio.py", line 48, in __call__
    do = self.iter(retry_state=retry_state)
  File "/home/me/.local/lib/python3.10/site-packages/tenacity/__init__.py", line 351, in iter
    return fut.result()
  File "/usr/lib/python3.10/concurrent/futures/_base.py", line 451, in result
    return self.__get_result()
  File "/usr/lib/python3.10/concurrent/futures/_base.py", line 403, in __get_result
    raise self._exception
  File "/home/me/.local/lib/python3.10/site-packages/tenacity/_asyncio.py", line 51, in __call__
    result = await fn(*args, **kwargs)
  File "/home/me/python-evnex-main/evnex/api.py", line 267, in get_charge_point_override
    return EvnexChargePointOverrideConfig(**json_data)
  File "pydantic/main.py", line 342, in pydantic.main.BaseModel.__init__
pydantic.error_wrappers.ValidationError: 1 validation error for EvnexChargePointOverrideConfig
chargeNow
  value could not be parsed to a boolean (type=type_error.bool)
hardbyte commented 2 years ago

The issue above is that the request to get the charge point override doesn't seem to include the ID:

Getting charge override setting
DEBUG:httpx._client:HTTP Request: POST https://client-api.evnex.io/v3/charge-points/-/commands/get-override "HTTP/1.1 200 OK"

Not sure why the charge point ID didn't make it into the query

The idea with running from the project directory instead of the examples directory is so Python would use the latest code from git instead of the released version which was installed with pip. It might not work without using a Python virtual environment though.

Not to worry, I've made a new release, so if you want to update your installed version and git pull the latest example code let's try again.

pip install -U evnex
zorruno commented 1 year ago
me@mycomputer:~/python-evnex/examples$ pip show evnex
Name: evnex
Version: 0.3.3

Output

me@mycomputer:~/python-evnex/examples$ python -m get_charge_point_detail
DEBUG:asyncio:Using selector: EpollSelector
DEBUG:evnex.api:Creating evnex api instance
DEBUG:botocore.hooks:Changing event name from creating-client-class.iot-data to creating-client-class.iot-data-plane
DEBUG:botocore.hooks:Changing event name from before-call.apigateway to before-call.api-gateway
DEBUG:botocore.hooks:Changing event name from request-created.machinelearning.Predict to request-created.machine-learning.Predict
DEBUG:botocore.hooks:Changing event name from before-parameter-build.autoscaling.CreateLaunchConfiguration to before-parameter-build.auto-scaling.CreateLaunchConfiguration
DEBUG:botocore.hooks:Changing event name from before-parameter-build.route53 to before-parameter-build.route-53
DEBUG:botocore.hooks:Changing event name from request-created.cloudsearchdomain.Search to request-created.cloudsearch-domain.Search
DEBUG:botocore.hooks:Changing event name from docs.*.autoscaling.CreateLaunchConfiguration.complete-section to docs.*.auto-scaling.CreateLaunchConfiguration.complete-section
DEBUG:botocore.hooks:Changing event name from before-parameter-build.logs.CreateExportTask to before-parameter-build.cloudwatch-logs.CreateExportTask
DEBUG:botocore.hooks:Changing event name from docs.*.logs.CreateExportTask.complete-section to docs.*.cloudwatch-logs.CreateExportTask.complete-section
DEBUG:botocore.hooks:Changing event name from before-parameter-build.cloudsearchdomain.Search to before-parameter-build.cloudsearch-domain.Search
DEBUG:botocore.hooks:Changing event name from docs.*.cloudsearchdomain.Search.complete-section to docs.*.cloudsearch-domain.Search.complete-section
DEBUG:botocore.utils:IMDS ENDPOINT: http://169.254.169.254/
DEBUG:botocore.credentials:Looking for credentials via: env
DEBUG:botocore.credentials:Looking for credentials via: assume-role
DEBUG:botocore.credentials:Looking for credentials via: assume-role-with-web-identity
DEBUG:botocore.credentials:Looking for credentials via: sso
DEBUG:botocore.credentials:Looking for credentials via: shared-credentials-file
DEBUG:botocore.credentials:Looking for credentials via: custom-process
DEBUG:botocore.credentials:Looking for credentials via: config-file
DEBUG:botocore.credentials:Looking for credentials via: ec2-credentials-file
DEBUG:botocore.credentials:Looking for credentials via: boto-config
DEBUG:botocore.credentials:Looking for credentials via: container-role
DEBUG:botocore.credentials:Looking for credentials via: iam-role
DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): 169.254.169.254:80
DEBUG:botocore.utils:Caught retryable HTTP exception while making metadata service request to http://169.254.169.254/latest/api/token: Connect timeout on endpoint URL: "http://169.254.169.254/latest/api/token"
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 169, in _new_conn
    conn = connection.create_connection(
  File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 96, in create_connection
    raise err
  File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 86, in create_connection
    sock.connect(sa)
TimeoutError: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/me/.local/lib/python3.10/site-packages/botocore/httpsession.py", line 455, in send
    urllib_response = conn.urlopen(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 755, in urlopen
    retries = retries.increment(
  File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 507, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/usr/lib/python3/dist-packages/six.py", line 719, in reraise
    raise value
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 699, in urlopen
    httplib_response = self._make_request(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 394, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 234, in request
    super(HTTPConnection, self).request(method, url, body=body, headers=headers)
  File "/usr/lib/python3.10/http/client.py", line 1282, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/home/me/.local/lib/python3.10/site-packages/botocore/awsrequest.py", line 94, in _send_request
    rval = super()._send_request(
  File "/usr/lib/python3.10/http/client.py", line 1328, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.10/http/client.py", line 1277, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/home/me/.local/lib/python3.10/site-packages/botocore/awsrequest.py", line 123, in _send_output
    self.send(msg)
  File "/home/me/.local/lib/python3.10/site-packages/botocore/awsrequest.py", line 218, in send
    return super().send(str)
  File "/usr/lib/python3.10/http/client.py", line 975, in send
    self.connect()
  File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 200, in connect
    conn = self._new_conn()
  File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 174, in _new_conn
    raise ConnectTimeoutError(
urllib3.exceptions.ConnectTimeoutError: (<botocore.awsrequest.AWSHTTPConnection object at 0x7f6e9e86a980>, 'Connection to 169.254.169.254 timed out. (connect timeout=1)')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/me/.local/lib/python3.10/site-packages/botocore/utils.py", line 456, in _fetch_metadata_token
    response = self._session.send(request.prepare())
  File "/home/me/.local/lib/python3.10/site-packages/botocore/httpsession.py", line 490, in send
    raise ConnectTimeoutError(endpoint_url=request.url, error=e)
botocore.exceptions.ConnectTimeoutError: Connect timeout on endpoint URL: "http://169.254.169.254/latest/api/token"
DEBUG:urllib3.connectionpool:Starting new HTTP connection (2): 169.254.169.254:80
DEBUG:botocore.utils:Caught retryable HTTP exception while making metadata service request to http://169.254.169.254/latest/meta-data/iam/security-credentials/: Connect timeout on endpoint URL: "http://169.254.169.254/latest/meta-data/iam/security-credentials/"
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 169, in _new_conn
    conn = connection.create_connection(
  File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 96, in create_connection
    raise err
  File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 86, in create_connection
    sock.connect(sa)
TimeoutError: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/me/.local/lib/python3.10/site-packages/botocore/httpsession.py", line 455, in send
    urllib_response = conn.urlopen(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 755, in urlopen
    retries = retries.increment(
  File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 507, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/usr/lib/python3/dist-packages/six.py", line 719, in reraise
    raise value
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 699, in urlopen
    httplib_response = self._make_request(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 394, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 234, in request
    super(HTTPConnection, self).request(method, url, body=body, headers=headers)
  File "/usr/lib/python3.10/http/client.py", line 1282, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/home/me/.local/lib/python3.10/site-packages/botocore/awsrequest.py", line 94, in _send_request
    rval = super()._send_request(
  File "/usr/lib/python3.10/http/client.py", line 1328, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.10/http/client.py", line 1277, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/home/me/.local/lib/python3.10/site-packages/botocore/awsrequest.py", line 123, in _send_output
    self.send(msg)
  File "/home/me/.local/lib/python3.10/site-packages/botocore/awsrequest.py", line 218, in send
    return super().send(str)
  File "/usr/lib/python3.10/http/client.py", line 975, in send
    self.connect()
  File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 200, in connect
    conn = self._new_conn()
  File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 174, in _new_conn
    raise ConnectTimeoutError(
urllib3.exceptions.ConnectTimeoutError: (<botocore.awsrequest.AWSHTTPConnection object at 0x7f6e9e86b2b0>, 'Connection to 169.254.169.254 timed out. (connect timeout=1)')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/me/.local/lib/python3.10/site-packages/botocore/utils.py", line 509, in _get_request
    response = self._session.send(request.prepare())
  File "/home/me/.local/lib/python3.10/site-packages/botocore/httpsession.py", line 490, in send
    raise ConnectTimeoutError(endpoint_url=request.url, error=e)
botocore.exceptions.ConnectTimeoutError: Connect timeout on endpoint URL: "http://169.254.169.254/latest/meta-data/iam/security-credentials/"
DEBUG:botocore.utils:Max number of attempts exceeded (1) when attempting to retrieve data from metadata service.
DEBUG:botocore.loaders:Loading JSON file: /home/me/.local/lib/python3.10/site-packages/botocore/data/endpoints.json
DEBUG:botocore.loaders:Loading JSON file: /home/me/.local/lib/python3.10/site-packages/botocore/data/sdk-default-configuration.json
DEBUG:botocore.hooks:Event choose-service-name: calling handler <function handle_service_name_alias at 0x7f6e9edd7490>
DEBUG:botocore.loaders:Loading JSON file: /home/me/.local/lib/python3.10/site-packages/botocore/data/cognito-idp/2016-04-18/service-2.json
DEBUG:botocore.loaders:Loading JSON file: /home/me/.local/lib/python3.10/site-packages/botocore/data/cognito-idp/2016-04-18/endpoint-rule-set-1.json.gz
DEBUG:botocore.loaders:Loading JSON file: /home/me/.local/lib/python3.10/site-packages/botocore/data/partitions.json
DEBUG:botocore.hooks:Event creating-client-class.cognito-identity-provider: calling handler <function add_generate_presigned_url at 0x7f6e9f0870a0>
DEBUG:botocore.endpoint:Setting cognito-idp timeout as (60, 60)
DEBUG:botocore.loaders:Loading JSON file: /home/me/.local/lib/python3.10/site-packages/botocore/data/_retry.json
DEBUG:botocore.client:Registering retry handlers for service: cognito-idp
DEBUG:evnex.api:Starting cognito auth flow
DEBUG:evnex.api:Authenticating to EVNEX cloud api
DEBUG:botocore.regions:Calling endpoint provider with parameters: {'Region': 'ap-southeast-2', 'UseDualStack': False, 'UseFIPS': False}
DEBUG:botocore.regions:Endpoint provider result: https://cognito-idp.ap-southeast-2.amazonaws.com
DEBUG:botocore.hooks:Event before-parameter-build.cognito-identity-provider.InitiateAuth: calling handler <function generate_idempotent_uuid at 0x7f6e9edf4d30>
DEBUG:botocore.hooks:Event before-call.cognito-identity-provider.InitiateAuth: calling handler <function add_recursion_detection_header at 0x7f6e9edf49d0>
DEBUG:botocore.hooks:Event before-call.cognito-identity-provider.InitiateAuth: calling handler <function inject_api_version_header_if_needed at 0x7f6e9edf6560>
DEBUG:botocore.endpoint:Making request for OperationModel(name=InitiateAuth) with params: {'url_path': '/', 'query_string': '', 'method': 'POST', 'headers': {'X-Amz-Target': 'AWSCognitoIdentityProviderService.InitiateAuth', 'Content-Type': 'application/x-amz-json-1.1', 'User-Agent': 'Boto3/1.26.0 Python/3.10.6 Linux/5.15.0-56-generic Botocore/1.29.0'}, 'body': b'{"AuthFlow": "USER_SRP_AUTH", "AuthParameters": {"USERNAME": "my@emailaddress", "SRP_A": "REDACTED"}, "ClientId": "REDACTED"}', 'url': 'https://cognito-idp.ap-southeast-2.amazonaws.com/', 'context': {'client_region': 'ap-southeast-2', 'client_config': <botocore.config.Config object at 0x7f6e9dfd09a0>, 'has_streaming_input': False, 'auth_type': 'none'}}
DEBUG:botocore.hooks:Event request-created.cognito-identity-provider.InitiateAuth: calling handler <bound method RequestSigner.handler of <botocore.signers.RequestSigner object at 0x7f6e9dfd0850>>
DEBUG:botocore.hooks:Event choose-signer.cognito-identity-provider.InitiateAuth: calling handler <function set_operation_specific_signer at 0x7f6e9edf4c10>
DEBUG:botocore.hooks:Event request-created.cognito-identity-provider.InitiateAuth: calling handler <function add_retry_headers at 0x7f6e9edf6c20>
DEBUG:botocore.endpoint:Sending http request: <AWSPreparedRequest stream_output=False, method=POST, url=https://cognito-idp.ap-southeast-2.amazonaws.com/, headers={'X-Amz-Target': b'AWSCognitoIdentityProviderService.InitiateAuth', 'Content-Type': b'application/x-amz-json-1.1', 'User-Agent': b'Boto3/1.26.0 Python/3.10.6 Linux/5.15.0-56-generic Botocore/1.29.0', 'amz-sdk-invocation-id': b'40c70791-8e76-4c54-8202-a092cff96d03', 'amz-sdk-request': b'attempt=1', 'Content-Length': '909'}>
DEBUG:botocore.httpsession:Certificate path: /etc/ssl/certs/ca-certificates.crt
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): cognito-idp.ap-southeast-2.amazonaws.com:443
DEBUG:urllib3.connectionpool:https://cognito-idp.ap-southeast-2.amazonaws.com:443 "POST / HTTP/1.1" 200 2703
DEBUG:botocore.parsers:Response headers: {'Date': 'Thu, 08 Dec 2022 23:40:53 GMT', 'Content-Type': 'application/x-amz-json-1.1', 'Content-Length': '2703', 'Connection': 'keep-alive', 'x-amzn-RequestId': 'f29dd064-5968-467a-a2d7-146eed252000'}
DEBUG:botocore.parsers:Response body:
b'{"ChallengeName":"PASSWORD_VERIFIER","ChallengeParameters":{"SALT":"REDACTED","SRP_B":"REDACTED","USERNAME":"my@emailaddress","USER_ID_FOR_SRP":"my@emailaddress"}}'
DEBUG:botocore.hooks:Event needs-retry.cognito-identity-provider.InitiateAuth: calling handler <botocore.retryhandler.RetryHandler object at 0x7f6e9dfd1c60>
DEBUG:botocore.retryhandler:No retry needed.
DEBUG:botocore.regions:Calling endpoint provider with parameters: {'Region': 'ap-southeast-2', 'UseDualStack': False, 'UseFIPS': False}
DEBUG:botocore.regions:Endpoint provider result: https://cognito-idp.ap-southeast-2.amazonaws.com
DEBUG:botocore.hooks:Event before-parameter-build.cognito-identity-provider.RespondToAuthChallenge: calling handler <function generate_idempotent_uuid at 0x7f6e9edf4d30>
DEBUG:botocore.hooks:Event before-call.cognito-identity-provider.RespondToAuthChallenge: calling handler <function add_recursion_detection_header at 0x7f6e9edf49d0>
DEBUG:botocore.hooks:Event before-call.cognito-identity-provider.RespondToAuthChallenge: calling handler <function inject_api_version_header_if_needed at 0x7f6e9edf6560>
DEBUG:botocore.endpoint:Making request for OperationModel(name=RespondToAuthChallenge) with params: {'url_path': '/', 'query_string': '', 'method': 'POST', 'headers': {'X-Amz-Target': 'AWSCognitoIdentityProviderService.RespondToAuthChallenge', 'Content-Type': 'application/x-amz-json-1.1', 'User-Agent': 'Boto3/1.26.0 Python/3.10.6 Linux/5.15.0-56-generic Botocore/1.29.0'}, 'body': b'{"ClientId": "rol3lsv2vg41783550i18r7vi", "ChallengeName": "PASSWORD_VERIFIER", "ChallengeResponses": {"TIMESTAMP": "Thu Dec 8 23:40:53 UTC 2022", "USERNAME": "my@emailaddress", "PASSWORD_CLAIM_SECRET_BLOCK": "REDACTED", "PASSWORD_CLAIM_SIGNATURE": "REDACTED"}}', 'url': 'https://cognito-idp.ap-southeast-2.amazonaws.com/', 'context': {'client_region': 'ap-southeast-2', 'client_config': <botocore.config.Config object at 0x7f6e9dfd09a0>, 'has_streaming_input': False, 'auth_type': 'none'}}
DEBUG:botocore.hooks:Event request-created.cognito-identity-provider.RespondToAuthChallenge: calling handler <bound method RequestSigner.handler of <botocore.signers.RequestSigner object at 0x7f6e9dfd0850>>
DEBUG:botocore.hooks:Event choose-signer.cognito-identity-provider.RespondToAuthChallenge: calling handler <function set_operation_specific_signer at 0x7f6e9edf4c10>
DEBUG:botocore.hooks:Event request-created.cognito-identity-provider.RespondToAuthChallenge: calling handler <function add_retry_headers at 0x7f6e9edf6c20>
DEBUG:botocore.endpoint:Sending http request: <AWSPreparedRequest stream_output=False, method=POST, url=https://cognito-idp.ap-southeast-2.amazonaws.com/, headers={'X-Amz-Target': b'AWSCognitoIdentityProviderService.RespondToAuthChallenge', 'Content-Type': b'application/x-amz-json-1.1', 'User-Agent': b'Boto3/1.26.0 Python/3.10.6 Linux/5.15.0-56-generic Botocore/1.29.0', 'amz-sdk-invocation-id': b'715eaaf2-7676-4997-9db7-b3870003f4fb', 'amz-sdk-request': b'attempt=1', 'Content-Length': '2020'}>
DEBUG:botocore.httpsession:Certificate path: /etc/ssl/certs/ca-certificates.crt
DEBUG:urllib3.connectionpool:https://cognito-idp.ap-southeast-2.amazonaws.com:443 "POST / HTTP/1.1" 200 3938
DEBUG:botocore.parsers:Response headers: {'Date': 'Thu, 08 Dec 2022 23:40:53 GMT', 'Content-Type': 'application/x-amz-json-1.1', 'Content-Length': '3938', 'Connection': 'keep-alive', 'x-amzn-RequestId': 'ebad9573-111e-4931-892b-dd00922edacd'}
DEBUG:botocore.parsers:Response body:
b'{"AuthenticationResult":{"AccessToken":"REDACTED","TokenType":"Bearer"},"ChallengeParameters":{}}'
DEBUG:botocore.hooks:Event needs-retry.cognito-identity-provider.RespondToAuthChallenge: calling handler <botocore.retryhandler.RetryHandler object at 0x7f6e9dfd1c60>
DEBUG:botocore.retryhandler:No retry needed.
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): cognito-idp.ap-southeast-2.amazonaws.com:443
DEBUG:urllib3.connectionpool:https://cognito-idp.ap-southeast-2.amazonaws.com:443 "GET /ap-southeast-2_zWnqo6ASv/.well-known/jwks.json HTTP/1.1" 200 916
DEBUG:httpx._client:HTTP Request: GET https://client-api.evnex.io/v2/apps/user "HTTP/1.1 200 OK"
DEBUG:evnex.api:Raw EVNEX API response.
200
{"data":{"email":"my@emailaddress","createdDate":"2019-09-25T23:55:13.750Z","id":"fef105f7-bc44-491a-a10c-e94f9d45008c","organisations":[{"id":"497ed299-8b92-4add-b56f-317dbcfa1a3d","isDefault":true,"role":2,"createdDate":"2020-02-18T21:56:38.102Z","name":"Vector CPO","namespacePrefix":"0372","slug":"497ed299-8b92-4add-b56f-317dbcfa1a3d","tier":4,"tierDetails":{"apiAccess":true},"updatedDate":"2020-02-18T21:56:38.102Z"}],"updatedDate":"2020-02-18T21:56:38.557Z","type":"User"}}
Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/me/python-evnex/examples/get_charge_point_detail.py", line 94, in <module>
    asyncio.run(main())
  File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete
    return future.result()
  File "/home/me/python-evnex/examples/get_charge_point_detail.py", line 23, in main
    user_data = await evnex.get_user_detail()
  File "/home/me/.local/lib/python3.10/site-packages/tenacity/_asyncio.py", line 86, in async_wrapped
    return await fn(*args, **kwargs)
  File "/home/me/.local/lib/python3.10/site-packages/tenacity/_asyncio.py", line 48, in __call__
    do = self.iter(retry_state=retry_state)
  File "/home/me/.local/lib/python3.10/site-packages/tenacity/__init__.py", line 351, in iter
    return fut.result()
  File "/usr/lib/python3.10/concurrent/futures/_base.py", line 451, in result
    return self.__get_result()
  File "/usr/lib/python3.10/concurrent/futures/_base.py", line 403, in __get_result
    raise self._exception
  File "/home/me/.local/lib/python3.10/site-packages/tenacity/_asyncio.py", line 51, in __call__
    result = await fn(*args, **kwargs)
  File "/home/me/.local/lib/python3.10/site-packages/evnex/api.py", line 135, in get_user_detail
    data = EvnexGetUserResponse(**response_json).data
  File "pydantic/main.py", line 342, in pydantic.main.BaseModel.__init__
pydantic.error_wrappers.ValidationError: 1 validation error for EvnexGetUserResponse
data -> name
  field required (type=value_error.missing)
zorruno commented 1 year ago

recap after updating to the latest version as I tried to reimplement this from scratch to see if anything had changed for me.

Reinstalled via HACS. Attempted to use Evnex integration, but still can't get past the usename/pass stage. I can login to https://app.evnex.io/ no problem (in a browser), and my evnex phone app works with the same credentials.

Other potential things of note (or hopefully of no note whatsoever)

  1. My username (email address) has a hyphen in it... otherwise not special)
  2. The wallbox was installed as part of the Vector trial, so my organisation within Evnex is fixed at "Vector CPO"
zorruno commented 1 year ago

Thought I'd retry as recently I have changed from the Vector residential trial to being a 'residential free holding' account. Started from scratch, removed then re-added the repo via HACS and installed the integration (v0.3.5)

I can still log in to https://app.evnex.io/ in a browser, but with the same credentials I get this 'unknown' error (as per screenshot)

image