Giter VIP home page Giter VIP logo

bimmer_connected's Introduction

bimmer_connected

https://github.com/bimmerconnected/bimmer_connected/actions/workflows/test.yml/badge.svg?branch=master https://readthedocs.org/projects/bimmer-connected/badge/?version=latest https://codecov.io/gh/bimmerconnected/bimmer_connected/branch/master/graph/badge.svg?token=qNT50j82f6 https://static.pepy.tech/badge/bimmer_connected/week https://static.pepy.tech/badge/bimmer_connected/month https://static.pepy.tech/badge/bimmer_connected

This is a simple library to query and control the status of your BMW, Mini, or Toyota Supra vehicle from the MyBMW portal.

Installation

bimmer_connected is tested against Python 3.8 or above. Just install the latest release from PyPI using pip3 install --upgrade bimmer_connected.

Alternatively, clone the project and execute pip install -e . to install the current master branch.

Note

If you want to connect to a chinese server, you need to install the [china] extra, e.g. pip3 install --upgrade bimmer_connected[china].

Usage

While this library is mainly written to be included in Home Assistant, it can be use on its own.

After installation, execute bimmerconnected from command line for usage instruction or see the full CLI documentation.

Please be aware that bimmer_connected is an async library when using it in Python code. The description of the modules can be found in the module documentation.

Example in an asyncio event loop

import asyncio
from bimmer_connected.account import MyBMWAccount
from bimmer_connected.api.regions import Regions

async def main():
    account = MyBMWAccount(USERNAME, PASSWORD, Regions.REST_OF_WORLD)
    await account.get_vehicles()
    vehicle = account.get_vehicle(VIN)
    print(vehicle.brand, vehicle.name, vehicle.vin)

    result = await vehicle.remote_services.trigger_remote_light_flash()
    print(result.state)

asyncio.run(main())

Example in non-async code

import asyncio
from bimmer_connected.account import MyBMWAccount
from bimmer_connected.api.regions import Regions


account = MyBMWAccount(USERNAME, PASSWORD, Regions.REST_OF_WORLD)
asyncio.run(account.get_vehicles())
vehicle = account.get_vehicle(VIN)
print(vehicle.brand, vehicle.name, vehicle.vin)

result = asyncio.run(vehicle.remote_services.trigger_remote_light_flash())
print(result.state)

Compatibility

This works with BMW/Mini/Toyota Supra vehicles with a MyBMW account. So far it is tested on vehicles with a 'MGU', 'NBTEvo', 'EntryEvo', 'NBT', or 'EntryNav' navigation system. If you have any trouble with other navigation systems, please create an issue with your server responses (see next section).

To use this library, your BMW/Mini/Toyota Supra must have the remote services enabled for your vehicle. You might need to book this in the MyBMW/Mini Connected/Supra Connect portal and this might cost some money. In addition to that you need to enable the Remote Services in your infotainment system in the vehicle.

Different models of vehicles and infotainment systems result in different types of attributes provided by the server. So the experience with the library will certainly vary across the different vehicle models.

Data Contributions

If some features do not work for your vehicle, we would need the data returned form the server to analyse this and potentially extend the code. Different models and head unit generations lead to different responses from the server.

If you want to contribute your data, perform the following steps:

# get the latest version of the library
pip3 install --upgrade bimmer_connected

# run the fingerprint function
bimmerconnected fingerprint <username> <password> <region>

This will create a set of log files in the "vehicle_fingerprint" folder. Before sending the data to anyone please check for any personal data such as dealer name or country.

The following attributes are by default replaced with anonymized values:

  • vin (Vehicle Identification Number)
  • lat and lon (GPS position)
  • licensePlate
  • information of dealer

Create a new fingerprint data contribution and add the files as attachment to the discussion.

Please add your model and year to the title of the issue, to make it easier to organize. If you know the "chassis code" of your car, you can include that too. (For example, googling "2017 BMW X5" will show a Wikipedia article entitled "BMW X5 (F15)". F15 is therefore the chassis code of the car.)

Note: We will then use this data as additional test cases. So we will publish (parts of) it (after checking for personal information again) and use this as test cases for our library. If you do not want this, please let us know in advance.

Code Contributions

Contributions are welcome! Please make sure that your code passes the checks in .github/workflows/test.yml. We currently test against flake8, pylint and our own pytest suite. And please add tests where it makes sense. The more the better.

