bimmerconnected / bimmer_connected

🚘 Library to query the status of your BMW or Mini from the ConnectedDrive portal
Apache License 2.0
364 stars 79 forks source link

2013 BMW 325D (F30) #95

Closed plaksnor closed 5 years ago

plaksnor commented 5 years ago

Hi all,

Looking forward to get bimmer_connected working in Home Assistant, so I started reading some threads but I'm not able to get it working.

Bimmer_connected:

$ pip3 install --upgrade bimmer_connected
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already up-to-date: bimmer_connected in /usr/local/lib/python3.5/dist-packages (0.5.3)
Requirement already satisfied, skipping upgrade: typing<4,>=3 in /usr/local/lib/python3.5/dist-packages (from bimmer_connected) (3.6.6)
Requirement already satisfied, skipping upgrade: requests in ./.local/lib/python3.5/site-packages (from bimmer_connected) (2.19.1)
Requirement already satisfied, skipping upgrade: chardet<3.1.0,>=3.0.2 in ./.local/lib/python3.5/site-packages (from requests->bimmer_connected) (3.0.4)
Requirement already satisfied, skipping upgrade: idna<2.8,>=2.5 in ./.local/lib/python3.5/site-packages (from requests->bimmer_connected) (2.7)
Requirement already satisfied, skipping upgrade: certifi>=2017.4.17 in ./.local/lib/python3.5/site-packages (from requests->bimmer_connected) (2018.8.24)
Requirement already satisfied, skipping upgrade: urllib3<1.24,>=1.21.1 in ./.local/lib/python3.5/site-packages (from requests->bimmer_connected) (1.23)

Fingerprint:

$ sudo bimmerconnected fingerprint XXXXXXXXXXXXX XXXXXXXXXXXXX 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:443
DEBUG:urllib3.connectionpool:https://b2vapi.bmwgroup.com:443 "POST /gcdm/oauth/token HTTP/1.1" 200 None
DEBUG:bimmer_connected.account:got new token 5dFzGZZsgOMG365YN2ysaDzdsTWz7joq with expiration date 2018-10-17 10:29:42.923715
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:443
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:443
DEBUG:urllib3.connectionpool:https://b2vapi.bmwgroup.com:443 "GET /webapi/v1/user/vehicles/XXXXXXXXXXXXX/status?dlat=0.0&deviceTime=2018-10-17T09%3A29%3A44&dlon=0.0 HTTP/1.1" 200 None
DEBUG:bimmer_connected.state:received new data from connected drive
fingerprint of the vehicles written to /usr/local/bin/vehicle_fingerprint/2018-10-17_09-29-43

status_0.txt:

$ more status_0.txt
{
  "vehicleStatus": {
    "DCS_CCH_Activation": "NA",
    "DCS_CCH_Ongoing": false,
    "position": {
      "status": "TOO_FAR_AWAY"
    },
    "steering": "LH",
    "updateTime": "2018-10-17T09:08:48+0200",
    "vehicleCountry": "NL",
    "vin": "some_vin"
  }
}

vehicles_0.txt:

$ more vehicles_0.txt
{
  "vehicles": [
    {
      "a4a": "USB_ONLY",
      "bodytype": "F30",
      "brand": "BMW",
      "breakdownNumber": "+4989358957103",
      "carCloud": "NOT_SUPPORTED",
      "chargeNow": "NOT_SUPPORTED",
      "chargingControl": "NOT_SUPPORTED",
      "climateControl": "START_TIMER",
      "climateControlRES": "NOT_SUPPORTED",
      "climateFunction": "VENTILATION",
      "climateNow": "ACTIVATED",
      "climateNowRES": "NOT_SUPPORTED",
      "color": "BLACK SAPPHIRE METALLIC",
      "colorCode": "475",
      "countryCode": "V1-NL",
      "dealer": {
        "city": "XXXXXXXXXXXXXXX",
        "country": "NL",
        "name": "XXXXXXXXXXXXXXX",
        "phone": "XXXXXXXXXXXXXXX",
        "postalCode": "XXXXXXXXXXXXXXX",
        "street": "XXXXXXXXXXXXXXX"
      },
      "doorLock": "ACTIVATED",
      "doorUnlock": "ACTIVATED",
      "driveTrain": "CONV",
      "fuelType": "DIESEL",
      "hasAlarmSystem": false,
      "hmiVersion": "ID4",
      "hornBlow": "ACTIVATED",
      "hub": "HUB_ECE",
      "intermodalRouting": "NOT_AVAILABLE",
      "ipa": "NOT_SUPPORTED",
      "lastDestinations": "NOT_SUPPORTED",
      "lightFlash": "ACTIVATED",
      "lscType": "NOT_SUPPORTED",
      "model": "325d",
      "onlineSearchMode": "MAP",
      "onlineSearchProvider": "GOOGLE",
      "rangeMap": "NOT_SUPPORTED",
      "remote360": "NOT_SUPPORTED",
      "remoteSoftwareUpgrade": "NOT_SUPPORTED",
      "sendPoi": "ACTIVATED",
      "smartSolution": "NOT_SUPPORTED",
      "statisticsAvailable": false,
      "statisticsCommunityEnabled": false,
      "steering": "LH",
      "vehicleFinder": "ACTIVATED",
      "vin": "some_vin",
      "yearOfConstruction": 2013
    }
  ]
}

