Skip to content

Commit

Permalink
Merge pull request #689 from johannrichard/alpha
Browse files Browse the repository at this point in the history
Beta release 💚
  • Loading branch information
johannrichard authored Nov 1, 2024
2 parents 723eb75 + 07a3763 commit 3dd9470
Show file tree
Hide file tree
Showing 23 changed files with 6,321 additions and 5,598 deletions.
36 changes: 0 additions & 36 deletions .eslintrc

This file was deleted.

2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: 2
updates:
- package-ecosystem: npm
target-branch: 'alpha'
target-branch: 'next'
directory: '/'
schedule:
interval: monthly
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
matrix:
# the Node.js versions to build on
node-version: [16.x, 17.x, 18.x]
node-version: [18.x, 19.x, 20.x]

steps:
- uses: actions/checkout@main
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/semantic-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:

- uses: actions/setup-node@main
with:
node-version: '16'
node-version: '20'
cache: 'yarn'

- name: Install dependencies
Expand Down
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ web_modules/
# Github templates and actions, own stuff
.github
api
.husky
.prettierrc
.prettierignore
commitlint.config.js
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,8 @@
"eslint.nodePath": ".yarn/sdks",
"prettier.prettierPath": ".yarn/sdks/prettier/index.js",
"typescript.tsdk": ".yarn/sdks/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true
"typescript.enablePromptUseWorkspaceTsdk": true,
"conventionalCommits.scopes": [
"fix"
]
}
77 changes: 0 additions & 77 deletions .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs

This file was deleted.

8 changes: 0 additions & 8 deletions .yarn/plugins/@yarnpkg/plugin-typescript.cjs

This file was deleted.

550 changes: 0 additions & 550 deletions .yarn/plugins/@yarnpkg/plugin-version.cjs

This file was deleted.

823 changes: 0 additions & 823 deletions .yarn/releases/yarn-3.3.1.cjs

This file was deleted.

934 changes: 934 additions & 0 deletions .yarn/releases/yarn-4.5.1.cjs

Large diffs are not rendered by default.

14 changes: 5 additions & 9 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
checksumBehavior: update

nodeLinker: node-modules
compressionLevel: mixed

enableGlobalCache: false

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: "@yarnpkg/plugin-interactive-tools"
- path: .yarn/plugins/@yarnpkg/plugin-typescript.cjs
spec: "@yarnpkg/plugin-typescript"
- path: .yarn/plugins/@yarnpkg/plugin-version.cjs
spec: "@yarnpkg/plugin-version"
nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-3.3.1.cjs
yarnPath: .yarn/releases/yarn-4.5.1.cjs
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Homebridge Plugin for dingz Devices: homebridge-dingz

:construction: **Incompatibility w/ dingz Firmware v2.x.x** 🚧

