Skip to content
This repository has been archived by the owner on Nov 14, 2023. It is now read-only.

Commit

Permalink
Update to latest MyQ API
Browse files Browse the repository at this point in the history
This required some changes to how we were loading the MyQ library since it's now only supporting modules.

Add a region when logging into MyQ since the 'east' region seems to be more reliable, based on issues filed in the myq library repo.

Improve behavior when multiple clients load against the same server: no longer logging in multiple times.

Update eslint to latest and github actions to test against modern nodejs versions (Magic Mirror requires Node 18).
  • Loading branch information
parnic committed Sep 13, 2023
1 parent 5673758 commit 71bd450
Show file tree
Hide file tree
Showing 5 changed files with 842 additions and 772 deletions.
10 changes: 6 additions & 4 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@
"radix": [2, "as-needed"],
"no-console": 0,
"linebreak-style": "off",
"prettier/prettier": 0
"prettier/prettier": 0,
"quotes": ["error", "single"],
"jsdoc/require-jsdoc": 0
},
"settings": {
"import/core-modules": [ "node_helper" ]
},
"env": {
"browser": true,
"node": true,
"es6": true
"es2017": true
},
"parserOptions": {
"ecmaVersion": 8
"ecmaVersion": "latest"
}
}
}
2 changes: 1 addition & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

strategy:
matrix:
node-version: [10.x, 12.x, 14.x, 16.x]
node-version: [16.x, 18.x, 20.x]

steps:
- uses: actions/checkout@v3
Expand Down
10 changes: 6 additions & 4 deletions node_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/

const NodeHelper = require('node_helper');
const MyQ = require('@hjdhjd/myq');

module.exports = NodeHelper.create({
_customActions: {
Expand All @@ -28,10 +27,13 @@ module.exports = NodeHelper.create({
}, this.config.updateInterval);
},

socketNotificationReceived(notification, payload) {
async socketNotificationReceived(notification, payload) {
if (notification === 'MYQ_CONFIG') {
this.config = payload;
this.account = new MyQ.myQApi(this.config.email, this.config.password);
if (!this.config) {
this.config = payload;
const MyQ = await import('@hjdhjd/myq');
this.account = new MyQ.myQApi(this.config.email, this.config.password, null, 'east');
}
this.sendSocketNotification('MYQ_LOGGED_IN', this._customActions);
this.getData();
} else if (this.config) {
Expand Down
Loading

0 comments on commit 71bd450

Please sign in to comment.