Note:

$ sudo bimmerconnected status XXXXXXXXXXXXXXX XXXXXXXXXXXXXXX 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:443
DEBUG:urllib3.connectionpool:https://b2vapi.bmwgroup.com:443 "POST /gcdm/oauth/token HTTP/1.1" 200 None
DEBUG:bimmer_connected.account:got new token WqfjSXprWElyQE0Ut14633rLsdnLHB4n with expiration date 2018-10-17 10:41:27.252552
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:443
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:443
DEBUG:urllib3.connectionpool:https://b2vapi.bmwgroup.com:443 "GET /webapi/v1/user/vehicles/XXXXXXXXXXXXXXX/status?dlat=0.0&dlon=0.0&deviceTime=2018-10-17T09%3A41%3A27 HTTP/1.1" 200 None
DEBUG:bimmer_connected.state:received new data from connected drive
Found 1 vehicles: 325d
VIN: XXXXXXXXXXXXXXX
DEBUG:bimmer_connected.state:No data available for attribute <function VehicleState.mileage at 0x75e06d20>!
mileage: None
vehicle properties:
{
    "countryCode": "V1-NL",
    "model": "325d",
    "fuelType": "DIESEL",
    "rangeMap": "NOT_SUPPORTED",
    "bodytype": "F30",
    "climateNow": "ACTIVATED",
    "colorCode": "475",
    "a4a": "USB_ONLY",
    "doorUnlock": "ACTIVATED",
    "yearOfConstruction": 2013,
    "vehicleFinder": "ACTIVATED",
    "color": "BLACK SAPPHIRE METALLIC",
    "steering": "LH",
    "carCloud": "NOT_SUPPORTED",
    "vin": "XXXXXXXXXXXXXXX",
    "sendPoi": "ACTIVATED",
    "onlineSearchProvider": "GOOGLE",
    "breakdownNumber": "+4989358957103",
    "climateControlRES": "NOT_SUPPORTED",
    "onlineSearchMode": "MAP",
    "chargeNow": "NOT_SUPPORTED",
    "chargingControl": "NOT_SUPPORTED",
    "smartSolution": "NOT_SUPPORTED",
    "climateFunction": "VENTILATION",
    "intermodalRouting": "NOT_AVAILABLE",
    "dealer": {
        "city": "XXXXXXXXXXXXXXX",
        "phone": "XXXXXXXXXXXXXXX",
        "postalCode": "XXXXXXXXXXXXXXX",
        "street": "XXXXXXXXXXXXXXX",
        "name": "XXXXXXXXXXXXXXX",
        "country": "XXXXXXXXXXXXXXX"
    },
    "statisticsAvailable": false,
    "brand": "BMW",
    "driveTrain": "CONV",
    "lscType": "NOT_SUPPORTED",
    "statisticsCommunityEnabled": false,
    "remoteSoftwareUpgrade": "NOT_SUPPORTED",
    "hasAlarmSystem": false,
    "lastDestinations": "NOT_SUPPORTED",
    "ipa": "NOT_SUPPORTED",
    "hub": "HUB_ECE",
    "doorLock": "ACTIVATED",
    "hmiVersion": "ID4",
    "remote360": "NOT_SUPPORTED",
    "climateControl": "START_TIMER",
    "climateNowRES": "NOT_SUPPORTED",
    "lightFlash": "ACTIVATED",
    "hornBlow": "ACTIVATED"
}
vehicle status:
{
    "steering": "LH",
    "updateTime": "2018-10-17T09:08:48+0200",
    "vin": "XXXXXXXXXXXXXXX",
    "DCS_CCH_Activation": "NA",
    "position": {
        "status": "TOO_FAR_AWAY"
    },
    "vehicleCountry": "NL",
    "DCS_CCH_Ongoing": false
}

In Home Assistant (0.80.1) I have the following configuration.

configuration.yaml (stripped:)

bmw_connected_drive:
  name:
    username: !secret bmw_username
    password: !secret bmw_password
    region: "rest_of_world"

home_assistant.log:

