Skip to content

Commit

Permalink
Fix import issues and update configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
Herlix committed Jun 20, 2024
1 parent 95ce1f3 commit a64ca86
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 85 deletions.
75 changes: 16 additions & 59 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -13,69 +13,26 @@
"dist"
],
"rules": {
"quotes": [
"warn",
"single"
],
"indent": [
"warn",
2,
{
"SwitchCase": 1
}
],
"semi": [
"off"
],
"quotes": ["warn", "single"],
"indent": ["warn", 2, { "SwitchCase": 1 }],
"semi": ["off"],
"comma-dangle": ["warn", "always-multiline"],
"dot-notation": "off",
"eqeqeq": "warn",
"curly": [
"warn",
"all"
],
"brace-style": [
"warn"
],
"prefer-arrow-callback": [
"warn"
],
"max-len": [
"warn",
140
],
"no-console": [
"warn"
], // use the provided Homebridge log method instead
"no-non-null-assertion": [
"off"
],
"comma-spacing": [
"error"
],
"no-multi-spaces": [
"warn",
{
"ignoreEOLComments": true
}
],
"no-trailing-spaces": [
"warn"
],
"lines-between-class-members": [
"warn",
"always",
{
"exceptAfterSingleLine": true
}
],
"curly": ["warn", "all"],
"brace-style": ["warn"],
"prefer-arrow-callback": ["warn"],
"max-len": ["warn", 140],
"no-console": ["warn"], // use the provided Homebridge log method instead
"no-non-null-assertion": ["off"],
"comma-spacing": ["error"],
"no-multi-spaces": ["warn", { "ignoreEOLComments": true }],
"no-trailing-spaces": ["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/explicit-module-boundary-types": "off",
"@typescript-eslint/semi": [
"warn"
],
"@typescript-eslint/member-delimiter-style": [
"warn"
]
"@typescript-eslint/semi": ["warn"],
"@typescript-eslint/member-delimiter-style": ["warn"]
}
}
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#### 1.3.6 (2024-06-20)

Fix import issues and update configurations

#### 1.3.6 (2024-06-20)

Update dependencies