See the contributing guidelines for more details.

Thank you

Thank you to all contributors for your research and contributions! And thanks to everyone who shares the fingerprint data of their vehicles which we use to test the code. A special thanks to @HuChundong, @muxiachuixue, @vividmuse for figuring out how to solve login issues!

This library is basically a best-of of other similar solutions, yet none of them provided a ready to use library with a matching interface to be used in Home Assistant and is available on pypi.

Thank you for your great software!

License

The bimmer_connected library is licensed under the Apache License 2.0.

Disclaimer

This library is not affiliated with or endorsed by BMW Group.

bimmer_connected's People

Contributors

5e avatar algestam avatar cdce8p avatar cubinet-code avatar datdraggy avatar eddyk69 avatar gerard33 avatar gr3yh0und avatar luka6000 avatar m1n3rva avatar markinus avatar muxiachuixue avatar plourenco avatar quentame avatar rikroe avatar robthebold avatar scop avatar severon96 avatar swimsystems avatar timmccor avatar vanshg avatar yixi 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bimmer_connected's Issues

Implement "send text to car"

From the connected drive portal you can somehow send a text message to your car.

it would be nice, if we can also provide this service via the API

BMW 320d xDrive Touring (F31 LCI) (08/2015)

I'm using the BMW Connected Drive component of Home Assistant but don't get very much information. Thought sharing my fingerprint files could be useful. I've only obfuscated the vehicle's lat and long attributes. Other values weren't changed.

status_0.txt

{
  "vehicleStatus": {
    "DCS_CCH_Activation": "NA",
    "DCS_CCH_Ongoing": false,
    "position": {
      "lat": 0.0,
      "lon": 0.0,
      "status": "OK"
    },
    "steering": "LH",
    "updateTime": "2018-04-26T22:44:27+0200",
    "vin": "some_vin"
  }
}

vehicles_0.txt

{
  "vehicles": [
    {
      "a4a": "USB_ONLY",
      "bodytype": "F31",
      "brand": "BMW",
      "breakdownNumber": "+4989358957103",
      "carCloud": "NOT_SUPPORTED",
      "chargeNow": "NOT_SUPPORTED",
      "chargingControl": "NOT_SUPPORTED",
      "climateControl": "START_TIMER",
      "climateFunction": "VENTILATION",
      "climateNow": "ACTIVATED",
      "color": "BLACK SAPPHIRE METALLIC",
      "colorCode": "475",
      "countryCode": "V6",
      "doorLock": "ACTIVATED",
      "doorUnlock": "ACTIVATED",
      "driveTrain": "CONV",
      "fuelType": "DIESEL",
      "hasAlarmSystem": true,
      "hmiVersion": "ID4",
      "hornBlow": "ACTIVATED",
      "hub": "HUB_ECE",
      "intermodalRouting": "NOT_AVAILABLE",
      "ipa": "NOT_SUPPORTED",
      "lastDestinations": "NOT_SUPPORTED",
      "licensePlate": "some_license_plate",
      "lightFlash": "ACTIVATED",
      "lscType": "NOT_SUPPORTED",
      "model": "320d xDrive",
      "onlineSearchMode": "MAP",
      "onlineSearchProvider": "GOOGLE",
      "rangeMap": "NOT_SUPPORTED",
      "remote360": "NOT_SUPPORTED",
      "sendPoi": "ACTIVATED",
      "smartSolution": "NOT_SUPPORTED",
      "statisticsAvailable": false,
      "statisticsCommunityEnabled": false,
      "steering": "LH",
      "vehicleFinder": "ACTIVATED",
      "vehicleFinderRestriction": "NONE",
      "vin": "some_vin",
      "yearOfConstruction": 2015
    }
  ]
}

Show info in device tracker if tracking is disabled [nice to have]

Would be nice to show in the device tracker (via state attribute) if tracking is disabled.

Tracking for my car was enabled, but when I disabled it in the car settings, the device tracker doesn't show gps coordinates and shows Home (which is not were my car is atm).

screenshot_2

Fix startup of components in HA

There is some weird concurrence/async problem during startup: The data is pulled in before the sensors are created. So there is no data on startup and you have to wait until the 5 minute refresh kicks in. Not a major issue but also not very nice.

Condition based service data

  • Get the condition based service data from the server response and parse it.
  • Extend the sensors in Home Assistant with this data

