What I did for the German website:
I used the developer console from Google Chrome and observed me logging into the connected drive site. And there is one URL where the browser sends the username/password and get the “access_token” back in the header of the response.
What I would need are examples of:
the url that the login request is sent to
an example of the request header (to see if the format is the same)
an example of the response header (to see if the format is the same)
I can’t analyze that as I can’t create a Canadian Connected Drive account without a Canadian vehicle…
The problem here is that obviously the US and Canadian Connected Drive portals are using a different URL to login via username/password. So i need someone with such an account to figure out the parameters (see my comment above: BMW ConnectedDrive component)
This should be fixed in HA 0.64.2 which is just released.
That’s already the case
When the door_lock_state is LOCKED or SECURED:
The lock (switch) has a locked icon
The status of the binary sensor ‘Door lock state’ is shown as Safe
When the door_lock_state is SELECTIVELOCKED or UNLOCKED:
The lock (switch) has an unlocked icon
The status of the binary sensor ‘Door lock state’ is shown as Unsafe
I see you don’t have that binary sensor in your group, but it’s already available, so you can add that.
Quickest way to find all sensors available for your car is to go to Developer tools - States and go to Filter attributes where you can enter the type of your car, in your case X1 sDrive18d.
You can add control: hidden to your BMW X1 Group so no On/Off switch is shown in the header, which will avoid you to accidentally switch on the horn, lights and climate at the same time
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.6/asyncio/tasks.py", line 180, in _step
result = coro.send(None)
File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 223, in async_update_ha_state
device_attr = self.device_state_attributes
File "/config/custom_components/switch/bmw_connected_drive.py", line 69, in device_state_attributes
'last_update': vehicle_state.timestamp,
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!
2018-03-02 08:43:13 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
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 91, in timestamp
unix_time = int(self._attributes['updateTime_converted_timestamp'])
KeyError: 'updateTime_converted_timestamp'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.6/asyncio/tasks.py", line 180, in _step
result = coro.send(None)
File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 223, in async_update_ha_state
device_attr = self.device_state_attributes
File "/config/custom_components/switch/bmw_connected_drive.py", line 69, in device_state_attributes
'last_update': vehicle_state.timestamp,
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!
You are using the custom component, that version is not changed yet.
Either remove the custom component so you can use the updated version in 0.64.2 or wait until I have updated the custom component.
Edit: the custom component is bumped to bimmer_connected v0.41.
Can you open the BMW ConnectedDrive app and after that check if HA shows recent data?
Some older cars don’t seem to support auto refresh of the data. See this post BMW ConnectedDrive component.
@coolTNT
Thx for the analysis. The request and response look quite different from the one from Europe. What I’m missing is the access_token in the Location attribute. This token is then used in the authentication of the API calls. So it seems this is done differently in the Canadian site
Maybe this is related to the vehicle. In my last vehicle, I had to push the “update position” icon in the BMW connected drive portal. Only then it would update the position after waiting for some time.
Only the later generations of the head units seem to upload the position automatically after parking the car.
I have a 2016 F36 (440i Gran Coupe). It only has ID4 so I wonder if that is the problem, perhaps you need ID5 or 6 for this to work properly? Damn BMW for superseding its software so quick!
I haven’t gotten around to trying any remote services yet, but will try to find out what the REMOTE_SERVICE_URL is soon.
To try these URLs I would just have to put them into bimmer_connected/const.py right?
Update: I tried it, it doesn’t work. I think it’s because the Canadian site sends the access token back as a JSON in the response, which I think removes the need to use 'redirect_uri': 'https://www.bmw-connecteddrive.com/app/default/static/external-dispatch.html', and self._oauth_token = url_with_token['access_token'][0]
Below is the first packet sent/recieved by the BMW Remote app on first startup, after the login button is pressed.