#### 1.3.5 (2024-03-14)
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
"displayName": "Plejd",
"name": "homebridge-plejd",
"author": "Herlix",
"version": "1.3.6",
"version": "1.3.7",
"description": "HomeKit support for the Plejd BLE platform using Homebridge",
"license": "Apache-2.0",
"type": "module",
"repository": {
"type": "git",
"url": "[email protected]:Herlix/homebridge-plejd.git"
Expand All @@ -22,7 +23,7 @@
"lint": "eslint src/**.ts --max-warnings=0",
"watch": "npm run build && npm link && nodemon",
"build": "rimraf ./dist && tsc",
"prepublishOnly": "npm run lint && npm run build"
"prepublishOnly": "npm run build"
},
"keywords": ["homebridge-plugin", "plejd"],
"dependencies": {
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { API } from "homebridge";

import { PLATFORM_NAME, PLUGIN_NAME } from "./settings";
import { PlejdPlatform } from "./plejdPlatform";
import { PLATFORM_NAME, PLUGIN_NAME } from "./settings.js";
import { PlejdPlatform } from "./plejdPlatform.js";

/**
* This method registers the platform with Homebridge
Expand Down
2 changes: 1 addition & 1 deletion src/plejdApi.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import axios from "axios";
import EventEmitter from "events";
import { Logger } from "homebridge";
import { Site } from "./model/plejdSite";
import { Site } from "./model/plejdSite.js";

const API_APP_ID = "zHtVqXt8k4yFyk2QGmgp48D9xZr2G94xWYnF4dak";
const API_BASE_URL = "https://cloud.plejd.com/parse/";
Expand Down
14 changes: 7 additions & 7 deletions src/plejdPlatform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ import {
PLEJD_ADDONS,
PLEJD_LIGHTS,
PLUGIN_NAME,
} from "./settings";
import { PlejdPlatformAccessoryHandler } from "./plejdPlatformAccessory";
import { UserInputConfig } from "./model/userInputConfig";
import { Device } from "./model/device";
import { PlejdService } from "./plejdService";
import PlejdRemoteApi from "./plejdApi";
import { Site } from "./model/plejdSite";
} from "./settings.js";
import { PlejdPlatformAccessoryHandler } from "./plejdPlatformAccessory.js";
import { UserInputConfig } from "./model/userInputConfig.js";
import { Device } from "./model/device.js";
import { PlejdService } from "./plejdService.js";
import PlejdRemoteApi from "./plejdApi.js";
import { Site } from "./model/plejdSite.js";

export class PlejdPlatform implements DynamicPlatformPlugin {
public readonly Service: typeof Service;
Expand Down
20 changes: 10 additions & 10 deletions src/plejdPlatformAccessory.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge';
import { Device } from './model/device';
import { Service, PlatformAccessory, CharacteristicValue } from "homebridge";
import { Device } from "./model/device.js";

import { PlejdPlatform } from './plejdPlatform';
import { PLATFORM_NAME } from './settings';
import { PlejdPlatform } from "./plejdPlatform.js";
import { PLATFORM_NAME } from "./settings.js";

interface DeviceState {
isOn: boolean;
Expand Down Expand Up @@ -75,15 +75,15 @@ export class PlejdPlatformAccessoryHandler {

updateState = (isOn: boolean, brightness?: number) => {
this.state.isOn = isOn;
this.platform.log.debug('updateState | Sending isOn', isOn);
this.platform.log.debug("updateState | Sending isOn", isOn);
this.service
.getCharacteristic(this.platform.Characteristic.On)
.updateValue(isOn);

if (brightness) {
this.state.brightness = Math.round(brightness);
this.platform.log.debug(
'update state | Sending brightness',
"update state | Sending brightness",
this.state.brightness,
);
this.service
Expand All @@ -99,8 +99,8 @@ export class PlejdPlatformAccessoryHandler {
const newVal = value as boolean;
this.platform.log.info(
`Updating state | ${this.device.name} | to ${
newVal ? 'On' : 'off'
} | from ${this.state.isOn ? 'On' : 'Off'}`,
newVal ? "On" : "off"
} | from ${this.state.isOn ? "On" : "Off"}`,
);
this.updateState(newVal, this.state.brightness);
this.platform.plejdService?.updateState(
Expand All @@ -112,7 +112,7 @@ export class PlejdPlatformAccessoryHandler {

private getOn = async (): Promise<CharacteristicValue> => {
this.platform.log.debug(
'Get Characteristic On',
"Get Characteristic On",
this.device.name,
this.state.isOn,
);
Expand All @@ -134,7 +134,7 @@ export class PlejdPlatformAccessoryHandler {

private getBrightness = async (): Promise<CharacteristicValue> => {
this.platform.log.debug(
'Get Characteristic Brightness',
"Get Characteristic Brightness",
this.device.name,
this.state.brightness,
);
Expand Down
6 changes: 3 additions & 3 deletions src/plejdService.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Logger } from "homebridge";
import { UserInputConfig } from "./model/userInputConfig";
import { UserInputConfig } from "./model/userInputConfig.js";
import {
plejdChalResp as plejdCharResp,
plejdEncodeDecode,
reverseBuffer,
} from "./plejdUtils";
} from "./plejdUtils.js";

import { randomBytes } from "crypto";
import noble from "@abandonware/noble";
import { PLEJD_WRITE_TIMEOUT } from "./settings";
import { PLEJD_WRITE_TIMEOUT } from "./settings.js";

const NOBLE_IS_POWER_ON = "oweredOn";

Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
"strict": true,
"target": "ES2022"
},
"include": ["eslint.config.mjs", "homebridge-ui", "src"],
"include": ["eslint.config.mjs", "homebridge-ui", "src/**/*.ts"],
"exclude": ["**/*.spec.ts"]
}

0 comments on commit a64ca86

Please sign in to comment.