Dingz recently released v2.x of their firmware [with a lot of changes](http://dingz.ch/en/changelog-en/) which I neither had the time to review nor to cope with. Unfortunately, the changes [are breaking things](https://github.com/johannrichard/homebridge-dingz/issues/611) if you use this homebridge plugin with dingz running on Firmware v2.x.

I have neither an idea of how bad this is (i.e. what broke) nor an ETA until when this can or will be fixed.

![Build and Lint](https://github.com/johannrichard/homebridge-dingz/workflows/Build%20and%20Lint/badge.svg)
[![Semantic release](https://github.com/johannrichard/homebridge-dingz/actions/workflows/semantic-release.yml/badge.svg?branch=master)](https://github.com/johannrichard/homebridge-dingz/actions/workflows/semantic-release.yml)
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fjohannrichard%2Fhomebridge-dingz.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fjohannrichard%2Fhomebridge-dingz?ref=badge_shield)
Expand Down
60 changes: 60 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import typescriptEslint from "@typescript-eslint/eslint-plugin";
import tsParser from "@typescript-eslint/parser";
import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
});

export default [{
ignores: ["**/dist", "**/commitlint.config.js"],
}, ...compat.extends(
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended",
), {
plugins: {
"@typescript-eslint": typescriptEslint,
},

languageOptions: {
parser: tsParser,
ecmaVersion: 2018,
sourceType: "module",
},

rules: {
quotes: ["warn", "single"],

indent: ["warn", 2, {
SwitchCase: 1,
}],

"linebreak-style": ["warn", "unix"],
semi: ["warn", "always"],
"comma-dangle": ["warn", "always-multiline"],
"dot-notation": "warn",
eqeqeq: "warn",
curly: ["warn", "all"],
"brace-style": ["warn"],
"prefer-arrow-callback": ["warn"],
"max-len": ["warn", 140],
"no-console": ["warn"],

"lines-between-class-members": ["warn", "always", {
exceptAfterSingleLine: true,
}],

"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-require-imports": "off",
},
}];
92 changes: 53 additions & 39 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "homebridge-dingz",
"version": "3.0.0",
"author": "johannrichard",
"description": "Homebridge Plugin for dingz & myStrom Devices. Implements some (but not all, due to API limitations) functions of a [dingz](https://dingz.ch) Smart Home Device.",
"description": "Homebridge Plugin for dingz & myStrom Devices. Implements some (but not all, due to API limitations) functions of a [dingz](https://dingz.ch) Smart Home Device. Not regularly updated.",
"license": "Apache-2.0",
"homepage": "https://github.com/johannrichard/homebridge-dingz#readme",
"repository": {
Expand All @@ -20,7 +20,6 @@
"main": "dist/index.js",
"scripts": {
"lint": "eslint src/**.ts",
"postinstall": "husky install",
"prepack": "yarn pinst --disable",
"postpack": "yarn pinst --enable",
"watch": "yarn dlx nodemon",
Expand All @@ -37,49 +36,51 @@
"iot"
],
"dependencies": {
"async-mutex": "^0.3.2",
"axios": "^0.25.0",
"axios-retry": "^3.2.4",
"body-parser": "^1.20.1",
"async-mutex": "^0.5.0",
"axios": "^1.7.7",
"axios-retry": "^4.5.0",
"body-parser": "^1.20.3",
"chalk": "4.1.2",
"cockatiel": "^2.0.2",
"express": "^4.18.2",
"cockatiel": "^3.2.1",
"express": "^4.21.1",
"intervals-for-humans": "^1.0.4",
"is-valid-host": "^1.0.1",
"limit-number": "^3.0.0",
"qs": "^6.11.0",
"semver": "^7.3.8",
"qs": "^6.13.0",
"semver": "^7.6.3",
"simple-color-converter": "^2.1.13"
},
"devDependencies": {
"@commitlint/cli": "^17.3.0",
"@commitlint/config-conventional": "^17.3.0",
"@semantic-release/changelog": "^6.0.2",
"@semantic-release/commit-analyzer": "^9.0.2",
"@semantic-release/github": "^8.0.7",
"@semantic-release/npm": "^9.0.1",
"@semantic-release/release-notes-generator": "^10.0.3",
"@types/body-parser": "^1.19.2",
"@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.47.1",
"@typescript-eslint/parser": "^5.47.1",
"depcheck": "^1.4.3",
"eslint": "^8.30.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.2.1",
"@commitlint/cli": "^19.5.0",
"@commitlint/config-conventional": "^19.5.0",
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.13.0",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/commit-analyzer": "^13.0.0",
"@semantic-release/github": "^11.0.0",
"@semantic-release/npm": "^12.0.1",
"@semantic-release/release-notes-generator": "^14.0.1",
"@types/body-parser": "^1.19.5",
"@types/express": "^5.0.0",
"@types/node": "^20.17.5",
"@types/qs": "^6.9.16",
"@types/semver": "^7.5.8",
"@typescript-eslint/eslint-plugin": "^8.12.2",
"@typescript-eslint/parser": "^8.12.2",
"depcheck": "^1.4.7",
"eslint": "^9.13.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1",
"generate-changelog": "^1.8.0",
"homebridge": "^1.6.0",
"husky": "^8.0.2",
"lint-staged": "^13.1.0",
"nodemon": "^2.0.20",
"homebridge": "^1.8.5",
"husky": "^9.1.6",
"lint-staged": "^15.2.10",
"nodemon": "^3.1.7",
"pinst": "^3.0.0",
"prettier": "^2.8.1",
"rimraf": "^3.0.2",
"semantic-release": "^19.0.5",
"typescript": "^4.9.4"
"prettier": "^3.3.3",
"rimraf": "^6.0.1",
"semantic-release": "^24.2.0",
"typescript": "^5.6.3"
},
"lint-staged": {
"**/*.+(js|jsx|css|less|scss|ts|tsx|md)": [
Expand All @@ -88,8 +89,17 @@
]
},
"release": {
"plugins": [
"@semantic-release/commit-analyzer",
"plugins": [ [
"@semantic-release/commit-analyzer", {
"preset": "angular",
"releaseRules": [
{ "type": "docs", "scope": "README", "release": "patch" },
{ "type": "refactor", "scope": "platform", "release": "minor" },
{ "type": "refactor", "release": "patch" },
{ "type": "fix", "release": "patch" },
{ "scope": "no-release", "release": false }
]
}],
"@semantic-release/release-notes-generator",
"@semantic-release/changelog",
"@semantic-release/npm",
Expand All @@ -100,9 +110,13 @@
"ignores": [
"@commitlint/*",
"eslint*",
"prettier*",
"rimraf*",
"husky*",

"semantic-release",
"@semantic-release/*"
]
},
"packageManager": "yarn@3.3.1"
"packageManager": "yarn@4.5.1"
}
20 changes: 11 additions & 9 deletions src/dingzAccessory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class DingzAccessory extends DingzDaBaseAccessory {
Brightness: 0 as number,
};

private motionTimer?: NodeJS.Timer;
private motionTimer?: NodeJS.Timeout;

private config: DingzDeviceConfig;
private hw: DingzDeviceHWInfo;
Expand Down Expand Up @@ -717,7 +717,9 @@ export class DingzAccessory extends DingzDaBaseAccessory {
service.getCharacteristic(this.platform.Characteristic.Brightness),
);
} catch (e) {
this.log.warn('Attempt to remove "Brightness" characteristic failed');
this.log.warn(
`Attempt to remove "Brightness" characteristic failed ${e}`,
);
} finally {
service.addCharacteristic(this.platform.Characteristic.Brightness);
service
Expand Down Expand Up @@ -782,7 +784,7 @@ export class DingzAccessory extends DingzDaBaseAccessory {
value: CharacteristicValue,
callback: CharacteristicSetCallback,
) {
const isOn: boolean = value > 0 ? true : false;
const isOn: boolean = Number(value) > 0 ? true : false;
this.dingzStates.Dimmers[index].output = value as number;
this.dingzStates.Dimmers[index].on = isOn;

Expand Down Expand Up @@ -938,9 +940,9 @@ export class DingzAccessory extends DingzDaBaseAccessory {
const windowCovering = this.dingzStates.WindowCovers[id];
if (windowCovering) {
// Make sure we're setting motion when changing the position
if (position > windowCovering.position) {
if (Number(position) > windowCovering.position) {
windowCovering.moving = 'up';
} else if (position < windowCovering.position) {
} else if (Number(position) < windowCovering.position) {
windowCovering.moving = 'down';
} else {
windowCovering.moving = 'stop';
Expand All @@ -951,7 +953,7 @@ export class DingzAccessory extends DingzDaBaseAccessory {
await this.setWindowCovering({
id: id,
blind: position as number,
lamella: (windowCovering.lamella / 90) * 100, // FIXES #419, we must convert ° to %
lamella: windowCovering.lamella, // FIXES #419, we must convert ° to %
callback: callback,
});
}
Expand Down Expand Up @@ -1078,7 +1080,7 @@ export class DingzAccessory extends DingzDaBaseAccessory {
// Only check for motion if we have a PIR and set the Interval
if (this.platform.config.motionPoller ?? true) {
this.log.info('Motion POLLING enabled');
const motionInterval: NodeJS.Timer = setInterval(() => {
const motionInterval: NodeJS.Timeout = setInterval(() => {
this.getDeviceMotion()
.then((data) => {
if (data?.success) {
Expand Down Expand Up @@ -1115,7 +1117,7 @@ export class DingzAccessory extends DingzDaBaseAccessory {
private removeMotionService() {
// Remove motionService & motionTimer
if (this.motionTimer) {
clearTimeout(this.motionTimer);
clearInterval(this.motionTimer);
this.motionTimer = undefined;
}
const service: Service | undefined = this.accessory.getService(
Expand Down Expand Up @@ -1518,7 +1520,7 @@ export class DingzAccessory extends DingzDaBaseAccessory {
lamella = Math.round(lamella);

this.log.debug(
`Setting WindowCovering ${id} to position ${blind} and angle ${lamella}°`,
`Setting WindowCovering ${id} to position ${blind} and ${lamella}% tilt position`,
);
// The API says the parameters can be omitted. This is not true
// {{ip}}/api/v1/shade/0?blind=<value>&lamella=<value>
Expand Down
Loading

0 comments on commit 3dd9470

Please sign in to comment.