Skip to content

Commit

Permalink
update cert
Browse files Browse the repository at this point in the history
  • Loading branch information
TA2k committed Sep 18, 2023
1 parent f4ab91d commit 59012a6
Show file tree
Hide file tree
Showing 10 changed files with 700 additions and 1,496 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.prettierrc.js
**/.eslintrc.js
20 changes: 11 additions & 9 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
"node": true,
"mocha": true
},
"extends": [
"eslint:recommended"
],
"extends": ["eslint:recommended"],
"plugins": [],
"rules": {
"indent": [
Expand All @@ -18,6 +16,13 @@
}
],
"no-console": "off",
"no-unused-vars": [
"error",
{
"ignoreRestSiblings": true,
"argsIgnorePattern": "^_"
}
],
"no-var": "error",
"no-trailing-spaces": "error",
"prefer-const": "error",
Expand All @@ -29,12 +34,9 @@
"allowTemplateLiterals": true
}
],
"semi": [
"error",
"always"
]
"semi": ["error", "always"]
},
"parserOptions": {
"ecmaVersion": 2018
"ecmaVersion": 2020
}
}
}
70 changes: 35 additions & 35 deletions .github/workflows/test-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,48 +3,48 @@ name: Test and Release
# Run this job on all pushes and pull requests
# as well as tags with a semantic version
on:
push:
branches:
- "master"
tags:
# normal versions
- "v[0-9]+.[0-9]+.[0-9]+"
# pre-releases
- "v[0-9]+.[0-9]+.[0-9]+-**"
pull_request: {}
push:
branches:
- "master"
tags:
# normal versions
- "v[0-9]+.[0-9]+.[0-9]+"
# pre-releases
- "v[0-9]+.[0-9]+.[0-9]+-**"
pull_request: {}

jobs:
# Performs quick checks before the expensive test runs
check-and-lint:
if: contains(github.event.head_commit.message, '[skip ci]') == false
# Performs quick checks before the expensive test runs
check-and-lint:
if: contains(github.event.head_commit.message, '[skip ci]') == false

runs-on: ubuntu-latest
runs-on: ubuntu-latest

steps:
- uses: ioBroker/testing-action-check@v1
with:
node-version: "14.x"
# Uncomment the following line if your adapter cannot be installed using 'npm ci'
# install-command: 'npm install'
lint: true
steps:
- uses: ioBroker/testing-action-check@v1
with:
node-version: "20.x"
# Uncomment the following line if your adapter cannot be installed using 'npm ci'
# install-command: 'npm install'
lint: true

# Runs adapter tests on all supported node versions and OSes
adapter-tests:
if: contains(github.event.head_commit.message, '[skip ci]') == false
# Runs adapter tests on all supported node versions and OSes
adapter-tests:
if: contains(github.event.head_commit.message, '[skip ci]') == false

runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [18.x, 14.x, 16.x]
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [18.x, 20.x, 16.x]
os: [ubuntu-latest, windows-latest, macos-latest]

