GithubHelp home page GithubHelp logo

g-two / subarulink Goto Github PK

View Code? Open in Web Editor NEW
83.0 83.0 14.0 868 KB

A python package for interacting with Subaru STARLINK remote vehicle services.

License: Apache License 2.0

Python 99.70% Makefile 0.30%
subaru

subarulink's People

Contributors

a4v2d4 avatar alandtse avatar dependabot[bot] avatar dfinlay avatar fabaff avatar g-two avatar johanjongsma avatar pre-commit-ci[bot] avatar stboch avatar ultratoto14 avatar wonderslug avatar zabuldon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

subarulink's Issues

Install Help

I am wanting to help validate this but am struggling with how to get this installed into Home Assistant. I created a custom_components folder in config and then dropped in the "subaru" folder from components directory. Is there a place you could direct me to? My internet searches aren't turning up much unfortunately.

Convert string values to int or float

Additional processing is required by users of the module to use numerical values presented as strings. This module should convert the text strings to numerical types.

Example from HomeAssistant:

    def get_current_value(self):
        """Get raw value from the coordinator."""
        if isinstance(data := self.coordinator.data, dict):
            value = data.get(self.vin)[VEHICLE_STATUS].get(self.entity_description.key)
            if value in sc.BAD_SENSOR_VALUES:
                value = None
            if isinstance(value, str):
                if "." in value:
                    value = float(value)
                elif value.isdigit():
                    value = int(value)
            _LOGGER.debug("Raw value for %s: %s", self._attr_name, value)
            return value

Ideally, this code should be simplified to without any adverse behavior:

    def get_current_value(self):
        """Get raw value from the coordinator."""
        if isinstance(data := self.coordinator.data, dict):
            value = data.get(self.vin)[VEHICLE_STATUS].get(self.entity_description.key)
            _LOGGER.debug("Raw value for %s: %s", self._attr_name, value)
            return value

Question: remote start configuration

I got the HA restful switch working for the locks. I'm happy to document that somehow if others would find it useful. But your HA integration seems like it is close and will accomplish the same thing and not be so hacky.

I'm moving on to remote_start and I have what I think is a basic question.

When I do subarulink remote_start it tells me ERROR - Remote start settings not found in config file. Configure settings interactively first

When I go into interactive mode, then do start it says hvac <set|start|stop> and gives me a new prompt. I can't figure out what to put in that new prompt line.

I probably just don't know this notation. Help appreciated, thank you!

Support vehicle status for Safety Plus subscriptions

When I run the command it displays my vehicle's VIN under available vehicles but then says it is unable to connect.

$ subarulink -i

Available Vehicles:
[1] ############### (##################)
2020-07-19 20:37:48,346 - subarulink - ERROR - Unable to connect. Check Username/Password.

Update to g2v25

This package currently uses g2v24 and the official app now uses g2v25 (as of Jan 20 2023).

Based on Android MySubaru 2.7.39 www/app/pages/initPage.js:10

var defaultApi = "/g2v25";

Need to determine content changes (if any) and update this package before Subaru turns off g2v24 endpoints.

Issues after update

HA component version 0.2.0
subarulink version 0.3.10
Issues after updates

Unexpected error fetching subaru_data data: cannot unpack non-iterable NoneType object
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 144, in async_refresh
    self.data = await self._async_update_data()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 132, in _async_update_data
    return await self.update_method()
  File "/config/custom_components/subaru/__init__.py", line 121, in async_update_data
    return await subaru_update(vehicle_info, controller)
  File "/config/custom_components/subaru/__init__.py", line 268, in subaru_update
    await refresh_subaru_data(vehicle, controller)
  File "/config/custom_components/subaru/__init__.py", line 292, in refresh_subaru_data
    update_result = await controller.update(vehicle[VEHICLE_VIN], force=True)
  File "/usr/local/lib/python3.8/site-packages/subarulink/controller.py", line 371, in update
    result = await self._locate(vin, hard_poll=True)
  File "/usr/local/lib/python3.8/site-packages/subarulink/controller.py", line 895, in _locate
    success, js_resp = await self._remote_command(vin, url, poll_url=poll_url)
TypeError: cannot unpack non-iterable NoneType object

2020-12-22 15:44:20 ERROR (MainThread) [homeassistant.components.binary_sensor] Error while setting up subaru platform for binary_sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 199, in _async_setup_platform
await asyncio.shield(task)
File "/config/custom_components/subaru/binary_sensor.py", line 128, in async_setup_entry
_create_sensor_entities(entities, vehicle_info[vin], coordinator, hass)
File "/config/custom_components/subaru/binary_sensor.py", line 142, in _create_sensor_entities
if coordinator.data[vehicle_info[VEHICLE_VIN]]["status"].get(subaru_sensor[SENSOR_FIELD]) not in sc.BAD_BINARY_SENSOR_VALUES:
TypeError: 'NoneType' object is not subscriptable

2024 Outback - KeyError: 'FRONT_TIRE' with version v0.7.9

Hello, I have a brand new Outback where 'summary' fails to complete successfully. I'm using v0.7.9 of subarulink

