Vehicle information through OnStar?

Not yet - don’t have multiple cars with onstar so…

Strange error. Is there more?
Please update since I see you forked from my code. There were some changes.
Here is what I see:

Does "services.yaml" go in the "custom_components/onstar_components" directory?

yes
it is information for HA about service

image

Here’s the error log.

2019-10-17 16:44:50 ERROR (MainThread) [homeassistant.loader] Error loading custom_components.onstar_component. Make sure all dependencies are installed
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/loader.py", line 346, in _load_file
    module = importlib.import_module(path)
  File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/homeassistant/.homeassistant/custom_components/onstar_component/__init__.py", line 8, in <module>
    from onstar import onstar
ModuleNotFoundError: No module named 'onstar'
2019-10-17 16:44:51 ERROR (MainThread) [homeassistant.loader] Error loading custom_components.onstar_component. Make sure all dependencies are installed
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/loader.py", line 346, in _load_file
    module = importlib.import_module(path)
  File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/homeassistant/.homeassistant/custom_components/onstar_component/__init__.py", line 8, in <module>
    from onstar import onstar
ModuleNotFoundError: No module named 'onstar'
2019-10-17 16:44:54 ERROR (MainThread) [homeassistant.loader] Error loading custom_components.onstar_component. Make sure all dependencies are installed
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/loader.py", line 346, in _load_file
    module = importlib.import_module(path)
  File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/homeassistant/.homeassistant/custom_components/onstar_component/__init__.py", line 8, in <module>
    from onstar import onstar
ModuleNotFoundError: No module named 'onstar'
2019-10-17 16:44:54 ERROR (MainThread) [homeassistant.setup] Setup failed for onstar_component: Integration not found.

configuration.yaml

onstar_component:
  username: !secret onstar_username
  password: !secret onstar_password
  pin:      !secret onstar_pin

secrets.yaml

onstar_username: my_onstar_email
onstar_password: my_onstar_password
onstar_pin: my_onstar_pin

custom_components>onstar_component:

__init__.py
device_tracker.py
sensor.py
services.yaml

Line 18 of init.py contains:
REQUIREMENTS = [‘onstar==0.1.2’]
? if so - maybe we need to add manifest.json?

That was my initial thought last night, but didn’t know what to add.

Checkout my repository - manifest was added. Let’s see

Will do.

Below is what I tried last night, but it didn’t work.

{
  "domain": "onstar",
  "name": "Onstar",
  "documentation": "https://github.com/nyxnyx/onstar_component",
  "dependencies": [],
  "codeowners": ["@nyxnyx"],
  "requirements": []
}

Error Log:

2019-10-17 17:14:02 ERROR (MainThread) [homeassistant.components.device_tracker] Error setting up platform legacy
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/device_tracker/setup.py", line 77, in async_setup_legacy
    discovery_info,
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/homeassistant/.homeassistant/custom_components/onstar_component/device_tracker.py", line 14, in setup_scanner
    tracker.setup(hass)
  File "/home/homeassistant/.homeassistant/custom_components/onstar_component/device_tracker.py", line 27, in setup
    self.update()
  File "/home/homeassistant/.homeassistant/custom_components/onstar_component/device_tracker.py", line 38, in update
    dev_id = slugify(self._data.status['onstar.plate'])
  File "/home/homeassistant/.homeassistant/custom_components/onstar_component/__init__.py", line 151, in status
    self.update()
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/util/__init__.py", line 240, in wrapper
    result = method(*args, **kwargs)
  File "/home/homeassistant/.homeassistant/custom_components/onstar_component/__init__.py", line 170, in update
    self._status = self._get_status()
  File "/home/homeassistant/.homeassistant/custom_components/onstar_component/__init__.py", line 113, in _get_status
    loop.run_until_complete(o.refresh())
  File "/usr/local/lib/python3.7/asyncio/base_events.py", line 584, in run_until_complete
    return future.result()
  File "/srv/homeassistant/lib/python3.7/site-packages/onstar/onstar.py", line 31, in refresh
    await self._login()
  File "/srv/homeassistant/lib/python3.7/site-packages/onstar/onstar.py", line 53, in _login
    self._token = data.results[0].token