make it easier to test the library

Based on the discussion in #41 we should make it easier for people to test the library and also contribute vehicle data. For that we should:

  1. Add requests to the project dependencies
  2. add documentation to pull the latest branch via pip

please assign this ticket to me, I'll prepare something

Location Update

Hi.
I was wondering whether it is already known how to trigger a vehicle location update (while it is stationary) as you would do with the Android/iOS app, provided that the option is enabled in the vehicle.

Firstly I have tried something like this:

GET https://www.bmw-connecteddrive.xy/api/vehicle/service/v1/-----VIN_NUMBER ----

This returns a list of 'features' including the already known: RDL, RDU, RCN, RHB, RLF, RCT.... but also returns something called "VF" which I interpreted as Vehicle_Finder.

But if I try use POST to trigger this function (it already works OK with RDL for instance) I get the following status_report: CDP_ERROR.

Does anyone know if I am missing some parameter (maybe sender location or something like that) or the appropriate syntax to trigger the location update?.

Thanks in advance.

Missing beRemainingRangeFuel attribute

I'm facing an issue getting the vehicle state.

Traceback (most recent call last):
  File "/config/deps/lib/python3.6/site-packages/bimmer_connected/state.py", line 44, in _func_wrapper
    return func(self, *args, **kwargs)
  File "/config/deps/lib/python3.6/site-packages/bimmer_connected/state.py", line 141, in remaining_range_fuel
    return float(self._attributes['beRemainingRangeFuel'])
KeyError: 'beRemainingRangeFuel'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/lib/python3.6/site-packages/homeassistant/components/bmw_connected_drive.py", line 98, in update
    listener()
  File "/usr/lib/python3.6/site-packages/homeassistant/components/sensor/bmw_connected_drive.py", line 81, in update
    self._state = getattr(vehicle_state, self._attribute)
  File "/config/deps/lib/python3.6/site-packages/bimmer_connected/state.py", line 46, in _func_wrapper
    raise ValueError('No data available!')
ValueError: No data available!

It seems that for my car the beRemainingRangeFuel is missing.

This is what I'm getting:

{
  "attributesMap" : {
    "DCS_CCH_Ongoing " : null,
    "unitOfElectricConsumption" : "kWh/100km",
    "mileage" : "xxxxx",
    "head_unit_pu_software" : "07/14",
    "gps_lat" : "xxxxxx",
    "head_unit" : "NBT",
    "DCS_CCH_Activation" : null,
    "condition_based_services" : "00001,OVERDUE,12.2018,-500,453,19,24;00100,OVERDUE,12.2018,-500,453,38,48;00002,PENDING,,140,,36,;00003,OK,4.2019,,573,,24;00032,OK,4.2019,,573,,;00033,OK,4.2019,,573,,",
    "vehicle_tracking" : "1",
    "remaining_fuel" : "66",
    "lastUpdateReason" : "Error",
    "gps_lng" : "xxxxxxx",
    "unitOfCombustionConsumption" : "l/100km",
    "unitOfEnergy" : "kWh",
    "unitOfLength" : "km"
  },
  "vehicleMessages" : {
    "ccmMessages" : [ ],
    "cbsMessages" : [ {
      "description" : "Minął termin przeglądu! Proszę jak najszybciej ustalić termin ze swoim serwisem.",
      "text" : "Olej silnikowy",
      "id" : 1,
      "status" : "OVERDUE",
      "messageType" : "CBS",
      "date" : "12.2018",
      "unitOfLengthRemaining" : "-500"
    }, {
      "description" : "Minął termin kontroli wzrokowej! Proszę ustalić termin ze swoim serwisem.",
      "text" : "Kontrola pojazdu",
      "id" : 100,
      "status" : "OVERDUE",
      "messageType" : "CBS",
      "date" : "12.2018",
      "unitOfLengthRemaining" : "-500"
    }, {
      "description" : "Zbliża się termin wymiany. Proszę ustalić termin ze swoim serwisem.",
      "text" : "Okładz. hamulc. przód",
      "id" : 2,
      "status" : "PENDING",
      "messageType" : "CBS",
      "date" : "",
      "unitOfLengthRemaining" : "140"
    }, {
      "description" : "Następna wymiana najpóźniej w podanym terminie.",
      "text" : "Płyn hamulcowy",
      "id" : 3,
      "status" : "OK",
      "messageType" : "CBS",
      "date" : "4.2019",
      "unitOfLengthRemaining" : ""
    }, {
      "description" : "Następne obowiązkowe badanie techniczne pojazdu w podanym terminie.",
      "text" : "§ Badan. techn. pojazdu",
      "id" : 32,
      "status" : "OK",
      "messageType" : "CBS",
      "date" : "4.2019",
      "unitOfLengthRemaining" : ""
    }, {
      "description" : "Następne obowiązkowe badanie emisji spalin najpóźniej w podanym terminie.",
      "text" : "§ Badanie emisji spalin",
      "id" : 33,
      "status" : "OK",
      "messageType" : "CBS",
      "date" : "4.2019",
      "unitOfLengthRemaining" : ""
    } ]
  }
}

