Style and minor cleanup
I didn't like the previous linting setup where eslint and prettier were arguing, so for now just sticking with eslint.
This commit is contained in:
@ -1,11 +1,12 @@
|
||||
{
|
||||
"extends": "airbnb-base",
|
||||
"rules": {
|
||||
"comma-dangle": 0,
|
||||
"indent": [2, 4],
|
||||
"max-len": [2, 120, { "ignoreStrings": true }],
|
||||
"max-len": "off",
|
||||
"radix": [2, "as-needed"],
|
||||
"no-console": 0
|
||||
"no-console": 0,
|
||||
"linebreak-style": "off",
|
||||
"prettier/prettier": 0
|
||||
},
|
||||
"settings": {
|
||||
"import/core-modules": [ "node_helper" ]
|
||||
|
10
MMM-MyQ.js
10
MMM-MyQ.js
@ -7,9 +7,8 @@
|
||||
|
||||
Module.register('MMM-MyQ', {
|
||||
defaults: {
|
||||
colored: false,
|
||||
email: 'email',
|
||||
password: 'password',
|
||||
email: '',
|
||||
password: '',
|
||||
types: ['wifigaragedooropener'],
|
||||
updateInterval: 5 * 60 * 1000 // every 5 minutes
|
||||
},
|
||||
@ -49,10 +48,7 @@ Module.register('MMM-MyQ', {
|
||||
|
||||
table.appendChild(this.createLabelRow());
|
||||
|
||||
const max = Math.min(
|
||||
this.rotateIndex + this.config.matches,
|
||||
this.scores.length
|
||||
);
|
||||
const max = Math.min(this.rotateIndex + this.config.matches, this.scores.length);
|
||||
for (let i = this.rotateIndex; i < max; i += 1) {
|
||||
this.appendDataRow(this.scores[i], table);
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ MyQ module for MagicMirror²
|
||||
position: 'top_right',
|
||||
config: {
|
||||
email: 'you@example.com',
|
||||
password: 'correct horse battery stapler'
|
||||
password: 'correct horse battery staple'
|
||||
}
|
||||
}
|
||||
```
|
||||
|
@ -5,10 +5,8 @@
|
||||
* MIT Licensed.
|
||||
*/
|
||||
|
||||
/* eslint-env node */
|
||||
|
||||
const NodeHelper = require('node_helper');
|
||||
const { myQ, _ } = require('myq-api');
|
||||
const { myQ } = require('myq-api');
|
||||
|
||||
module.exports = NodeHelper.create({
|
||||
start() {
|
||||
@ -19,11 +17,9 @@ module.exports = NodeHelper.create({
|
||||
if (notification === 'MYQ_CONFIG') {
|
||||
this.config = payload;
|
||||
this.account = new myQ(this.config.email, this.config.password);
|
||||
console.log('config received');
|
||||
this.account
|
||||
.login()
|
||||
|
||||
this.account.login()
|
||||
.then((result) => {
|
||||
console.log('login complete');
|
||||
if (result.returnCode !== 0) {
|
||||
throw new Error('login failure');
|
||||
}
|
||||
@ -32,8 +28,8 @@ module.exports = NodeHelper.create({
|
||||
this.getData();
|
||||
})
|
||||
.catch((err) => {
|
||||
this.sendSocketNotification('MYQ_ERROR');
|
||||
console.error(`login error: ${err}`);
|
||||
this.sendSocketNotification('MYQ_ERROR', {context: 'login', err});
|
||||
console.error(`myq login error: ${err}`);
|
||||
});
|
||||
|
||||
setInterval(() => {
|
||||
@ -43,35 +39,28 @@ module.exports = NodeHelper.create({
|
||||
},
|
||||
|
||||
getData() {
|
||||
console.log('retrieving devices');
|
||||
this.account
|
||||
.getDevices()
|
||||
this.account.getDevices()
|
||||
.then((result) => {
|
||||
console.log('devices retrieved');
|
||||
result.devices.forEach((device) => {
|
||||
if (this.config.types.includes(device.type)) {
|
||||
this.sendSocketNotification('MYQ_DEVICE_FOUND', device);
|
||||
|
||||
console.log('getting door state');
|
||||
console.log(device);
|
||||
this.account
|
||||
.getDoorState(device.serialNumber)
|
||||
this.account.getDoorState(device.serialNumber)
|
||||
.then((state) => {
|
||||
console.log('state');
|
||||
console.log(state);
|
||||
if (state.returnCode === 0) {
|
||||
this.sendSocketNotification(
|
||||
'MYQ_DEVICE_STATE',
|
||||
{ device, state }
|
||||
);
|
||||
this.sendSocketNotification('MYQ_DEVICE_STATE', { device, state });
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
})
|
||||
.catch((err) => {
|
||||
this.sendSocketNotification('MYQ_ERROR');
|
||||
console.error(`getData error: ${err}`);
|
||||
this.sendSocketNotification('MYQ_ERROR', {context: 'getDevices', err});
|
||||
console.error(`myQ getDevices error: ${err}`);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
2364
package-lock.json
generated
2364
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
10
package.json
10
package.json
@ -3,7 +3,7 @@
|
||||
"version": "1.0.0",
|
||||
"description": "MyQ module for MagicMirror2",
|
||||
"scripts": {
|
||||
"lint": "./node_modules/.bin/eslint . && ./node_modules/.bin/stylelint ."
|
||||
"lint": "./node_modules/.bin/eslint ."
|
||||
},
|
||||
"repository": "github:parnic/MMM-MyQ",
|
||||
"keywords": [
|
||||
@ -19,13 +19,9 @@
|
||||
},
|
||||
"homepage": "https://github.com/parnic/MMM-MyQ#readme",
|
||||
"devDependencies": {
|
||||
"eslint": "^7.7.0",
|
||||
"eslint-config-airbnb-base": "^14.2.0",
|
||||
"eslint-plugin-import": "^2.2.0",
|
||||
"stylelint": "^13.6.1",
|
||||
"stylelint-config-standard": "^20.0.0"
|
||||
"eslint": "^7.7.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"myq-api": "parnic/myq-api#9402fed007a9039b06d5b73c6fa6138cae2723d5"
|
||||
"myq-api": "github:parnic/myq-api#9402fed007a9039b06d5b73c6fa6138cae2723d5"
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user