AttributeError: 'X' object has no attribute 'results'
2019-10-17 17:14:06 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up platform onstar_component
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity_platform.py", line 150, in _async_setup_platform
    await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
  File "/usr/local/lib/python3.7/asyncio/tasks.py", line 416, in wait_for
    return fut.result()
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/homeassistant/.homeassistant/custom_components/onstar_component/sensor.py", line 19, in setup_platform
    if data.status is None:
  File "/home/homeassistant/.homeassistant/custom_components/onstar_component/__init__.py", line 151, in status
    self.update()
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/util/__init__.py", line 240, in wrapper
    result = method(*args, **kwargs)
  File "/home/homeassistant/.homeassistant/custom_components/onstar_component/__init__.py", line 170, in update
    self._status = self._get_status()
  File "/home/homeassistant/.homeassistant/custom_components/onstar_component/__init__.py", line 113, in _get_status
    loop.run_until_complete(o.refresh())
  File "/usr/local/lib/python3.7/asyncio/base_events.py", line 584, in run_until_complete
    return future.result()
  File "/srv/homeassistant/lib/python3.7/site-packages/onstar/onstar.py", line 31, in refresh
    await self._login()
  File "/srv/homeassistant/lib/python3.7/site-packages/onstar/onstar.py", line 53, in _login
    self._token = data.results[0].token
AttributeError: 'X' object has no attribute 'results'

that in 99% chance means that you have provided wrong user / password and / or pin
onstar=0.1.2 has bug where it is not properly handling errors.
One solution to be sure is to:

  1. Clone: https://github.com/nyxnyx/onstar
  2. enter into onstar directory
  3. execute: python3 onstar/demo.py
  4. provide user, password and pin
  5. see if it is getting results
    Use same data for HA
pi@hassbian:~/onstar $ python3 onstar/demo.py
Traceback (most recent call last):
  File "onstar/demo.py", line 1, in <module>
    import aiohttp
ImportError: No module named 'aiohttp'

ok - it’s in README:

pip3 install -r requirements.txt

I’m going to sleep now - so let me know what you achieved.

No dice, confirmed all credentials is correct in my onstar account.

pi@hassbian:~/onstar $ python3 onstar/demo.py
This demo will connect to: https://gsp.eur.onstar.com/

Before trying - ensure you have access by login in above site


Provide credentials

Username/email: *******************
Password:
PIN for localization:
Data from fetch - looking for token

X(error='401 Unauthorized', success=False)
Traceback (most recent call last):
  File "onstar/demo.py", line 85, in <module>
    loop.run_until_complete(main(loop))
  File "/usr/lib/python3.5/asyncio/base_events.py", line 466, in run_until_complete
    return future.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
    raise self._exception
  File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step
    result = coro.send(None)
  File "onstar/demo.py", line 59, in main
    token = data.results[0].token
AttributeError: 'X' object has no attribute 'results'
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x75f0b910>
Unclosed connector
connections: ['[(<aiohttp.client_proto.ResponseHandler object at 0x75f7a688>, 773590.910653948)]']
connector: <aiohttp.connector.TCPConnector object at 0x75f0b8b0>

Maybe you are not from Europe - maybe you are from different continent and need to use different service?

Yep, I’m in the US.

Yea I wanted to try this as well but I’m in the US also.

All I need is an address of endpoint plus make modifications to OnStar component. Can you please check that? When I login into OnStar.com then I press f12 and look at network tab. On page I go to locate my vehicle and input pin. Just before submitting pin, I clear network tab. Then press button to submit pin and on network tab I have few addresses. Please share those with me.

I’m not getting this part, once I login and go to any vehicle, I don not need to enter my pin

Sorry to have wasted your time, I don’t think this is going to work, I just realized that my onstar service is controlled via the vehicle manufacturers site.

FYI, the auto redirect url is "Owners | Experience GM

Localization:


Do you have it after login?