Figure out a way to use the refresh token

Maybe also use a proper oauth library.

I heared rumors that there is a longer living "refresh" token, the we could use and cache instead of the credentials. Although I've never seen an interface that can provide such a token...

Add missing sensors

  • Add all other attributes a vehicle could have.
  • Automatically detect which attributes are available for a vehicle.

Add switches

  • Climate (most logical use case in HA)
  • Flash lights
  • Horn

You can assign this one to me as well. I can rewrite my existing switches component to your bimmer connected module.

SWITCHES = {
    'climate': ['Climate', 'mdi:air-conditioner'],
    'light': ['Light', 'mdi:alarm-light'],
    'horn': ['Horn', 'mdi:bullhorn'],
}

Mini Connected

Hi,

Is there a way to get Mini Fix series status ?
Those cars use Mini Connected App.
It may use quite the same things to get Data, No ?

Thx

Add extra sensor options

  • check if car type is fuel, electric or hybrid and show the relevant sensors (see i, ii)
  • give sensors a friendly name and mdi icon (see ii)
  • show nice icon with battery % for electric/hybrid cars, see this comment

i. Is part of bimmer_connected module.

ii.

SENSOR_TYPES = {
    'remaining_fuel': ['Remaining Fuel', 'mdi:gas-station'],
    'kombi_current_remaining_range_fuel': ['Range (fuel)', 'mdi:ruler'],
    'mileage': ['Mileage', 'mdi:speedometer']
}

SENSOR_TYPES_ELEC = {
    'beRemainingRangeElectric': ['Range (electric)', 'mdi:ruler'],
    'chargingLevelHv': ['Charging level', 'mdi:battery-charging'],
    'soc_hv_percent': ['State of charge', 'mdi:battery-charging-60'],
    'chargingTimeRemaining': ['Charging level', 'mdi:clock']   # Not available on i3 or when fully loaded?
}

Error running bimmerconnected

I get the following error running this command:

bimmerconnected fingerprint "username" "password" rest_of_world

DEBUG:bimmer_connected.account:Getting vehicle list DEBUG:bimmer_connected.account:getting new oauth token DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): b2vapi.bmwgroup.com DEBUG:urllib3.connectionpool:https://b2vapi.bmwgroup.com:443 "POST /webapi/oauth/token HTTP/1.1" 200 None DEBUG:bimmer_connected.account:got new token "zzzzzzzzzzzzzzzxxxxxxxxxxxxxxxxx" with expiration date 2018-04-03 05:59:33.105577 DEBUG:bimmer_connected.account:Old token is still valid. Not getting a new one. DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): b2vapi.bmwgroup.com DEBUG:urllib3.connectionpool:https://b2vapi.bmwgroup.com:443 "GET /webapi/v1/user/vehicles HTTP/1.1" 200 None Traceback (most recent call last): File "/usr/local/bin/bimmerconnected", line 106, in <module> main() File "/usr/local/bin/bimmerconnected", line 44, in main args.func(args) File "/usr/local/bin/bimmerconnected", line 72, in fingerprint log_responses=time_dir) File "/usr/local/lib/python3.5/dist-packages/bimmer_connected/account.py", line 55, in __init__ self._get_vehicles() File "/usr/local/lib/python3.5/dist-packages/bimmer_connected/account.py", line 183, in _get_vehicles logfilename='vehicles') File "/usr/local/lib/python3.5/dist-packages/bimmer_connected/account.py", line 129, in send_request self._log_response_to_file(response, logfilename) File "/usr/local/lib/python3.5/dist-packages/bimmer_connected/account.py", line 137, in _log_response_to_file anonymized_data = json.dumps(self._anonymize_data(response.json()), indent=2, sort_keys=True) File "/usr/local/lib/python3.5/dist-packages/bimmer_connected/account.py", line 167, in _anonymize_data json_data[key] = [ConnectedDriveAccount._anonymize_data(v) for v in value] File "/usr/local/lib/python3.5/dist-packages/bimmer_connected/account.py", line 167, in <listcomp> json_data[key] = [ConnectedDriveAccount._anonymize_data(v) for v in value] File "/usr/local/lib/python3.5/dist-packages/bimmer_connected/account.py", line 167, in _anonymize_data json_data[key] = [ConnectedDriveAccount._anonymize_data(v) for v in value] File "/usr/local/lib/python3.5/dist-packages/bimmer_connected/account.py", line 167, in <listcomp> json_data[key] = [ConnectedDriveAccount._anonymize_data(v) for v in value] File "/usr/local/lib/python3.5/dist-packages/bimmer_connected/account.py", line 161, in _anonymize_data for key, value in json_data.items(): AttributeError: 'str' object has no attribute 'items'
The vehicle fingerprint folder is created, but it is empty.
My car is a new BMW i3 LCI 2018. I use the Swedish Connected Drive website.