2018-10-17 08:46:25 INFO (MainThread) [homeassistant.setup] Setup of domain bmw_connected_drive took 4.2 seconds.
2018-10-17 08:46:25 INFO (MainThread) [homeassistant.loader] Loaded sensor.bmw_connected_drive from homeassistant.components.sensor.bmw_connected_drive
2018-10-17 08:46:25 INFO (MainThread) [homeassistant.loader] Loaded binary_sensor.bmw_connected_drive from homeassistant.components.binary_sensor.bmw_connected_d
rive
2018-10-17 08:46:25 INFO (MainThread) [homeassistant.setup] Setting up lock
2018-10-17 08:46:25 INFO (MainThread) [homeassistant.setup] Setup of domain lock took 0.0 seconds.
2018-10-17 08:46:25 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.bmw_connected_drive
2018-10-17 08:46:25 INFO (MainThread) [homeassistant.components.binary_sensor] Setting up binary_sensor.bmw_connected_drive
2018-10-17 08:46:25 INFO (MainThread) [homeassistant.loader] Loaded lock.bmw_connected_drive from homeassistant.components.lock.bmw_connected_drive
2018-10-17 08:46:25 INFO (MainThread) [homeassistant.components.lock] Setting up lock.bmw_connected_drive
2018-10-17 08:46:25 ERROR (MainThread) [homeassistant.components.binary_sensor] bmw_connected_drive: Error on device update!
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity_platform.py", line 251, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity.py", line 349, in async_device_update
    await self.hass.async_add_job(self.update)
  File "/usr/lib/python3.5/asyncio/futures.py", line 380, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup
    future.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
    raise self._exception
  File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/binary_sensor/bmw_connected_drive.py", line 166, in update
    self._state = vehicle_state.has_check_control_messages
  File "/srv/homeassistant/lib/python3.5/site-packages/bimmer_connected/state.py", line 71, in _func_wrapper
    return func(self, *args, **kwargs)
  File "/srv/homeassistant/lib/python3.5/site-packages/bimmer_connected/state.py", line 326, in has_check_control_messages
    return len(self.check_control_messages) > 0
TypeError: object of type 'NoneType' has no len()
2018-10-17 08:46:25 ERROR (MainThread) [homeassistant.components.binary_sensor] bmw_connected_drive: Error on device update!
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity_platform.py", line 251, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity.py", line 349, in async_device_update
    await self.hass.async_add_job(self.update)
  File "/usr/lib/python3.5/asyncio/futures.py", line 380, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup
    future.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
    raise self._exception
  File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/binary_sensor/bmw_connected_drive.py", line 164, in update
    self._state = not vehicle_state.are_all_cbs_ok
  File "/srv/homeassistant/lib/python3.5/site-packages/bimmer_connected/state.py", line 231, in are_all_cbs_ok
    for cbs in self.condition_based_services:
TypeError: 'NoneType' object is not iterable
2018-10-17 08:46:25 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step
    result = coro.send(None)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity_platform.py", line 354, in _async_add_entity
    await entity.async_update_ha_state()
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity.py", line 240, in async_update_ha_state
    device_attr = self.device_state_attributes
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/lock/bmw_connected_drive.py", line 69, in device_state_attributes
    'door_lock_state': vehicle_state.door_lock_state.value
AttributeError: 'NoneType' object has no attribute 'value'
2018-10-17 08:46:25 INFO (Thread-5) [homeassistant.components.device_tracker.nmap_tracker] nmap scan successful
2018-10-17 08:46:25 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step
    result = coro.send(None)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity_platform.py", line 354, in _async_add_entity
    await entity.async_update_ha_state()
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity.py", line 240, in async_update_ha_state
    device_attr = self.device_state_attributes
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/binary_sensor/bmw_connected_drive.py", line 114, in device_state_attributes
    result['door_lock_state'] = vehicle_state.door_lock_state.value
AttributeError: 'NoneType' object has no attribute 'value'
2018-10-17 08:46:25 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step
    result = coro.send(None)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity_platform.py", line 354, in _async_add_entity
    await entity.async_update_ha_state()
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity.py", line 240, in async_update_ha_state
    device_attr = self.device_state_attributes
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/binary_sensor/bmw_connected_drive.py", line 117, in device_state_attributes
    result['lights_parking'] = vehicle_state.parking_lights.value
AttributeError: 'NoneType' object has no attribute 'value'
2018-10-17 08:46:44 INFO (MainThread) [homeassistant.setup] Setup of domain device_tracker took 22.4 seconds.
2018-10-17 08:46:44 INFO (MainThread) [homeassistant.loader] Loaded device_tracker.bmw_connected_drive from homeassistant.components.device_tracker.bmw_connected
_drive
2018-10-17 08:46:44 INFO (MainThread) [homeassistant.components.device_tracker] Setting up device_tracker.bmw_connected_drive
2018-10-17 08:46:44 INFO (MainThread) [homeassistant.bootstrap] Home Assistant initialized in 27.10s

Is anyone able to guide me further through the process to get this working? If you need any more information, please let me know.

gerard33 commented 5 years ago

See https://community.home-assistant.io/t/bmw-connecteddrive-component/39569/310.

gerard33 commented 5 years ago

See also #96.

m1n3rva commented 5 years ago

@plaksnor Your vehicle 🚘 just does not send much useful data to the server (see your Status.txt), so there is not much to show in Home Assistant. I'm sorry, but there is not much that we can do here 😭

lock[bot] commented 4 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.