2024-01-03 11:23:07,853 - subarulink.controller - DEBUG - {'data': '[{"name":"Winter","runTimeMinutes":"10","climateZoneFrontTempCelsius":"22","climateZoneFrontAirMode":"WINDOW","climateZoneFrontAirVolume":"5","outerAirCirculation":"outsideAir","heatedRearWindowActive":"true","heatedSeatFrontLeft":"MEDIUM_HEAT","heatedSeatFrontRight":"OFF","airConditionOn":"false","canEdit":"true","disabled":"false","presetType":"userPreset","startConfiguration":"START_ENGINE_ALLOW_KEY_IN_IGNITION"}]',
 'dataName': None,
 'errorCode': None,
 'success': True}
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\wylde\AppData\Local\Programs\Python\Python311\Scripts\subarulink.exe\__main__.py", line 7, in <module>
  File "C:\Users\wylde\AppData\Local\Programs\Python\Python311\Lib\site-packages\subarulink\app\cli.py", line 715, in main
    LOOP.run_until_complete(cli.single_command(args.command, args.vin, cli.config))
  File "C:\Users\wylde\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "C:\Users\wylde\AppData\Local\Programs\Python\Python311\Lib\site-packages\subarulink\app\cli.py", line 538, in single_command
    print("\n".join(self._summary_data()), "\n")
                    ^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\wylde\AppData\Local\Programs\Python\Python311\Lib\site-packages\subarulink\app\cli.py", line 334, in _summary_data
    self.car_data[sc.VEHICLE_HEALTH][sc.HEALTH_RECOMMENDED_TIRE_PRESSURE][
KeyError: 'FRONT_TIRES'
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x000001B93F637650>
Unclosed connector
connections: ['[(<aiohttp.client_proto.ResponseHandler object at 0x000001B93F5C1A90>, 982289.343)]']
connector: <aiohttp.connector.TCPConnector object at 0x000001B93F637690>

update service results in invalid token

I can start the car using the start service, vin and climate preset, however I rely on the update service to monitor when the car is turned off by polling every minute.

I get this response when calling update:

Failed to call service subaru.update. Service update failed for 2019 Ascent Limited: Unhandled API error: InvalidToken - {'success': False, 'errorCode': 'InvalidToken', 'dataName': 'errorResponse', 'data': {'errorLabel': 'InvalidToken', 'errorDescription': 'E003'}}

Anything change? Some entities missing and no services

Hi hi, I've been happily using the Home Assistant integration for a while. I recently upgraded to 2021.06 HA and then noticed today that I had a whole bunch of duplicate Subaru entities in HA. I uninstalled the integration and reinstalled it. Now I'm down to 9 entities, and don't have one for location of the car or the ignition status or door lock. There also don't appear to be the door lock service available which I am heavily reliant on.

Wondering if anything has changed recently?

Unexpanded String In status Returned JSON

I'm getting the name of the underlying asyncio object inline in the JSON returned by subarulink status , rather than the string value of the lock state:

 'last_update_time': 0,
 'lock': <asyncio.locks.Lock object at 0x7f5a1d63df40 [unlocked]>,
 'modelName': 'Crosstrek',
 'modelYear': '2022',

I did pull a location shortly before this if that's informative.

Thanks again for the quick response on issue #53.

Error when session cookie expires and API request is invoked under new session.

This may only affect accounts with multiple vehicles. Error persists even when supplying selectedVin to login.json. Must fix prior to publishing new release. Likely solution is just to call selectVehicle.json when validateSession.json fails (indicating the session cookie has expired) after login.json succeeds. It might also be helpful to add a debug print to indicate the result of validateSession.json.

Debug log:

subarulink.controller - DEBUG - Fetching vehicle status from Subaru
subarulink.connection - DEBUG - GET: https://mobileapi.prod.subarucs.com/g2v15/validateSession.json
subarulink.connection - DEBUG - POST: https://mobileapi.prod.subarucs.com/g2v15/login.json
subarulink.connection - DEBUG - Client authentication successful
subarulink.connection - DEBUG - GET: https://mobileapi.prod.subarucs.com/g2v15/service/g2/condition/execute.json
subarulink.connection - DEBUG - {'errorCode': 'error',
 'errorMessage': 'java.lang.NullPointerException - null',
 'httpCode': 500}

VS_DIST_TO_EMPTY and VS_VEHICLE_STATE are not always available in the response

This happened in my case. Here's the raw response I got:

{'data': {'avgFuelConsumptionLitersPer100Kilometers': None,
          'avgFuelConsumptionMpg': None,
          'distanceToEmptyFuelKilometers': None,
          'distanceToEmptyFuelKilometers10s': None,
          'distanceToEmptyFuelMiles': None,
          'distanceToEmptyFuelMiles10s': None,
          'evDistanceToEmptyByStateKilometers': None,
          'evDistanceToEmptyByStateMiles': None,
          'evDistanceToEmptyKilometers': None,
          'evDistanceToEmptyMiles': None,
          'evStateOfChargePercent': None,
          'eventDate': 1664270191000,
          'eventDateStr': '2022-09-27T09:16+0000',
          'latitude': None,
          'longitude': None,
          'odometerValue': REDACTED,
          'odometerValueKilometers': REDACTED,
          'positionHeadingDegree': None,
          'tirePressureFrontLeft': None,
          'tirePressureFrontLeftPsi': None,
          'tirePressureFrontRight': None,
          'tirePressureFrontRightPsi': None,
          'tirePressureRearLeft': None,
          'tirePressureRearLeftPsi': None,
          'tirePressureRearRight': None,
          'tirePressureRearRightPsi': None,
          'tyreStatusFrontLeft': None,
          'tyreStatusFrontRight': None,
          'tyreStatusRearLeft': None,
          'tyreStatusRearRight': None,
          'vehicleStateType': None,
          'vhsId': REDACTED,
          'windowFrontLeftStatus': None,
          'windowFrontRightStatus': None,
          'windowRearLeftStatus': None,
          'windowRearRightStatus': None,
          'windowSunroofStatus': None},
 'dataName': None,
 'errorCode': None,
 'success': True}

Such response will cause subarulink/controller.py:944 to throw an exception.

remote start with CLI argument

Small thing: when I run subarulink -v 2 remote_start I get the following error. It doesn't seem to accept remote_start on as it does in interactive mode

Traceback (most recent call last):
File "/Users/local_user/Development/subaru/venv/bin/subarulink", line 10, in
sys.exit(main())
File "/Users/local_user/Development/subaru/venv/lib/python3.7/site-packages/subarulink/app/cli.py", line 567, in main
LOOP.run_until_complete(cli.single_command(args.command, args.vin))
File "/Users/local_user/.pyenv/versions/3.7.3/lib/python3.7/asyncio/base_events.py", line 584, in run_until_complete
return future.result()
File "/Users/local_user/Development/subaru/venv/lib/python3.7/site-packages/subarulink/app/cli.py", line 459, in single_command
self._config["hvac"]["rear_ac"],
TypeError: remote_start() takes 3 positional arguments but 10 were given
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x10d03d160>
Unclosed connector
connections: ['[(<aiohttp.client_proto.ResponseHandler object at 0x10cffbc10>, 1.597272416)]']
connector: <aiohttp.connector.TCPConnector object at 0x10d03d208>

Multiple vehicles in account but VIN not specified in config

Hey!

I'm getting:

2022-03-24 08:29:45,439 - subarulink - ERROR - Multiple vehicles in account but VIN not specified in config or command line

however:

-> % cat ~/.subarulink.cfg
{
    "country": "USA",
    "username": "[email protected]",
    "password": "53cr3tp455w0rd",
    "pin": "1234",
    "device_name": "subarulink",
    "save_creds": "Y",
    "device_id": 1628400000,
    "default_vin": "JF2XXXXX1XX123456",
    "remote_start_preset": "FULL HEAT"
}

Obviously I've masked out sensitive values, but that is otherwise my config. I'm no sure how to specify key/value on the command line as it's not mentioned in --help. My checkout is current:

-> % git pull
Already up to date.

-> % git log | head -n1
commit e60d054cb9b68cd6898fa4b7a53cae108188992f

-> % python --version
Python 3.9.5

I also really only have one car in my account
Screen Shot 2022-03-24 at 8 35 52 AM

THANK YOU!
M.

Handle API session expiring after 24 hours

I get one of these every day with 0.3.3 and 0.3.4rc0. It is handled gracefully by HA, so seems to be a minor issue. Need to determine the type of exception and find out why the message isn't passing from subarulink to the subaru integration.

2020-07-29 02:03:35 ERROR (MainThread) [homeassistant.components.subaru] Error fetching subaru_data data: Error communicating with API: 

Remove hass subpackage

Development of the Subaru integration on Home Assistant is cumbersome with some of the implementation partially in the subarulink package. The current architecture has subarulink.hass classes that are inherited by homeassistant.components.subaru classes with no added value. Modifications to the sensor classes during the HomeAssistant PR required changing code in both subarulink and homeassistant. This resulted in the need to update the PyPI package version, even though there was no change to the core package.

Proposal
Move all the homeassistant related code out of this package, and use existing homeassistant helpers, constants, and frameworks to streamline code.

Error on door unlock

On v0.6.0rc2, I get this error when unlocking the doors. Locking works fine. This is directly from the subaru lock entity.

Service unlock failed for insert_VIN_here: Invalid door 'all' specified for unlock command.

Screen Shot 2021-12-30 at 9 40 38 AM

Gen 3 telematics debug log

$ subarulink -v2 -i
2023-02-23 19:24:52,487 - subarulink - INFO - Entering interactive mode
2023-02-23 19:24:52,487 - subarulink - INFO - Opening config file: XXXXX
2023-02-23 19:24:52,488 - subarulink - INFO - Connecting to Subaru Remote Services API
2023-02-23 19:24:52,488 - subarulink.controller - DEBUG - subarulink 0.7.5
2023-02-23 19:24:52,488 - subarulink.controller - DEBUG - Connecting controller to Subaru Remote Services
2023-02-23 19:24:52,488 - subarulink.connection - DEBUG - POST: https://mobileapi.prod.subarucs.com/g2v25/login.json, params=None, json_data=None
2023-02-23 19:24:53,059 - subarulink.connection - DEBUG - Client authentication successful
2023-02-23 19:24:53,064 - subarulink.connection - DEBUG - {'data': {'account': {'accountKey': xxxxxxx,
'createdDate': XXXXX,
'firstName': 'XXXXX',
'lastLoginDate': XXXXXX,
'lastName': 'XXXXX',
'marketId': X,
'zipCode': 'XXXXX',
'zipCode5': 'XXXXX'},
'currentVehicleIndex': 0,
'deviceId': 'XXXXXX',
'deviceRegistered': True,
'digitalGlobeConnectId': 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
'digitalGlobeImageTileService': 'https://earthwatch.digitalglobe.com/earthservice/tmsaccess/tms/1.0.0/DigitalGlobe:ImageryTileService@EPSG:3857@png/{z}/{x}/{y}.png?connectId=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
'digitalGlobeTransparentTileService': 'https://earthwatch.digitalglobe.com/earthservice/tmsaccess/tms/1.0.0/Digitalglobe:OSMTransparentTMSTileService@EPSG:3857@png/{z}/{x}/{-y}.png/?connectId=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,
'enableXtime': True,
'handoffToken': 'XXXXXXXXXXXXX',
'passwordToken': XXXX,
'registeredDevicePermanent': True,
'resetPassword': False,
'rightToRepairEnabled': True,
'rightToRepairStartYear': 2022,
'rightToRepairStates': 'MA',
'satelliteViewEnabled': True,
'sessionChanged': False,
'sessionId': 'XXXXXXXXXX',
'termsAndConditionsAccepted': True,
'tomtomKey': 'XXXXXXXXXXXXX',
'vehicleInactivated': False,
'vehicles': [{'accessLevel': -1,
'active': True,
'authorizedVehicle': False,
'cachedStateCode': 'XX',
'crmRightToRepair': False,
'customer': {'email': None,
'firstName': None,
'lastName': None,
'oemCustId': None,
'phone': None,
'sessionCustomer': None,
'zip': None},
'email': None,
'engineSize': None,
'extDescrip': None,
'features': None,
'firstName': None,
'intDescrip': None,
'lastName': None,
'licensePlate': '',
'licensePlateState': '',
'modelCode': None,
'modelName': None,
'modelYear': None,
'needEmergencyContactPrompt': False,
'needMileagePrompt': False,
'nickname': '2023 Outback Wilderness',
'oemCustId': 'XXXXXXXXXXXXX',
'phev': None,
'phone': None,
'preferredDealer': None,
'provisioned': True,
'remoteServicePinExist': True,
'show3gSunsetBanner': False,
'stolenVehicle': False,
'subscriptionFeatures': None,
'subscriptionPlans': [],
'subscriptionStatus': None,
'sunsetUpgraded': True,
'timeZone': 'XXXXXXXXXXXXXXXXX',
'transCode': None,
'userOemCustId': 'XXXXXXXXX',
'vehicleGeoPosition': None,
'vehicleKey': XXXXXXX,
'vehicleMileage': None,
'vehicleName': '2023 Outback Wilderness',
'vin': 'XXXXXXXXXXXXXXXX',
'zip': None}]},
'dataName': 'sessionData',
'errorCode': 'BIOMETRICS_DISABLED',
'success': True}
2023-02-23 19:24:53,065 - subarulink.connection - DEBUG - GET: https://mobileapi.prod.subarucs.com/g2v25/selectVehicle.json, params={'vin': 'XXXXXXXXXXXXXXXX', '_': XXXXXXXXXXXX}, json_data=None
2023-02-23 19:24:53,363 - subarulink.connection - DEBUG - {'data': {'accessLevel': -1,
'active': True,
'authorizedVehicle': False,
'cachedStateCode': 'XX',
'crmRightToRepair': False,
'customer': {'email': None,
'firstName': None,
'lastName': None,
'oemCustId': None,
'phone': None,
'sessionCustomer': None,
'zip': None},
'email': None,
'engineSize': 2.4,
'extDescrip': 'Ice Silver Metallic',
'features': ['ABS_MIL',
'ACCS',
'AHBL_MIL',
'ATF_MIL',
'AWD_MIL',
'BSD',
'BSDRCT_MIL',
'CEL_MIL',
'EBD_MIL',
'EOL_MIL',
'EPAS_MIL',
'EPB_MIL',
'ESS_MIL',
'EYESIGHT',
'ISS_MIL',
'OPL_MIL',
'PANPM-TUIRWAOC',
'PWAAADWWAP',
'RAB_MIL',
'RCC',
'REARBRK',
'RES',
'RESCC',
'RHSF',
'RPOI',
'RPOIA',
'RTGU',
'SRH_MIL',
'SRS_MIL',
'TEL_MIL',
'TIF_35',
'TIR_33',
'TLD',
'TPMS_MIL',
'VALET',
'VDC_MIL',
'WASH_MIL',
'g3'],
'firstName': None,
'intDescrip': 'Gray',
'lastName': None,
'licensePlate': '',
'licensePlateState': '',
'modelCode': 'PDI',
'modelName': 'Outback',
'modelYear': '2023',
'needEmergencyContactPrompt': False,
'needMileagePrompt': False,
'nickname': '2023 Outback Wilderness',
'oemCustId': 'XXXXXXXXXXX',
'phev': None,
'phone': None,
'preferredDealer': None,
'provisioned': True,
'remoteServicePinExist': True,
'show3gSunsetBanner': False,
'stolenVehicle': False,
'subscriptionFeatures': ['SAFETY', 'Financed3', 'REMOTE'],
'subscriptionPlans': [],
'subscriptionStatus': 'ACTIVE',
'sunsetUpgraded': True,
'timeZone': 'XXXXXXXXX',
'transCode': 'CVT',
'userOemCustId': 'XXXXXXXXXXXX',
'vehicleGeoPosition': {'heading': None,
'latitude': 90.0,
'longitude': 180.0,
'speed': None,
'timestamp': '2023-02-24T02:50:26'},
'vehicleKey': XXXXXXX,
'vehicleMileage': None,
'vehicleName': '2023 Outback Wilderness',
'vin': 'XXXXXXXXXXXXXXX',
'zip': None},
'dataName': 'vehicle',
'errorCode': None,
'success': True}
2023-02-23 19:24:53,363 - subarulink.controller - DEBUG - Parsing vehicle: vinxxxxxxxxxxxxxxxx
2023-02-23 19:24:53,363 - subarulink.controller - DEBUG - Parsed recommended tire pressure for vinxxxxxxxxxxxxxxxx: {'FRONT_TIRES': 35, 'REAR_TIRES': 33}
2023-02-23 19:24:53,364 - subarulink.controller - DEBUG - Subaru Remote Services Ready
2023-02-23 19:24:53,364 - subarulink - INFO - Successfully connected
2023-02-23 19:24:53,364 - subarulink - INFO - Fetching data for 2023 Outback Wilderness...
2023-02-23 19:24:53,364 - subarulink.controller - DEBUG - Fetching vehicle status from Subaru
2023-02-23 19:24:53,364 - subarulink.connection - DEBUG - GET: https://mobileapi.prod.subarucs.com/g2v25/validateSession.json, params=None, json_data=None
2023-02-23 19:24:53,551 - subarulink.connection - DEBUG - {'data': None, 'dataName': None, 'errorCode': None, 'success': True}
2023-02-23 19:24:53,551 - subarulink.connection - DEBUG - GET: https://mobileapi.prod.subarucs.com/g2v25/vehicleStatus.json, params=None, json_data=None
2023-02-23 19:24:53,740 - subarulink.controller - DEBUG - {'data': {'avgFuelConsumptionLitersPer100Kilometers': 7.7,
'avgFuelConsumptionMpg': 30.5,
'distanceToEmptyFuelKilometers': 370,
'distanceToEmptyFuelKilometers10s': 370,
'distanceToEmptyFuelMiles': 229.91,
'distanceToEmptyFuelMiles10s': 230,
'evDistanceToEmptyByStateKilometers': None,
'evDistanceToEmptyByStateMiles': None,
'evDistanceToEmptyKilometers': None,
'evDistanceToEmptyMiles': None,
'evStateOfChargePercent': None,
'eventDate': xxxxxxxxxxx,
'eventDateStr': '2023-02-24T02:50+0000',
'latitude': 90.0,
'longitude': 180.0,
'odometerValue': 144,
'odometerValueKilometers': 233,
'positionHeadingDegree': None,
'remainingFuelPercent': 63,
'tirePressureFrontLeft': '2551',
'tirePressureFrontLeftPsi': '37',
'tirePressureFrontRight': '2551',
'tirePressureFrontRightPsi': '37',
'tirePressureRearLeft': '2413',
'tirePressureRearLeftPsi': '35',
'tirePressureRearRight': '2482',
'tirePressureRearRightPsi': '36',
'tyreStatusFrontLeft': 'UNKNOWN',
'tyreStatusFrontRight': 'UNKNOWN',
'tyreStatusRearLeft': 'UNKNOWN',
'tyreStatusRearRight': 'UNKNOWN',
'vehicleStateType': 'IGNITION_OFF',
'vhsId':xxxxxxxxxx,
'windowFrontLeftStatus': 'CLOSE',
'windowFrontRightStatus': 'CLOSE',
'windowRearLeftStatus': 'CLOSE',
'windowRearRightStatus': 'CLOSE',
'windowSunroofStatus': 'CLOSE'},
'dataName': None,
'errorCode': None,
'success': True}
2023-02-23 19:24:53,746 - subarulink.controller - DEBUG - Getting subscription Status vinxxxxxxxxxxxxxxxx:True
2023-02-23 19:24:53,746 - subarulink.controller - DEBUG - Getting remote Status vinxxxxxxxxxxxxxxxx:True
2023-02-23 19:24:53,746 - subarulink.controller - DEBUG - Getting vehicle API gen vinxxxxxxxxxxxxxxxx:g3
2023-02-23 19:24:53,747 - subarulink.connection - DEBUG - GET: https://mobileapi.prod.subarucs.com/g2v25/validateSession.json, params=None, json_data=None
2023-02-23 19:24:53,821 - subarulink.connection - DEBUG - {'data': None, 'dataName': None, 'errorCode': None, 'success': True}
2023-02-23 19:24:53,822 - subarulink.controller - DEBUG - Getting vehicle API gen vinxxxxxxxxxxxxxxxx:g3
2023-02-23 19:24:53,822 - subarulink.connection - DEBUG - GET: https://mobileapi.prod.subarucs.com/g2v25/service/g2/condition/execute.json, params=None, json_data=None
2023-02-23 19:24:54,193 - subarulink.controller - DEBUG - {'data': {'cancelled': False,
'errorCode': None,
'errorDescription': None,
'remoteServiceState': 'finished',
'remoteServiceType': 'condition',
'result': {'avgFuelConsumption': None,
'avgFuelConsumptionUnit': 'MPG',
'distanceToEmptyFuel': None,
'distanceToEmptyFuelUnit': 'MILES',
'doorBootPosition': 'CLOSED',
'doorEngineHoodPosition': 'CLOSED',
'doorFrontLeftPosition': 'CLOSED',
'doorFrontRightPosition': 'CLOSED',
'doorRearLeftPosition': 'CLOSED',
'doorRearRightPosition': 'CLOSED',
'evChargerStateType': None,
'evDistanceToEmpty': None,
'evDistanceToEmptyUnit': None,
'evIsPluggedIn': None,
'evStateOfChargeMode': None,
'evStateOfChargePercent': None,
'evTimeToFullyCharged': None,
'lastUpdatedTime': '2023-02-24T03:26:35+0000',
'odometer': 144,
'odometerUnit': 'MILES',
'remainingFuelPercent': None,
'tirePressureFrontLeft': None,
'tirePressureFrontLeftUnit': 'PSI',
'tirePressureFrontRight': None,
'tirePressureFrontRightUnit': 'PSI',
'tirePressureRearLeft': None,
'tirePressureRearLeftUnit': 'PSI',
'tirePressureRearRight': None,
'tirePressureRearRightUnit': 'PSI',
'vehicleStateType': 'IGNITION_OFF',
'windowFrontLeftStatus': 'CLOSE',
'windowFrontRightStatus': 'CLOSE',
'windowRearLeftStatus': 'CLOSE',
'windowRearRightStatus': 'CLOSE',
'windowSunroofStatus': 'CLOSE'},
'serviceRequestId': None,
'subState': None,
'success': True,
'updateTime': None,
'vin': 'vinxxxxxxxxxxxxxxxx'},
'dataName': 'remoteServiceStatus',
'errorCode': None,
'success': True}
2023-02-23 19:24:54,196 - subarulink.controller - DEBUG - Getting subscription Status vinxxxxxxxxxxxxxxxx:True
2023-02-23 19:24:54,196 - subarulink.controller - DEBUG - Getting remote Status vinxxxxxxxxxxxxxxxx:True
2023-02-23 19:24:54,196 - subarulink.controller - DEBUG - Getting power window status vinxxxxxxxxxxxxxxxx:True
2023-02-23 19:24:54,196 - subarulink.controller - DEBUG - Getting subscription Status vinxxxxxxxxxxxxxxxx:True
2023-02-23 19:24:54,197 - subarulink.controller - DEBUG - Getting remote Status vinxxxxxxxxxxxxxxxx:True
2023-02-23 19:24:54,197 - subarulink.controller - DEBUG - Getting power window status vinxxxxxxxxxxxxxxxx:True
2023-02-23 19:24:54,197 - subarulink.controller - DEBUG - Getting moonroof status vinxxxxxxxxxxxxxxxx:True
2023-02-23 19:24:54,197 - subarulink.controller - DEBUG - Getting EV Status vinxxxxxxxxxxxxxxxx:False
2023-02-23 19:24:54,197 - subarulink.connection - DEBUG - GET: https://mobileapi.prod.subarucs.com/g2v25/validateSession.json, params=None, json_data=None
2023-02-23 19:24:54,281 - subarulink.connection - DEBUG - {'data': None, 'dataName': None, 'errorCode': None, 'success': True}
2023-02-23 19:24:54,281 - subarulink.controller - DEBUG - Getting vehicle API gen vinxxxxxxxxxxxxxxxx:g3
2023-02-23 19:24:54,281 - subarulink.connection - DEBUG - GET: https://mobileapi.prod.subarucs.com/g2v25/service/g2/locate/execute.json, params=None, json_data=None
2023-02-23 19:24:54,701 - subarulink.controller - DEBUG - {'data': {'cancelled': False,
'errorCode': None,
'errorDescription': None,
'remoteServiceState': 'finished',
'remoteServiceType': 'locate',
'result': {'heading': None,
'latitude': xxxreal latxxx,
'locationTimestamp': 1677209194000,
'longitude': xxxreal longxxxx,
'speed': None},
'serviceRequestId': None,
'subState': None,
'success': True,
'updateTime': None,
'vin': 'vinxxxxxxxxxxxxxxxx'},
'dataName': 'remoteServiceStatus',
'errorCode': None,
'success': True}
2023-02-23 19:24:54,702 - subarulink.connection - DEBUG - GET: https://mobileapi.prod.subarucs.com/g2v25/validateSession.json, params=None, json_data=None
2023-02-23 19:24:54,887 - subarulink.connection - DEBUG - {'data': None, 'dataName': None, 'errorCode': None, 'success': True}
2023-02-23 19:24:54,888 - subarulink.controller - DEBUG - Getting vehicle API gen vinxxxxxxxxxxxxxxxx:g3
2023-02-23 19:24:54,888 - subarulink.connection - DEBUG - GET: https://mobileapi.prod.subarucs.com/g2v25/vehicleHealth.json, params=None, json_data=None
2023-02-23 19:24:55,045 - subarulink.controller - DEBUG - {'data': {'lastUpdatedDate': 1677207026000,
'vehicleHealthItems': [{'b2cCode': 'airbag',
'featureCode': 'SRS_MIL',
'isTrouble': False,
'onDaiId': 0,
'onDates': [],
'warningCode': 10},
{'b2cCode': 'oilTemp',
'featureCode': 'ATF_MIL',
'isTrouble': False,
'onDaiId': 0,
'onDates': [],
'warningCode': 4},
{'b2cCode': 'blindspot',
'featureCode': 'BSDRCT_MIL',
'isTrouble': False,
'onDaiId': 0,
'onDates': [],
'warningCode': 39},
{'b2cCode': 'engineFail',
'featureCode': 'CEL_MIL',
'isTrouble': False,
'onDaiId': 0,
'onDates': [],
'warningCode': 2},
{'b2cCode': 'pkgBrake',
'featureCode': 'EPB_MIL',
'isTrouble': False,
'onDaiId': 0,
'onDates': [],
'warningCode': 44},
{'b2cCode': 'ebd',
'featureCode': 'EBD_MIL',
'isTrouble': False,
'onDaiId': 0,
'onDates': [],
'warningCode': 8},
{'b2cCode': 'oilWarning',
'featureCode': 'EOL_MIL',
'isTrouble': False,
'onDaiId': 0,
'onDates': [],
'warningCode': 3},
{'b2cCode': 'washer',
'featureCode': 'WASH_MIL',
'isTrouble': False,
'onDaiId': 0,
'onDates': [],
'warningCode': 1},
{'b2cCode': 'iss',
'featureCode': 'ISS_MIL',
'isTrouble': False,
'onDaiId': 0,
'onDates': [],
'warningCode': 50},
{'b2cCode': 'oilPres',
'featureCode': 'OPL_MIL',
'isTrouble': False,
'onDaiId': 0,
'onDates': [],
'warningCode': 53},
{'b2cCode': 'epas',
'featureCode': 'EPAS_MIL',
'isTrouble': False,
'onDaiId': 0,
'onDates': [],
'warningCode': 11},
{'b2cCode': 'revBrake',
'featureCode': 'RAB_MIL',
'isTrouble': False,
'onDaiId': 0,
'onDates': [],
'warningCode': 69},
{'b2cCode': 'telematics',
'featureCode': 'TEL_MIL',
'isTrouble': False,
'onDaiId': 0,
'onDates': [],
'warningCode': 14},
{'b2cCode': 'tpms',
'featureCode': 'TPMS_MIL',
'isTrouble': False,
'onDaiId': 0,
'onDates': [],
'warningCode': 9},
{'b2cCode': 'vdc',
'featureCode': 'VDC_MIL',
'isTrouble': False,
'onDaiId': 0,
'onDates': [],
'warningCode': 7},
{'b2cCode': 'abs',
'featureCode': 'ABS_MIL',
'isTrouble': False,
'onDaiId': 0,
'onDates': [],
'warningCode': 6},
{'b2cCode': 'awd',
'featureCode': 'AWD_MIL',
'isTrouble': False,
'onDaiId': 0,
'onDates': [],
'warningCode': 5},
{'b2cCode': 'eyesight',
'featureCode': 'ESS_MIL',
'isTrouble': False,
'onDaiId': 0,
'onDates': [],
'warningCode': 12},
{'b2cCode': 'ahbl',
'featureCode': 'AHBL_MIL',
'isTrouble': False,
'onDaiId': 0,
'onDates': [],
'warningCode': 30},
{'b2cCode': 'srh',
'featureCode': 'SRH_MIL',
'isTrouble': False,
'onDaiId': 0,
'onDates': [],
'warningCode': 31}]},
'dataName': None,
'errorCode': None,
'success': True}
2023-02-23 19:24:55,045 - subarulink.controller - DEBUG - Collecting MIL Feature SRS_MIL
2023-02-23 19:24:55,045 - subarulink.controller - DEBUG - Collecting MIL Feature ATF_MIL
2023-02-23 19:24:55,046 - subarulink.controller - DEBUG - Collecting MIL Feature BSDRCT_MIL
2023-02-23 19:24:55,046 - subarulink.controller - DEBUG - Collecting MIL Feature CEL_MIL
2023-02-23 19:24:55,046 - subarulink.controller - DEBUG - Collecting MIL Feature EPB_MIL
2023-02-23 19:24:55,046 - subarulink.controller - DEBUG - Collecting MIL Feature EBD_MIL
2023-02-23 19:24:55,046 - subarulink.controller - DEBUG - Collecting MIL Feature EOL_MIL
2023-02-23 19:24:55,046 - subarulink.controller - DEBUG - Collecting MIL Feature WASH_MIL
2023-02-23 19:24:55,046 - subarulink.controller - DEBUG - Collecting MIL Feature ISS_MIL
2023-02-23 19:24:55,046 - subarulink.controller - DEBUG - Collecting MIL Feature OPL_MIL
2023-02-23 19:24:55,047 - subarulink.controller - DEBUG - Collecting MIL Feature EPAS_MIL
2023-02-23 19:24:55,047 - subarulink.controller - DEBUG - Collecting MIL Feature RAB_MIL
2023-02-23 19:24:55,047 - subarulink.controller - DEBUG - Collecting MIL Feature TEL_MIL
2023-02-23 19:24:55,047 - subarulink.controller - DEBUG - Collecting MIL Feature TPMS_MIL
2023-02-23 19:24:55,047 - subarulink.controller - DEBUG - Collecting MIL Feature VDC_MIL
2023-02-23 19:24:55,047 - subarulink.controller - DEBUG - Collecting MIL Feature ABS_MIL
2023-02-23 19:24:55,047 - subarulink.controller - DEBUG - Collecting MIL Feature AWD_MIL
2023-02-23 19:24:55,047 - subarulink.controller - DEBUG - Collecting MIL Feature ESS_MIL
2023-02-23 19:24:55,047 - subarulink.controller - DEBUG - Collecting MIL Feature AHBL_MIL
2023-02-23 19:24:55,048 - subarulink.controller - DEBUG - Collecting MIL Feature SRH_MIL
2023-02-23 19:24:55,048 - subarulink.controller - DEBUG - Getting subscription Status vinxxxxxxxxxxxxxxxx:True
2023-02-23 19:24:55,048 - subarulink.controller - DEBUG - Getting remote Status vinxxxxxxxxxxxxxxxx:True
2023-02-23 19:24:55,048 - subarulink.controller - DEBUG - Getting RES Status vinxxxxxxxxxxxxxxxx:True
2023-02-23 19:24:55,048 - subarulink.controller - DEBUG - Getting subscription Status vinxxxxxxxxxxxxxxxx:True
2023-02-23 19:24:55,048 - subarulink.controller - DEBUG - Getting remote Status vinxxxxxxxxxxxxxxxx:True
2023-02-23 19:24:55,048 - subarulink.controller - DEBUG - Getting RES Status vinxxxxxxxxxxxxxxxx:True
2023-02-23 19:24:55,049 - subarulink.connection - DEBUG - GET: https://mobileapi.prod.subarucs.com/g2v25/service/g2/climatePresetSettings/fetch.json, params=None, json_data=None
2023-02-23 19:24:55,194 - subarulink.controller - DEBUG - {'data': ['{"name": "Auto", "runTimeMinutes": "10", "climateZoneFrontTemp": '
'"74", "climateZoneFrontAirMode": "AUTO", '
'"climateZoneFrontAirVolume": "AUTO", "outerAirCirculation": "auto", '
'"heatedRearWindowActive": "false", "airConditionOn": "false", '
'"heatedSeatFrontLeft": "off", "heatedSeatFrontRight": "off", '
'"startConfiguration": "START_ENGINE_ALLOW_KEY_IN_IGNITION", '
'"canEdit": "true", "disabled": "false", "vehicleType": "gas", '
'"presetType": "subaruPreset" }',
'{"name":"Full '
'Cool","runTimeMinutes":"10","climateZoneFrontTemp":"60","climateZoneFrontAirMode":"feet_face_balanced","climateZoneFrontAirVolume":"7","airConditionOn":"true","heatedSeatFrontLeft":"high_cool","heatedSeatFrontRight":"high_cool","heatedRearWindowActive":"false","outerAirCirculation":"outsideAir","startConfiguration":"START_ENGINE_ALLOW_KEY_IN_IGNITION","canEdit":"true","disabled":"true","vehicleType":"gas","presetType":"subaruPreset"}',
'{"name": "Full Heat", "runTimeMinutes": "10", '
'"climateZoneFrontTemp": "85", "climateZoneFrontAirMode": '
'"feet_window", "climateZoneFrontAirVolume": "7", "airConditionOn": '
'"false", "heatedSeatFrontLeft": "high_heat", '
'"heatedSeatFrontRight": "high_heat", "heatedRearWindowActive": '
'"true", "outerAirCirculation": "outsideAir", "startConfiguration": '
'"START_ENGINE_ALLOW_KEY_IN_IGNITION", "canEdit": "true", '
'"disabled": "true", "vehicleType": "gas", "presetType": '
'"subaruPreset" }',
'{"name": "Full Cool", "runTimeMinutes": "10", '
'"climateZoneFrontTemp": "60", "climateZoneFrontAirMode": '
'"feet_face_balanced", "climateZoneFrontAirVolume": "7", '
'"airConditionOn": "true", "heatedSeatFrontLeft": "OFF", '
'"heatedSeatFrontRight": "OFF", "heatedRearWindowActive": "false", '
'"outerAirCirculation": "outsideAir", "startConfiguration": '
'"START_CLIMATE_CONTROL_ONLY_ALLOW_KEY_IN_IGNITION", "canEdit": '
'"true", "disabled": "true", "vehicleType": "phev", "presetType": '
'"subaruPreset" }',
'{"name": "Full Heat", "runTimeMinutes": "10", '
'"climateZoneFrontTemp": "85", "climateZoneFrontAirMode": '
'"feet_window", "climateZoneFrontAirVolume": "7", "airConditionOn": '
'"false", "heatedSeatFrontLeft": "high_heat", '
'"heatedSeatFrontRight": "high_heat", "heatedRearWindowActive": '
'"true", "outerAirCirculation": "outsideAir", "startConfiguration": '
'"START_CLIMATE_CONTROL_ONLY_ALLOW_KEY_IN_IGNITION", "canEdit": '
'"true", "disabled": "true", "vehicleType": "phev", "presetType": '
'"subaruPreset" }'],
'dataName': None,
'errorCode': None,
'success': True}
2023-02-23 19:24:55,194 - subarulink.controller - DEBUG - Getting EV Status vinxxxxxxxxxxxxxxxx:False
2023-02-23 19:24:55,195 - subarulink.controller - DEBUG - Getting EV Status vinxxxxxxxxxxxxxxxx:False
2023-02-23 19:24:55,195 - subarulink.controller - DEBUG - Getting EV Status vinxxxxxxxxxxxxxxxx:False
2023-02-23 19:24:55,195 - subarulink.controller - DEBUG - Getting EV Status vinxxxxxxxxxxxxxxxx:False
2023-02-23 19:24:55,195 - subarulink.controller - DEBUG - Getting EV Status vinxxxxxxxxxxxxxxxx:False
2023-02-23 19:24:55,195 - subarulink.controller - DEBUG - Getting EV Status vinxxxxxxxxxxxxxxxx:False
2023-02-23 19:24:55,196 - subarulink.controller - DEBUG - Getting EV Status vinxxxxxxxxxxxxxxxx:False
2023-02-23 19:24:55,196 - subarulink.controller - DEBUG - Getting EV Status vinxxxxxxxxxxxxxxxx:False
2023-02-23 19:24:55,196 - subarulink.controller - DEBUG - Getting EV Status vinxxxxxxxxxxxxxxxx:False
2023-02-23 19:24:55,196 - subarulink.controller - DEBUG - Getting EV Status vinxxxxxxxxxxxxxxxx:False
2023-02-23 19:24:55,196 - subarulink.connection - DEBUG - GET: https://mobileapi.prod.subarucs.com/g2v25/service/g2/remoteEngineStartSettings/fetch.json, params=None, json_data=None
2023-02-23 19:24:55,384 - subarulink.controller - DEBUG - {'data': '[{"name":"Defrost","runTimeMinutes":"10","climateZoneFrontTemp":"72","climateZoneFrontAirMode":"FEET_WINDOW","climateZoneFrontAirVolume":"7","outerAirCirculation":"recirculation","heatedRearWindowActive":"true","heatedSeatFrontLeft":"LOW_HEAT","heatedSeatFrontRight":"LOW_HEAT","airConditionOn":"false","canEdit":"true","disabled":"false","presetType":"userPreset","startConfiguration":"START_ENGINE_ALLOW_KEY_IN_IGNITION"}]',
'dataName': None,
'errorCode': None,
'success': True}
2023-02-23 19:24:55,384 - subarulink.controller - DEBUG - Getting EV Status vinxxxxxxxxxxxxxxxx:False
2023-02-23 19:24:55,384 - subarulink.controller - DEBUG - Getting subscription Status vinxxxxxxxxxxxxxxxx:True
2023-02-23 19:24:55,385 - subarulink.controller - DEBUG - Getting remote Status vinxxxxxxxxxxxxxxxx:True
2023-02-23 19:24:55,385 - subarulink.controller - DEBUG - Getting RES Status vinxxxxxxxxxxxxxxxx:True
2023-02-23 19:24:55,385 - subarulink.controller - DEBUG - Getting subscription Status vinxxxxxxxxxxxxxxxx:True
2023-02-23 19:24:55,385 - subarulink.controller - DEBUG - Getting remote Status vinxxxxxxxxxxxxxxxx:True
2023-02-23 19:24:55,385 - subarulink.controller - DEBUG - Getting vehicle API gen vinxxxxxxxxxxxxxxxx:g3

Vehicle last reported data -1 days, 23 hours, 58 minutes ago

Odometer: 144.8 miles
Distance to Empty: 229 miles
Average Fuel Consumption: 30 MPG
Vehicle State: IGNITION_OFF
Tire Pressures (psi):
FL: 36 FR: 36 (35 recommended)
RL: 34 RR: 35 (33 recommended)
Position:XXXXXXXXXXXXXXXXXXXX Heading: 0

Enter a command. For a list of commands, enter '?'.

Blank / Example Config?

Hi!

Is there a way to generate a blank / framework config, or do you have an example available that my eyes aren't finding?

Thank you!

M.

Getting error on locate command

sudipta@Sudipta-Sen-W1FJVTJHQX  ~  python3env  subarulink locate                                                                                                                             ✔  4275  09:18:43
Traceback (most recent call last):
  File "/Users/sudipta/python3env/bin/subarulink", line 8, in <module>
    sys.exit(main())
  File "/Users/sudipta/python3env/lib/python3.9/site-packages/subarulink/app/cli.py", line 715, in main
    LOOP.run_until_complete(cli.single_command(args.command, args.vin, cli.config))
  File "/opt/homebrew/Cellar/[email protected]/3.9.13_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
    return future.result()
  File "/Users/sudipta/python3env/lib/python3.9/site-packages/subarulink/app/cli.py", line 555, in single_command
    print(f"Longitude:\t{self.car_data['status'].get('longitude')}")
KeyError: 'status'
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x103b4a2e0>
Unclosed connector
connections: ['[(<aiohttp.client_proto.ResponseHandler object at 0x103b730a0>, 17.977914666)]']
connector: <aiohttp.connector.TCPConnector object at 0x103b4a310>

Don't display VIN on success?

I use this on my phone and use Google voice keyboard for hacky Voice activated commands out and about, but I don't like that it shows the VIN number on success. I'd rather it show the vehicle nickname

[Feature] Add ability to stop the current request (Horn / Lights)

In the MySubaru app, you can sound the horn, and then stop it, as well. When sounding, it honks every couple of seconds.

With this, you just send a command to request the event and it keeps going.
I haven't fully tested if there's a timeout, or not, on their side, but it would be nice to be able to send a stop command, if that's possible.

I'm not sure what else to provide, but if I can help with any info, just let me know.

Otherwise, thanks for this, it's awesome.

Device not authenticated error

This happened the first time I tried running the CLI in a new virtual enviornment. It did not recur on subsequent runs. Dropping it here in case there's any error handling you want to do:

2020-07-22 14:11:25,622 - subarulink.connection - DEBUG - GET: https://www.mysubaru.com/profile/addDeviceName.json
2020-07-22 14:11:25,665 - subarulink.connection - DEBUG - Set Device Name Successful
2020-07-22 14:11:25,666 - subarulink.controller - DEBUG - Subaru Remote Services Ready!
2020-07-22 14:11:25,666 - subarulink - INFO - Successfully connected

Available Vehicles:
[1] *********** (***********)
2020-07-22 14:11:25,666 - subarulink.controller - DEBUG - Getting EV Status ***********:False
2020-07-22 14:11:25,666 - subarulink.controller - DEBUG - Getting RES Status ***********:True
2020-07-22 14:11:25,666 - subarulink - INFO - Fetching data for ***********...
2020-07-22 14:11:25,666 - subarulink.controller - DEBUG - Fetching vehicle status from Subaru
2020-07-22 14:11:25,666 - subarulink.connection - DEBUG - GET: https://mobileapi.prod.subarucs.com/g2v15/validateSession.json
2020-07-22 14:11:25,689 - subarulink.connection - DEBUG - {'data': None, 'dataName': None, 'errorCode': None, 'success': True}
2020-07-22 14:11:25,689 - subarulink.connection - DEBUG - GET: https://mobileapi.prod.subarucs.com/g2v15/service/g2/condition/execute.json
2020-07-22 14:11:25,717 - subarulink.controller - DEBUG - {'data': {'errorDescription': 'Device needs to be authenticated for triggering '
                              'remote services',
          'errorLabel': 'DEVICE_NOT_AUTHENTICATED'},
 'dataName': 'errorResponse',
 'errorCode': 'DEVICE_NOT_AUTHENTICATED',
 'success': False}
2020-07-22 14:11:25,718 - subarulink - ERROR - Unable to connect.  Check Username/Password.

Cannot get to work on Windows PC. Suspect 2-Factor authentication issue?

I have double checked my username and password, but always get an error when I try to connect for the first time with an empty config file. I suspect that the Subaru side is not recognizing the device I am using and so refuses until I go through 2-factor setup.

When I used a browser on the same PC it asked for the 2FA and I was able to then connect in Chrome, but the CLI tool is still failing. I have no idea what information the Subaru site is caching to decide if I am a valid device.

Any suggestions?

2023-01-06 13:57:49,510 - subarulink.connection - ERROR - RequestInfo(url=URL('https://mobileapi.prod.subarucs.com/g2v21/login.json'), method='POST', headers=<CIMultiDictProxy('Host': 'mobileapi.prod.subarucs.com', 'User-Agent': 'Mozilla/5.0 (
'one exists.


Apache '
'Tomcat/8.5.58

')
2023-01-06 13:57:49,514 - subarulink - ERROR - Unable to connect: HTTP 404: <ClientResponse(https://mobileapi.prod.subarucs.com/g2v21/login.json) [404 ]>
<CIMultiDictProxy('Date': 'Fri, 06 Jan 2023 18:57:49 GMT', 'Content-Type': 'text/html;charset=utf-8', 'Content-Length': '682', 'Connection': 'keep-alive', 'Content-Language': 'en', 'Cache-Control': 'max-age=0, no-cache, no-store, must-revalidate', 'Pra
gma': 'no-cache')>

International usage

I would be greatly interested in this but I am from Switzerland and MySubaru is only for the US I suppose. Is there any possibility without a MySubaru Account? What is it used for? I can help testing and debugging stuff. I have a 2019 Levorg Subaru.

Second Phase Connect to mysubaru.com Failing

Hello and thanks for subarulink.
I'm getting an error when using the CLI, whether it's doing the initial interactive setup or when sending a command.
My accounts were set up a week ago on 3/12.
The process did demand that I set up 2-factor authentication.
I do get data back from https://mobileapi.prod.subarucs.com , but there is an error on trying to connect to mysubaru.com:

...
'vehicleName': '2022 Crosstrek Limited',
'vin': 'JFXXXXXXXXXXXXXXX',
'zip': None},
'dataName': 'vehicle',
'errorCode': None,
'success': True}
2022-03-19 16:26:43,386 - subarulink.connection - DEBUG - Authorizing device via web API
2022-03-19 16:26:43,387 - subarulink.connection - DEBUG - POST: https://www.mysubaru.com/login, params=None, json_data=None
2022-03-19 16:26:43,646 - subarulink.connection - ERROR - RequestInfo(url=URL('https://www.mysubaru.com/login'), method='POST', headers=<CIMultiDictProxy('Host': 'www.mysubaru.com', 'Accept': '/', 'Accept-Encoding': 'gzip, deflate', 'User-Agent': 'Python/3.9 aiohttp/3.8.1', 'Content-Length': '77', 'Content-Type': 'application/x-www-form-urlencoded')>, real_url=URL('https://www.mysubaru.com/login'))
2022-03-19 16:26:43,783 - subarulink.connection - ERROR - ('\r\n'
'\r\n'
'\r\n'
...

...plus the remainder of the raw HTML of the response, then:

'\r\n')
2022-03-19 16:26:43,785 - subarulink - ERROR - Unable to connect: HTTP 500: <Cli
entResponse(https://www.mysubaru.com/login) [500 ]>

Could the 2-factor be causing the problem? I don't find any way to disable it.

Error 500 input string

Getting this error on remote start with default profile (created through interactive mode) for a Canadian account. I'm using the CLI, not HA. Any ideas? I assume the AUTO is coming from the custom preset data

subarulink.connection - ERROR - ('{"httpCode":500,"errorCode":"error","errorMessage":"java.lang.NumberFormatException ' '- For input string: \\"AUTO\\""}') 2022-01-24 17:12:17,663 - subarulink - ERROR - SubaruException caught: HTTP 500: <ClientResponse(https://mobileapi.ca.prod.subarucs.com/g2v21/service/g2/engineStart/execute.json) [500 ]>

[Question] Passing arguments to the CLI

I'm excited for the native HA integration for this. In the meantime, maybe a basic(?) question? Is it possible to pass arguments into the CLI ? If I could do that, I'm sure I could get a couple of the basic actions working in HA as a stopgap.

Is something like: subarulink VIN lock possible?

Tag the source

It seems that 0.3.14 was added to PyPI without pushing the relevant tag here.

This would allow distributions to build their packages without changing the location of the source tarball.

Thanks

Starlink API

This isn't certainly an issue but I was curious if one of the devs could provide me with a more straightforward API to interact with my car where I can send remote commands through an easy python script from my terminal.

Error when parsing time in controller.py

Hi,

I have been running subaru integration in Home assistant but I see the following error in the logs:

Traceback (most recent call last):
  File "/home/homeassistant/.pyenv/versions/3.11.6/lib/python3.11/site-packages/homeassistant/helpers/update_coordinator.py", line 290, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/homeassistant/.pyenv/versions/3.11.6/lib/python3.11/site-packages/homeassistant/helpers/update_coordinator.py", line 246, in _async_update_data
    return await self.update_method()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/homeassistant/.pyenv/versions/3.11.6/lib/python3.11/site-packages/homeassistant/components/subaru/__init__.py", line 75, in async_update_data
    return await refresh_subaru_data(entry, vehicle_info, controller)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/homeassistant/.pyenv/versions/3.11.6/lib/python3.11/site-packages/homeassistant/components/subaru/__init__.py", line 125, in refresh_subaru_data
    await controller.fetch(vin, force=True)
  File "/mnt/dietpi_userdata/homeassistant/deps/lib/python3.11/site-packages/subarulink/controller.py", line 569, in fetch
    result = await self._fetch_status(vin)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/dietpi_userdata/homeassistant/deps/lib/python3.11/site-packages/subarulink/controller.py", line 1070, in _fetch_status
    status = await self._parse_condition(js_resp, vin)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/dietpi_userdata/homeassistant/deps/lib/python3.11/site-packages/subarulink/controller.py", line 1304, in _parse_condition
    keep_data[sc.TIMESTAMP] = datetime.strptime(data[api.API_LAST_UPDATED_DATE], api.API_TIMESTAMP_FMT)
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/homeassistant/.pyenv/versions/3.11.6/lib/python3.11/_strptime.py", line 568, in _strptime_datetime
    tt, fraction, gmtoff_fraction = _strptime(data_string, format)
                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/homeassistant/.pyenv/versions/3.11.6/lib/python3.11/_strptime.py", line 349, in _strptime
    raise ValueError("time data %r does not match format %r" %
ValueError: time data '2024-02-04T18:53:51.000+0000' does not match format '%Y-%m-%dT%H:%M:%S%z'

I can submit a patch if I get time, but I believe the right fix would be to iterate through all the known time formats obtained from subaru. Wdyt @G-Two?

Unhandled server exception

Hope you don't mind if I open this as an issue. I've been having a lot of problems using the MySubaru app and the command line script tonight. It has actually crossed my mind that I'm being rate limited by their server. Anyhow, one of the errors I'm getting for lock/unlock commands is this:

2020-07-20 22:38:59,091 - subarulink.connection - DEBUG - GET: https://mobileapi.prod.subarucs.com/g2v15/validateSession.json
Traceback (most recent call last):
File "/Users/local_user/.pyenv/versions/3.7.3/lib/python3.7/site-packages/subarulink/connection.py", line 229, in __open
resp = await getattr(self.websession, method)(url, headers=headers, params=params, data=data, json=json)
File "/Users/local_user/.pyenv/versions/3.7.3/lib/python3.7/site-packages/aiohttp/client.py", line 504, in _request
await resp.start(conn)
File "/Users/local_user/.pyenv/versions/3.7.3/lib/python3.7/site-packages/aiohttp/client_reqrep.py", line 847, in start
message, payload = await self._protocol.read() # type: ignore # noqa
File "/Users/local_user/.pyenv/versions/3.7.3/lib/python3.7/site-packages/aiohttp/streams.py", line 591, in read
await self._waiter
aiohttp.client_exceptions.ServerDisconnectedError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Users/local_user/.pyenv/versions/3.7.3/bin/subarulink", line 10, in
sys.exit(main())
File "/Users/local_user/.pyenv/versions/3.7.3/lib/python3.7/site-packages/subarulink/app/cli.py", line 554, in main
LOOP.run_until_complete(cli.single_command(args.command, args.vin))
File "/Users/local_user/.pyenv/versions/3.7.3/lib/python3.7/asyncio/base_events.py", line 584, in run_until_complete
return future.result()
File "/Users/local_user/.pyenv/versions/3.7.3/lib/python3.7/site-packages/subarulink/app/cli.py", line 422, in single_command
success = await self._ctrl.unlock(self._current_vin)
File "/Users/local_user/.pyenv/versions/3.7.3/lib/python3.7/site-packages/subarulink/controller.py", line 198, in unlock
resp = await self._actuate(vin, "unlock", data=form_data)
File "/Users/local_user/.pyenv/versions/3.7.3/lib/python3.7/site-packages/subarulink/controller.py", line 305, in _actuate
return await self._remote_command(vin, cmd, data=form_data)
File "/Users/local_user/.pyenv/versions/3.7.3/lib/python3.7/site-packages/subarulink/controller.py", line 284, in _remote_command
await self._connection.validate_session(vin)
File "/Users/local_user/.pyenv/versions/3.7.3/lib/python3.7/site-packages/subarulink/connection.py", line 64, in validate_session
resp = await self.__open("/validateSession.json", "get")
File "/Users/local_user/.pyenv/versions/3.7.3/lib/python3.7/site-packages/subarulink/connection.py", line 238, in __open
raise SubaruException("aiohttp.ClientConnectionError")
subarulink.exceptions.SubaruException
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x10a2e2fd0>

Login error

Getting invalid account when trying to login. I can login to the mysubaru.ca website and the app works.

VehicleStatus.json Multiple Vehicles

@G-Two Looking into what/if using mysubaru.com/vehicleStatus.json for some data like perhaps regular checks of the Car's Location without having to force mysubaru to do a locate.

Can you let me know what it looks like for you? There doesn't seem to be any specific Matching ID used for the vehicle but I might be missing something only having 1 car.

{"success":true,"data":{"vhsId":1677992786,"odometerValue":4520,"odometerValueKilometers":7272,"eventDate":"2020-07-11T22:13:38.000+0000","eventDateStr":"2020-07-11T22:13+0000","latitude":39.XXXXXX,"longitude":-76.XXXXXX,"positionHeadingDegree":"337","distanceToEmptyFuelMiles":89.48,"distanceToEmptyFuelKilometers":144,"avgFuelConsumptionMpg":24.8,"avgFuelConsumptionLitersPer100Kilometers":9.5,"vehicleStateType":"IGNITION_OFF","distanceToEmptyFuelMiles10s":90,"distanceToEmptyFuelKilometers10s":140}}

Report When Car is Turned On & Off

Maybe there is a limitation that prevents this, but it would be super handy to know on/off events. Right now, I get odometer readings whenever the car turns off. What can't be reasoned out of that data is how long the car was running or what its average speed was. Even simple boolean records of on and off times would help amend this.

In an even more ideal world, all data would get recorded both when the car turns off and on, though I expect this is even more a limitation on Subaru's end. As it stands now, its easy to create a scenario where, on a long journey, the car gets turned off to refuel, then runs another ~300 miles before stopping to refuel again. In that scenario, you would get two reports of low "distance to empty", instead of a more accurate saw tooth shape.

Controller needs to maintain current VIN state.

For multi-vehicle accounts, the Controller needs to know/update what the current VIN is since all Subaru API calls are made without reference to a VIN. VIN is set by selectVehicle.json. Current vehicle is returned by login.json as currentVehicleIndex. This only needs to be called if the Controller is making an API call to a VIN that is not the current VIN. It may happen frequently with HomeAssistant users controlling multiple vehicles, so this must be fixed prior to the next release (which currently works because it naively calls selectVehicle.json every time).

Write tests

I anticipate more code changes as more users try different vehicles and issues are raised. Tests are needed to cover the code for this module.

Remove __pycache__ folder

The source tarball that is published on PyPI contains __pycache__ folders. Those folders and their content should not be part of the archive.

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.