What is wrong?

Add binary sensors

  • Doors
  • Windows
  • Door lock state
  • Parking lights
  • Condition based services
  • Control messages
  • Charging
  • Connector status

You can assign this to me. I can rewrite my existing binary sensor component to work with your bimmer connected module. Can you confirm that I should add these as
@property @backend_parameter in the bimmer connected module?

SENSOR_TYPES = {
    'doors_closed': ['Doors', 'opening'],
    'windows_closed': ['Windows', 'opening'],
    'door_lock_state': ['Door lock state', 'safety'],
    'lights_parking': ['Parking lights', 'light'],
    'condition_based_services': ['Condition based services', 'problem'],
    'check_control_messages': ['Control messages', 'problem']
}

SENSOR_TYPES_ELEC = {
    'charging_status': ['Charging', 'power'],       # CHARGINGACTIVE, CHARGINGENDED # attributes: lastChargingEndReason, lastChargingEndResult
    'connectorStatus': ['Connector status', 'plug']
}

CODE_TO_SERVICE_NAME = {
    '00001': 'motor_oil',
    '00003': 'brake_fluid',
    '00017': 'vehicle_inspection',  # from BMW i3
    '00100': 'car_check',
    '00032': 'vehicle_inspection'   # from BMW X1
}

Add some extra attributes as output in VehicleClass

  • lastUpdateReason
  • condition_based_services
  • lights_parking
  • check_control_messages

lastUpdateReason
The lastUpdateReason contains some nice information which can be shown as attribute of the Door lock state binary sensor.

Some of the possible values are:

VEHICLE_SECURED, DOORSTATECHANGED, VEHCSHUTDOWN, VEHCSHUTDOWN_SECURED, CHARGINGSTARTED

condition_based_services
Can be added as binary sensor. If all items are OK then all is good.

CODE_TO_SERVICE_NAME = {
    '00001': 'motor_oil',
    '00003': 'brake_fluid',
    '00017': 'vehicle_inspection',  # from BMW i3
    '00100': 'car_check',
    '00032': 'vehicle_inspection'   # from BMW X1
}

check_control_messages
Can be added as binary sensor. If string is empty then all is good.

lights_parking
Can be added as binary sensor.

anonymize files after data collection

When collecting data via generate_vehicle_fingerprint.py the results contains a lot of data that is sensitive. So it would be nice if we could automatically wipe the data clean, at least of the attributes where we know they are sensitive...

Handle errors from requests properly

If we're offline, an requests.exceptions.ConnectionError is thrown and handed up to the user. Maybe we should wrap all of the connection errors so that the user of the library can handle them gracefully.

Car picture from BMW ConnectedDrive [nice to have]

Using this URL you can get a picture of your car as also shown in the BMW ConnectedDrive app.

https://www.bmw-connecteddrive.de/api/vehicle/image/v1/<VIN>?startAngle=10&stepAngle=10&width=780

Size and angle can be changed in the url.
It returns a JSON with all pictures for each angle.