steps:
- uses: ioBroker/testing-action-adapter@v1
with:
node-version: ${{ matrix.node-version }}
os: ${{ matrix.os }}
# Uncomment the following line if your adapter cannot be installed using 'npm ci'
# install-command: 'npm install'
steps:
- uses: ioBroker/testing-action-adapter@v1
with:
node-version: ${{ matrix.node-version }}
os: ${{ matrix.os }}
# Uncomment the following line if your adapter cannot be installed using 'npm ci'
# install-command: 'npm install'
# TODO: To enable automatic npm releases, create a token on npmjs.org
# Enter this token as a GitHub secret (with name NPM_TOKEN) in the repository options
# Then uncomment the following block:
Expand Down
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
package.json
package-lock.json
9 changes: 9 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
semi: true,
trailingComma: "all",
singleQuote: false,
printWidth: 140,
useTabs: false,
tabWidth: 2,
endOfLine: "lf",
};
Binary file modified certs/mwp.dat
Binary file not shown.
5 changes: 4 additions & 1 deletion io-package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
{
"common": {
"name": "psa",
"version": "0.0.11",
"version": "0.0.12",
"news": {
"0.0.12": {
"en": "update old api certificate"
},
"0.0.11": {
"en": "add new api"
},
Expand Down
62 changes: 35 additions & 27 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// The adapter-core module gives you access to the core ioBroker functions
// you need to create an adapter
const utils = require("@iobroker/adapter-core");
const axios = require("axios");
const axios = require("axios").default;
const https = require("https");
const fs = require("fs");
const { extractKeys } = require("./lib/extractKeys");
Expand All @@ -22,15 +22,7 @@ class Psa extends utils.Adapter {
name: "psa",
});
this.on("ready", this.onReady.bind(this));
// this.on("stateChange", this.onStateChange.bind(this));
this.on("unload", this.onUnload.bind(this));
}

/**
* Is called when databases are connected and adapter received configuration.
*/
async onReady() {
// Initialize your adapter here

this.extractKeys = extractKeys;
this.idArray = [];
Expand Down Expand Up @@ -72,6 +64,14 @@ class Psa extends utils.Adapter {
url: "mw-op-rp.mym.awsmpsa.com",
},
};
}

/**
* Is called when databases are connected and adapter received configuration.
*/
async onReady() {
// Initialize your adapter here

if (!this.config.type) {
this.log.warn("Please select type in settings");
return;
Expand All @@ -93,24 +93,26 @@ class Psa extends utils.Adapter {
this.getVehicles()
.then(() => {
this.idArray.forEach((element) => {
this.getRequest("https://api.groupe-psa.com/connectedcar/v4/user/vehicles/" + element.id + "/status", element.vin + ".status").catch(
() => {
this.log.error("Get device status failed");
this.log.info("Remove device " + element.vin + " from list");
const index = this.idArray.indexOf(element);
if (index !== -1) {
this.idArray.splice(index, 1);
}
this.getRequest(
"https://api.groupe-psa.com/connectedcar/v4/user/vehicles/" + element.id + "/status",
element.vin + ".status",
).catch(() => {
this.log.error("Get device status failed");
this.log.info("Remove device " + element.vin + " from list");
const index = this.idArray.indexOf(element);
if (index !== -1) {
this.idArray.splice(index, 1);
}
);
});
});
this.appUpdateInterval = setInterval(() => {
this.idArray.forEach((element) => {
this.getRequest("https://api.groupe-psa.com/connectedcar/v4/user/vehicles/" + element.id + "/status", element.vin + ".status").catch(
() => {
this.log.error("Get device status failed");
}
);
this.getRequest(
"https://api.groupe-psa.com/connectedcar/v4/user/vehicles/" + element.id + "/status",
element.vin + ".status",
).catch(() => {
this.log.error("Get device status failed");
});
});
}, this.config.interval * 60 * 1000);
})
Expand Down Expand Up @@ -370,7 +372,11 @@ class Psa extends utils.Adapter {
});
const data = JSON.stringify({ site_code: this.brands[this.config.type].siteCode, ticket: this.oldAToken });
const url =
"https://" + this.brands[this.config.type].url + "/api/v1/user?culture=de_DE&width=1080&cgu=" + parseInt(Date.now() / 1000) + "&v=1.29.3";
"https://" +
this.brands[this.config.type].url +
"/api/v1/user?culture=de_DE&width=1080&cgu=" +
parseInt(Date.now() / 1000) +
"&v=1.29.3";
this.log.debug(url);
this.log.debug(data);
axios({
Expand Down Expand Up @@ -500,9 +506,11 @@ class Psa extends utils.Adapter {
native: {},
});

this.getRequest("https://api.groupe-psa.com/connectedcar/v4/user/vehicles/" + element.id, element.vin + ".details").catch(() => {
this.log.error("Get Details failed");
});
this.getRequest("https://api.groupe-psa.com/connectedcar/v4/user/vehicles/" + element.id, element.vin + ".details").catch(
() => {
this.log.error("Get Details failed");
},
);
});
resolve();
})
Expand Down
Loading

0 comments on commit 59012a6

Please sign in to comment.