Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No status available #2

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# These are supported funding model platforms

github: chrisloftus # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
27 changes: 17 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = function(homebridge) {
Service = homebridge.hap.Service;
Characteristic = homebridge.hap.Characteristic;

homebridge.registerAccessory("homebridge-bmw-connected", "BMWConnected", BMWConnected);
homebridge.registerAccessory("@chrisloftus/homebridge-bmw-connected", "BMWConnected", BMWConnected);
}

function BMWConnected(log, config) {
Expand Down Expand Up @@ -93,7 +93,7 @@ BMWConnected.prototype.getExecution = function(callback) {
var complete = 0;

requestretry.get({
url: 'https://www.bmw-connecteddrive.co.uk/api/vehicle/remoteservices/v1/' + this.vin + '/state/execution',
url: 'https://www.bmw-connecteddrive.co.uk/remoteservices/rsapi/v1/' + this.vin + '/state/execution',
headers: {
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_1_1 like Mac OS X) AppleWebKit/604.3.5 (KHTML, like Gecko) Version/11.0 Mobile/15B150 Safari/604.1',
'Authorization': 'Bearer ' + this.authToken,
Expand Down Expand Up @@ -122,10 +122,10 @@ BMWConnected.prototype.getExecution = function(callback) {
function myRetryStrategy(err, response, body){
// retry the request if we had an error or if the response was a 'Bad Gateway'
var json = JSON.parse(body);
var commandtype = (json["remoteServiceType"]);
var execution = (json["remoteServiceStatus"]);
// var commandtype = (json["remoteServiceType"]);
var execution = (json["event"]["rsEventStatus"]);

return err || execution === "PENDING" || execution ==="DELIVERED_TO_VEHICLE"
return err || execution === "PENDING" || execution === "RUNNING"
}


Expand All @@ -138,12 +138,19 @@ BMWConnected.prototype.setState = function(state, callback) {
callback(err);
}

// console.log('authtoken', this.authToken)

var setStateUrl = 'https://www.bmw-connecteddrive.co.uk/remoteservices/rsapi/v1/' + this.vin + '/' + bmwState

request.post({
url: 'https://customer.bmwgroup.com/api/vehicle/remoteservices/v1/' + this.vin +'/' + bmwState,
headers: {
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_1_1 like Mac OS X) AppleWebKit/604.3.5 (KHTML, like Gecko) Version/11.0 Mobile/15B150 Safari/604.1',
'Authorization': 'Bearer ' + this.authToken,
}
url: setStateUrl,
headers: {
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_1_1 like Mac OS X) AppleWebKit/604.3.5 (KHTML, like Gecko) Version/11.0 Mobile/15B150 Safari/604.1',
'Authorization': 'Bearer ' + this.authToken,
},
json: {
clientId: 3
}
}, function(err, response, body) {

if (!err && response.statusCode == 200) {
Expand Down
Loading