Skip to content

Commit

Permalink
test add MS600 light sensor
Browse files Browse the repository at this point in the history
  • Loading branch information
bwp91 committed Jul 20, 2024
1 parent 5d7cc5a commit 4ef8caa
Show file tree
Hide file tree
Showing 35 changed files with 319 additions and 44 deletions.
34 changes: 34 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,42 @@ export default antfu(
ignores: [],
jsx: false,
rules: {
'curly': ['error', 'multi-line'],
'new-cap': 'off',
'import/extensions': ['error', 'ignorePackages'],
'import/order': 0,
'jsdoc/check-alignment': 'warn',
'jsdoc/check-line-alignment': 'warn',
'jsdoc/require-returns-check': 0,
'jsdoc/require-returns-description': 0,
'no-undef': 'error',
'perfectionist/sort-exports': 'error',
'perfectionist/sort-imports': [
'error',
{
groups: [
'type',
'internal-type',
'builtin',
'external',
'internal',
['parent-type', 'sibling-type', 'index-type'],
['parent', 'sibling', 'index'],
'object',
'unknown',
],
order: 'asc',
type: 'natural',
},
],
'perfectionist/sort-named-exports': 'error',
'perfectionist/sort-named-imports': 'error',
'quotes': ['error', 'single'],
'sort-imports': 0,
'style/brace-style': ['error', '1tbs', { allowSingleLine: true }],
'style/quote-props': ['error', 'consistent-as-needed'],
'test/no-only-tests': 'error',
'unicorn/no-useless-spread': 'error',
'unused-imports/no-unused-vars': ['error', { caughtErrors: 'none' }],
},
typescript: false,
Expand Down
4 changes: 3 additions & 1 deletion lib/connection/http.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { createHash } from 'node:crypto'
import { Buffer } from 'node:buffer'
import { createHash } from 'node:crypto'

import axios from 'axios'

import platformConsts from '../utils/constants.js'
import {
encodeParams,
Expand Down
2 changes: 2 additions & 0 deletions lib/connection/mqtt.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { createHash } from 'node:crypto'

import { connect as mqttConnect } from 'mqtt'
import pTimeout from 'p-timeout'

import { generateRandomString } from '../utils/functions.js'
import platformLang from '../utils/lang-en.js'

Expand Down
1 change: 1 addition & 0 deletions lib/device/baby.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import PQueue from 'p-queue'
import { TimeoutError } from 'p-timeout'

import mqttClient from '../connection/mqtt.js'
import platformConsts from '../utils/constants.js'
import {
Expand Down
1 change: 1 addition & 0 deletions lib/device/cooler-single.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import PQueue from 'p-queue'
import { TimeoutError } from 'p-timeout'

import mqttClient from '../connection/mqtt.js'
import platformConsts from '../utils/constants.js'
import { hasProperty, parseError } from '../utils/functions.js'
Expand Down
1 change: 1 addition & 0 deletions lib/device/diffuser.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import PQueue from 'p-queue'
import { TimeoutError } from 'p-timeout'

import mqttClient from '../connection/mqtt.js'
import {
hk2mrRGB,
Expand Down
1 change: 1 addition & 0 deletions lib/device/fan.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import PQueue from 'p-queue'
import { TimeoutError } from 'p-timeout'

import mqttClient from '../connection/mqtt.js'
import platformConsts from '../utils/constants.js'
import {
Expand Down
15 changes: 8 additions & 7 deletions lib/device/garage-main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import PQueue from 'p-queue'
import { TimeoutError } from 'p-timeout'

import mqttClient from '../connection/mqtt.js'
import platformConsts from '../utils/constants.js'
import { hasProperty, parseError } from '../utils/functions.js'
Expand Down Expand Up @@ -142,13 +143,13 @@ export default class {
if (subAcc.context.serialNumber === this.accessory.context.serialNumber) {
subAcc.context = {
...subAcc.context,
...{
macAddress: this.accessory.context.macAddress,
hardware: this.accessory.context.hardware,
ipAddress: this.accessory.context.ipAddress,
firmware: this.accessory.context.firmware,
isOnline: this.accessory.context.isOnline,
},

macAddress: this.accessory.context.macAddress,
hardware: this.accessory.context.hardware,
ipAddress: this.accessory.context.ipAddress,
firmware: this.accessory.context.firmware,
isOnline: this.accessory.context.isOnline
,
}
this.platform.updateAccessory(subAcc)
}
Expand Down
1 change: 1 addition & 0 deletions lib/device/garage-single.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import PQueue from 'p-queue'
import { TimeoutError } from 'p-timeout'

import mqttClient from '../connection/mqtt.js'
import platformConsts from '../utils/constants.js'
import { generateRandomString, hasProperty, parseError } from '../utils/functions.js'
Expand Down
1 change: 1 addition & 0 deletions lib/device/garage-sub.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import PQueue from 'p-queue'
import { TimeoutError } from 'p-timeout'

import platformConsts from '../utils/constants.js'
import { generateRandomString, hasProperty, parseError } from '../utils/functions.js'
import platformLang from '../utils/lang-en.js'
Expand Down
1 change: 1 addition & 0 deletions lib/device/heater-single.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import PQueue from 'p-queue'
import { TimeoutError } from 'p-timeout'

import mqttClient from '../connection/mqtt.js'
import platformConsts from '../utils/constants.js'
import { hasProperty, parseError } from '../utils/functions.js'
Expand Down
15 changes: 8 additions & 7 deletions lib/device/hub-main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import PQueue from 'p-queue'
import { TimeoutError } from 'p-timeout'

import mqttClient from '../connection/mqtt.js'
import platformConsts from '../utils/constants.js'
import { hasProperty, parseError } from '../utils/functions.js'
Expand Down Expand Up @@ -173,13 +174,13 @@ export default class {
if (subAcc.context.serialNumber === this.accessory.context.serialNumber) {
subAcc.context = {
...subAcc.context,
...{
macAddress: this.accessory.context.macAddress,
hardware: this.accessory.context.hardware,
ipAddress: this.accessory.context.ipAddress,
firmware: this.accessory.context.firmware,
isOnline: this.accessory.context.isOnline,
},

macAddress: this.accessory.context.macAddress,
hardware: this.accessory.context.hardware,
ipAddress: this.accessory.context.ipAddress,
firmware: this.accessory.context.firmware,
isOnline: this.accessory.context.isOnline
,
}
this.platform.updateAccessory(subAcc)
}
Expand Down
1 change: 1 addition & 0 deletions lib/device/hub-valve.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import PQueue from 'p-queue'
import { TimeoutError } from 'p-timeout'

import platformConsts from '../utils/constants.js'
import { hasProperty, parseError } from '../utils/functions.js'
import platformLang from '../utils/lang-en.js'
Expand Down
1 change: 1 addition & 0 deletions lib/device/humidifier.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import PQueue from 'p-queue'
import { TimeoutError } from 'p-timeout'

import mqttClient from '../connection/mqtt.js'
import {
hk2mrRGB,
Expand Down
6 changes: 4 additions & 2 deletions lib/device/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ import deviceLightRGB from './light-rgb.js'
import deviceOutletMulti from './outlet-multi.js'
import deviceOutletSingle from './outlet-single.js'
import devicePowerStrip from './power-strip.js'
import devicePurifierSingle from './purifier-single.js'
import devicePurifier from './purifier.js'
import deviceRollerLocation from './roller-location.js'
import devicePurifierSingle from './purifier-single.js'
import deviceRoller from './roller.js'
import deviceRollerLocation from './roller-location.js'
import deviceSensorPresence from './sensor-presence.js'
import deviceSwitchMulti from './switch-multi.js'
import deviceSwitchSingle from './switch-single.js'
import deviceTemplate from './template.js'
Expand Down Expand Up @@ -52,6 +53,7 @@ export default {
devicePurifier,
deviceRollerLocation,
deviceRoller,
deviceSensorPresence,
deviceSwitchMulti,
deviceSwitchSingle,
deviceTemplate,
Expand Down
1 change: 1 addition & 0 deletions lib/device/light-cct.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import PQueue from 'p-queue'
import { TimeoutError } from 'p-timeout'

import mqttClient from '../connection/mqtt.js'
import { hk2mrCT, mr2hkCT } from '../utils/colour.js'
import platformConsts from '../utils/constants.js'
Expand Down
1 change: 1 addition & 0 deletions lib/device/light-dimmer.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import PQueue from 'p-queue'
import { TimeoutError } from 'p-timeout'

import mqttClient from '../connection/mqtt.js'
import platformConsts from '../utils/constants.js'
import {
Expand Down
1 change: 1 addition & 0 deletions lib/device/light-rgb.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import PQueue from 'p-queue'
import { TimeoutError } from 'p-timeout'

import mqttClient from '../connection/mqtt.js'
import {
hk2mrCT,
Expand Down
15 changes: 8 additions & 7 deletions lib/device/outlet-multi.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import PQueue from 'p-queue'
import { TimeoutError } from 'p-timeout'

import mqttClient from '../connection/mqtt.js'
import platformConsts from '../utils/constants.js'
import { hasProperty, parseError } from '../utils/functions.js'
Expand Down Expand Up @@ -265,13 +266,13 @@ export default class {
if (subAcc) {
subAcc.context = {
...subAcc.context,
...{
macAddress: this.accessory.context.macAddress,
hardware: this.accessory.context.hardware,
ipAddress: this.accessory.context.ipAddress,
firmware: this.accessory.context.firmware,
isOnline: this.accessory.context.isOnline,
},

macAddress: this.accessory.context.macAddress,
hardware: this.accessory.context.hardware,
ipAddress: this.accessory.context.ipAddress,
firmware: this.accessory.context.firmware,
isOnline: this.accessory.context.isOnline
,
}
this.platform.updateAccessory(subAcc)
}
Expand Down
1 change: 1 addition & 0 deletions lib/device/outlet-single.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import PQueue from 'p-queue'
import { TimeoutError } from 'p-timeout'

import mqttClient from '../connection/mqtt.js'
import platformConsts from '../utils/constants.js'
import { hasProperty, parseError } from '../utils/functions.js'
Expand Down
18 changes: 10 additions & 8 deletions lib/device/power-strip.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import PQueue from 'p-queue'
import { TimeoutError } from 'p-timeout'

import mqttClient from '../connection/mqtt.js'
import platformConsts from '../utils/constants.js'
import { hasProperty, parseError } from '../utils/functions.js'
Expand Down Expand Up @@ -194,13 +195,13 @@ export default class {
if (needsUpdate || firstRun) {
this.accessory.context = {
...this.accessory.context,
...{
macAddress: this.accessory.context.macAddress,
hardware: this.accessory.context.hardware,
ipAddress: this.accessory.context.ipAddress,
firmware: this.accessory.context.firmware,
isOnline: this.accessory.context.isOnline,
},

macAddress: this.accessory.context.macAddress,
hardware: this.accessory.context.hardware,
ipAddress: this.accessory.context.ipAddress,
firmware: this.accessory.context.firmware,
isOnline: this.accessory.context.isOnline
,
}
this.platform.updateAccessory(this.accessory)
}
Expand Down Expand Up @@ -251,8 +252,9 @@ export default class {

applyUpdate(data) {
data.forEach((channel) => {
if (channel.channel === 0)
if (channel.channel === 0) {
return
}

// Attempt to find the accessory this channel relates to
const { accessory } = this
Expand Down
1 change: 1 addition & 0 deletions lib/device/purifier-single.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import PQueue from 'p-queue'
import { TimeoutError } from 'p-timeout'

import mqttClient from '../connection/mqtt.js'
import platformConsts from '../utils/constants.js'
import { hasProperty, parseError } from '../utils/functions.js'
Expand Down
1 change: 1 addition & 0 deletions lib/device/purifier.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import PQueue from 'p-queue'
import { TimeoutError } from 'p-timeout'

import mqttClient from '../connection/mqtt.js'
import platformConsts from '../utils/constants.js'
import { hasProperty, parseError } from '../utils/functions.js'
Expand Down
1 change: 1 addition & 0 deletions lib/device/roller-location.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import PQueue from 'p-queue'
import { TimeoutError } from 'p-timeout'

import mqttClient from '../connection/mqtt.js'
import platformConsts from '../utils/constants.js'
import { hasProperty, parseError } from '../utils/functions.js'
Expand Down
1 change: 1 addition & 0 deletions lib/device/roller.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import PQueue from 'p-queue'
import { TimeoutError } from 'p-timeout'

import mqttClient from '../connection/mqtt.js'
import platformConsts from '../utils/constants.js'
import { hasProperty, parseError } from '../utils/functions.js'
Expand Down
Loading

0 comments on commit 4ef8caa

Please sign in to comment.