Not sure if it's possible, but would be nice if this can be showed automatically as the picture of the device tracker instead of the mdi icon.

add missing argument

Add these attributes that are present in the status.json, but not yet in the API:

    "positionLight" : "OFF",
    "chargingConnectionType" : "CONDUCTIVE",
    "chargingInductivePositioning" : "NOT_POSITIONED",
    "DCS_CCH_Ongoing" : false,
    "DCS_CCH_Activation" : "NA",
    "steering" : "LH",
    "connectionStatus" : "CONNECTED",
    "lastChargingEndReason" : "UNKNOWN",
    "lastChargingEndResult" : "UNKNOWN",
    "singleImmediateCharging" : false,

Home-assistant configuration problem

Hi,
I just tried to configure the Home Assistant component and received the error message "Invalid config for [bmw_connected_drive]: [name] is invalid option for [bmw_connected_drive]

What am I doing wrong when configuring? What am I supposed to put as name?

Features for electric/hybrid cars

Hi @robbz23
I saw your comment on home-assistant/core#12277 (comment).

We currently have this ongoing PR.

Next step is to add extra features including some for electric and hybrid cars. You can check the issue overview for these plans.
We have received data from an i3 and a 225xe hybrid which we can use to add some extra features like charging status, electric range.

If you have any more good ideas which features to add for an electric/hybrid car, you can drop them here and we can see how to add these.

BMW 225xe

In the Connected drive app I have values for the last trip driven. Is it possible to get these from the API as well?

Values that would be nice are
Total distance
Electric distance driven
Consumption
Duration
From (location)
To (location)

Thanks

bmw_225xe.zip

BMW 5 Series 2014 F10

@ChristianKuehnel @gerard33

I've managed to run the fingerprint command now and am seeing the following error, I have also attached the only file that was created

vehicles_0.txt
DEBUG:bimmer_connected.account:Getting vehicle list
DEBUG:bimmer_connected.account:getting new oauth token
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): b2vapi.bmwgroup.com
DEBUG:urllib3.connectionpool:https://b2vapi.bmwgroup.com:443 "POST /webapi/oauth/token HTTP/1.1" 200 None
DEBUG:bimmer_connected.account:got new token frDNNgIsIbmPice5feQCvGA2Kme5Z55J with expiration date 2018-04-03 23:01:10.770055
DEBUG:bimmer_connected.account:Old token is still valid. Not getting a new one.
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): b2vapi.bmwgroup.com
DEBUG:urllib3.connectionpool:https://b2vapi.bmwgroup.com:443 "GET /webapi/v1/user/vehicles HTTP/1.1" 200 None
DEBUG:bimmer_connected.state:requesting new data from connected drive
DEBUG:bimmer_connected.account:Old token is still valid. Not getting a new one.
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): b2vapi.bmwgroup.com
DEBUG:urllib3.connectionpool:https://b2vapi.bmwgroup.com:443 "GET /webapi/v1/user/vehicles/WBA5C32050D629352/status HTTP/1.1" 400 None
ERROR:bimmer_connected.account:Unknown status code 400, expected 200
ERROR:bimmer_connected.account:{
"error" : {
"code" : 500,
"description" : "(SmartPhoneUtil-A-101) Mandatory parameter(s) missed or blank: dlat and dlon are required for BMW vehicles!"
}
}
Traceback (most recent call last):
File "/usr/bin/bimmerconnected", line 106, in
main()
File "/usr/bin/bimmerconnected", line 44, in main
args.func(args)
File "/usr/bin/bimmerconnected", line 73, in fingerprint
account.update_vehicle_states()
File "/usr/lib/python3.6/site-packages/bimmer_connected/account.py", line 205, in update_vehicle_states
car.update_state()
File "/usr/lib/python3.6/site-packages/bimmer_connected/vehicle.py", line 58, in update_state
self.state.update_data()
File "/usr/lib/python3.6/site-packages/bimmer_connected/state.py", line 92, in update_data
VEHICLE_STATUS_URL.format(server=self._account.server_url, vin=self._vehicle.vin), logfilename='status')
File "/usr/lib/python3.6/site-packages/bimmer_connected/account.py", line 128, in send_request
raise IOError(msg)
OSError: Unknown status code 400, expected 200

BMW 520d F11 2016

No data shown
I'm on my phone, so can't attach files. Formating is difficult too. Hope all is readable.

