Skip to content

Commit

Permalink
Merge pull request #557 from johannrichard/alpha
Browse files Browse the repository at this point in the history
Prepare beta release
  • Loading branch information
johannrichard authored Dec 27, 2022
2 parents 5e6fea1 + 0125d96 commit 1b98801
Show file tree
Hide file tree
Showing 8 changed files with 692 additions and 854 deletions.
510 changes: 263 additions & 247 deletions .yarn/releases/yarn-3.3.0.cjs → .yarn/releases/yarn-3.3.1.cjs

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
checksumBehavior: update

nodeLinker: node-modules

plugins:
Expand All @@ -8,4 +10,4 @@ plugins:
- path: .yarn/plugins/@yarnpkg/plugin-version.cjs
spec: "@yarnpkg/plugin-version"

yarnPath: .yarn/releases/yarn-3.3.0.cjs
yarnPath: .yarn/releases/yarn-3.3.1.cjs
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
"scripts": {
"lint": "eslint src/**.ts",
"postinstall": "husky install",
"postpublish": "yarn pinst --enable",
"prepack": "yarn pinst --disable",
"postpack": "yarn pinst --enable",
"watch": "yarn dlx nodemon",
"build": "yarn rimraf ./dist && tsc",
"depcheck": "depcheck",
"prepublishOnly": "yarn pinst --disable",
"prepare": "yarn run lint && yarn run build && yarn run depcheck",
"changelog": "changelog --exclude ci,chore",
"debug": "yarn run lint && yarn run build && yarn dlx homebridge -I -D"
Expand Down Expand Up @@ -60,18 +60,18 @@
"@semantic-release/npm": "^9.0.1",
"@semantic-release/release-notes-generator": "^10.0.3",
"@types/body-parser": "^1.19.2",
"@types/express": "^4.17.14",
"@types/node": "^18.11.13",
"@types/express": "^4.17.15",
"@types/node": "^18.11.18",
"@types/qs": "^6.9.7",
"@types/semver": "^7.3.13",
"@typescript-eslint/eslint-plugin": "^5.46.0",
"@typescript-eslint/parser": "^5.46.0",
"@typescript-eslint/eslint-plugin": "^5.47.1",
"@typescript-eslint/parser": "^5.47.1",
"depcheck": "^1.4.3",
"eslint": "^8.29.0",
"eslint": "^8.30.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.2.1",
"generate-changelog": "^1.8.0",
"homebridge": "^1.5.1",
"homebridge": "^1.6.0",
"husky": "^8.0.2",
"lint-staged": "^13.1.0",
"nodemon": "^2.0.20",
Expand Down Expand Up @@ -104,5 +104,5 @@
"@semantic-release/*"
]
},
"packageManager": "[email protected].0"
"packageManager": "[email protected].1"
}
3 changes: 3 additions & 0 deletions src/lib/myStromTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ export const MyStromSwitchTypes = {
'106': 'CH v2',
WSEU: 'EU',
'107': 'EU',
LCS: 'Zero',
'120': 'Zero',
};

export interface MyStromDeviceHWInfo {
version: string;
mac: string;
Expand Down
28 changes: 20 additions & 8 deletions src/myStromSwitchAccessory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class MyStromSwitchAccessory extends DingzDaBaseAccessory {
)
.setCharacteristic(
this.platform.Characteristic.HardwareRevision,
this.mystromDeviceInfo ? 'EU/CH v2' : 'CH v1',
this.mystromDeviceInfo ? 'EU/CH v2/Zero' : 'CH v1',
)
.setCharacteristic(
this.platform.Characteristic.SerialNumber,
Expand All @@ -86,12 +86,11 @@ export class MyStromSwitchAccessory extends DingzDaBaseAccessory {

this.outletService
.getCharacteristic(this.platform.Characteristic.OutletInUse)
// .on(CharacteristicEventTypes.SET, this.setOutletInUse.bind(this)) // SET - bind to the `setOn` method below
.on(CharacteristicEventTypes.GET, this.getOutletInUse.bind(this)); // GET - bind to the `getOn` method below

if (this.device.hwInfo?.type !== undefined) {
// Only EU and CH v2 Switches have temperature sensor
if (this.device.model !== 'Zero' && this.device.model !== undefined) {
// Switch has a temperature sensor, make it available here
// create a new Temperature Sensor service
this.temperatureService =
this.accessory.getService(this.platform.Service.TemperatureSensor) ??
this.accessory.addService(this.platform.Service.TemperatureSensor);
Expand Down Expand Up @@ -121,9 +120,19 @@ export class MyStromSwitchAccessory extends DingzDaBaseAccessory {
.getCharacteristic(this.platform.Characteristic.On)
.updateValue(this.outletState.relay);

this.outletService
.getCharacteristic(this.platform.Characteristic.OutletInUse)
.updateValue(this.outletState.power > 0);
switch (this.device.model ?? 'unknown') {
case 'CH v1':
case 'Zero':
this.outletService
.getCharacteristic(this.platform.Characteristic.OutletInUse)
.updateValue(this.outletState.relay);
break;
default:
this.outletService
.getCharacteristic(this.platform.Characteristic.OutletInUse)
.updateValue(this.outletState.power > 0);
break;
}

if (this.temperatureService) {
this.temperatureService
Expand Down Expand Up @@ -160,7 +169,10 @@ export class MyStromSwitchAccessory extends DingzDaBaseAccessory {
}

private getOutletInUse(callback: CharacteristicGetCallback) {
const inUse: boolean = this.outletState?.power > 0;
const inUse: boolean =
this.device.model === 'Zero' // Zero does not measure power
? this.outletState?.relay
: this.outletState?.power > 0;
this.log.debug('Get Characteristic OutletInUse ->', inUse);
callback(this.reachabilityState, inUse);
}
Expand Down
16 changes: 12 additions & 4 deletions src/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,7 @@ export class DingzDaHomebridgePlatform implements DynamicPlatformPlugin {
info.type !== DeviceTypes.MYSTROM_SWITCH_CHV2 &&
info.type !== 'WSEU' &&
info.type !== DeviceTypes.MYSTROM_SWITCH_EU &&
info.type !== 'LCS' &&
info.type !== undefined // Switch V1 does not have a type
) {
throw new InvalidTypeError(
Expand Down Expand Up @@ -891,7 +892,7 @@ export class DingzDaHomebridgePlatform implements DynamicPlatformPlugin {
// the MAC of the discovered device will be printed in debug
if (!this.config.autoDiscover) {
this.log.debug(
`auto-discovery disabled: ignoring discovered device ${mac} at ${remoteInfo.address}`,
`Auto-discovery disabled: ignoring discovered device ${mac} at ${remoteInfo.address}`,
);
return;
}
Expand All @@ -904,7 +905,7 @@ export class DingzDaHomebridgePlatform implements DynamicPlatformPlugin {
'Ignoring discovered device',
this.ignored.get(mac.toUpperCase()).comment || '',
'at',
mac,
mac.toUpperCase(),
);
this.ignored.get(mac.toUpperCase()).isignored = true;
}
Expand All @@ -913,7 +914,11 @@ export class DingzDaHomebridgePlatform implements DynamicPlatformPlugin {
switch (t) {
case DeviceTypes.MYSTROM_BUTTON_PLUS:
throw new DeviceNotImplementedError(
`Device discovered at ${remoteInfo.address} of unsupported type ${DeviceTypes[t]}`,
`Device discovered at ${
remoteInfo.address
} (MAC:${mac.toUpperCase()}) of unsupported type ${
DeviceTypes[t]
} `,
);
break;
case DeviceTypes.MYSTROM_BUTTON:
Expand Down Expand Up @@ -973,6 +978,7 @@ export class DingzDaHomebridgePlatform implements DynamicPlatformPlugin {
case DeviceTypes.MYSTROM_SWITCH_CHV1:
case DeviceTypes.MYSTROM_SWITCH_CHV2:
case DeviceTypes.MYSTROM_SWITCH_EU:
case DeviceTypes.MYSTROM_SWITCH_ZERO:
retryWithBreaker
.execute(() => {
this.addMyStromSwitchDevice({
Expand Down Expand Up @@ -1017,7 +1023,9 @@ export class DingzDaHomebridgePlatform implements DynamicPlatformPlugin {
break;
}
} else {
this.log.debug('Stopping discovery of already known device:', mac);
this.log.debug(
`Stopping discovery of already known device: ${mac.toUpperCase()}`,
);
}
}
} catch (e) {
Expand Down
16 changes: 4 additions & 12 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,16 @@
"experimentalDecorators": true,
"target": "ES2018", // ~node10
"module": "commonjs",
"lib": [
"es2015",
"es2016",
"es2017",
"es2018"
],
"lib": ["es2015", "es2016", "es2017", "es2018"],
"declaration": true,
"declarationMap": true,
"sourceMap": true,
"outDir": "./dist",
"rootDir": "./src",
"strict": true,
"esModuleInterop": true,
"noImplicitAny": false
},
"include": [
"src/"
],
"exclude": [
"**/*.spec.ts"
]
"include": ["src/"],
"exclude": ["**/*.spec.ts"]
}
Loading

0 comments on commit 1b98801

Please sign in to comment.