Python error when trying to setup

Mar 10 01:07:36 ubuntu hass[16808]: 2018-03-10 01:07:36 ERROR (MainThread) [homeassistant.setup] Error during setup of component bmw_connected_drive
Mar 10 01:07:36 ubuntu hass[16808]: Traceback (most recent call last):
Mar 10 01:07:36 ubuntu hass[16808]:   File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/setup.py", line 145, in _async_setup_component
Mar 10 01:07:36 ubuntu hass[16808]:     component.setup, hass, processed_config)
Mar 10 01:07:36 ubuntu hass[16808]:   File "/usr/lib/python3.6/asyncio/futures.py", line 332, in __iter__
Mar 10 01:07:36 ubuntu hass[16808]:     yield self  # This tells Task to wait for completion.
Mar 10 01:07:36 ubuntu hass[16808]:   File "/usr/lib/python3.6/asyncio/tasks.py", line 250, in _wakeup
Mar 10 01:07:36 ubuntu hass[16808]:     future.result()
Mar 10 01:07:36 ubuntu hass[16808]:   File "/usr/lib/python3.6/asyncio/futures.py", line 245, in result
Mar 10 01:07:36 ubuntu hass[16808]:     raise self._exception
Mar 10 01:07:36 ubuntu hass[16808]:   File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
Mar 10 01:07:36 ubuntu hass[16808]:     result = self.fn(*self.args, **self.kwargs)
Mar 10 01:07:36 ubuntu hass[16808]:   File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/bmw_connected_drive.py", line 52, in setup
Mar 10 01:07:36 ubuntu hass[16808]:     bimmer = BMWConnectedDriveAccount(username, password, country, name)
Mar 10 01:07:36 ubuntu hass[16808]:   File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/bmw_connected_drive.py", line 83, in __init__
Mar 10 01:07:36 ubuntu hass[16808]:     self.account = ConnectedDriveAccount(username, password, country)
Mar 10 01:07:36 ubuntu hass[16808]:   File "/srv/homeassistant/lib/python3.6/site-packages/bimmer_connected/account.py", line 54, in __init__
Mar 10 01:07:36 ubuntu hass[16808]:     self._get_vehicles()
Mar 10 01:07:36 ubuntu hass[16808]:   File "/srv/homeassistant/lib/python3.6/site-packages/bimmer_connected/account.py", line 160, in _get_vehicles
Mar 10 01:07:36 ubuntu hass[16808]:     self._get_oauth_token()
Mar 10 01:07:36 ubuntu hass[16808]:   File "/srv/homeassistant/lib/python3.6/site-packages/bimmer_connected/account.py", line 85, in _get_oauth_token
Mar 10 01:07:36 ubuntu hass[16808]:     self._oauth_token = url_with_token['access_token'][0]
Mar 10 01:07:36 ubuntu hass[16808]: KeyError: 'access_token'

My config is

bmw_connected_drive:
  name:
    username: !secret bmw_username
    password: !secret bmw_password
    country: USA

Show value as int or float

Currently the values in state.py are shown as float of int, eg:

def mileage(self) -> float:
def max_range_electric(self) -> int:

resulting in:
screenshot_5

I would prefer to have these values all as int, but as long as these are shown consistent it's fine by me 😀

Also in some cases the get method is used:
return self._attributes.get('remainingRangeElectric')
and in some cases not:
return float(self._attributes['mileage'])

@m1n3rva shall I make a PR for this?

Add lock

A bit tricky, but it's possible to add a lock to HA which can be used to lock/unlock the car.

The most logical use case would be that you can remotely lock the car if it's not locked.

This one can also be assigned to me, as I already wrote a lock component.

Simplify usage of remote services

Using a remote service is quite ugly at the moment:

  1. you need to trigger the service
  2. you need to poll the current status until you get a final state
    1. and if we have several remote service calls in parallel, we need to check the id to get the right status of the service we just called
  3. you need to check if the status is EXECUTED or some sort of failed
  4. when locking/unlocking you need to update the vehicle state after 10 seconds or so, to get the latest state.

this is all quite complicated. It would be nice if we could wrap this in the library. but that would also mean that we need to block (synchronous case) for a while or add some asyncio features for this or both. And also that the library must then be able to notify the user of the library on updated data (callback).

Not sure what to do there...

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.