Skip to content

Commit

Permalink
v2.0.1 (#221)
Browse files Browse the repository at this point in the history
- Fix async constructor, Thanks [@dnicolson](https://github.com/dnicolson) [#229](#220)
- Housekeeping and update dependencies

**Full Changelog**: v2.0.0...v2.0.1
  • Loading branch information
donavanbecker committed Feb 7, 2024
1 parent 7a8e59c commit 3877620
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 92 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/changerelease.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
name: Changelog to Release

on:
workflow_dispatch:
push:
paths: [CHANGELOG.md]
branches: [latest]
release:
types: [published]

jobs:
changerelease:
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
name: Node Release

on:
push:
tags:
- 'v*.*.*'
workflow_dispatch:
release:
types: [published]

jobs:
build_and_test:
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

All notable changes to this project will be documented in this file. This project uses [Semantic Versioning](https://semver.org/)

## [2.0.1](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v2.0.1) (2024-02-06)

### What's Changed
- Fix async constructor, Thanks [@dnicolson](https://github.com/dnicolson) [#229](https://github.com/OpenWonderLabs/node-switchbot/pull/220)
- Housekeeping and update dependencies

**Full Changelog**: https://github.com/OpenWonderLabs/node-switchbot/compare/v2.0.0...v2.0.1

## [2.0.0](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v2.0.0) (2024-02-05)

### What's Changed
Expand Down
102 changes: 51 additions & 51 deletions README.md

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node-switchbot",
"version": "2.0.0",
"version": "2.0.1",
"description": "The node-switchbot is a Node.js module which allows you to control your Switchbot Devices through Bluetooth (BLE).",
"homepage": "https://github.com/OpenWonderLabs/node-switchbot",
"author": "OpenWonderLabs (https://github.com/OpenWonderLabs)",
Expand Down Expand Up @@ -36,7 +36,7 @@
],
"readmeFilename": "README.md",
"dependencies": {
"@abandonware/noble": "^1.9.2-23"
"@abandonware/noble": "^1.9.2-24"
},
"optionalDependencies": {
"@abandonware/bluetooth-hci-socket": "^0.5.3-10"
Expand Down
44 changes: 24 additions & 20 deletions src/switchbot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type peripherals = {
}

export class SwitchBot {
private ready: Promise<void>;
noble;
ondiscover;
onadvertisement;
Expand All @@ -48,27 +49,29 @@ export class SwitchBot {
* ---------------------------------------------------------------- */


constructor(params: params = {}) {
// Check parameters
(async () => {
let noble: any;
if (params && params.noble) {
noble = params.noble;
} else {
noble = (await import('@abandonware/noble')).default;
}

// Public properties
this.noble = noble;
this.ondiscover = null;
this.onadvertisement = null;
this.onlog = null;

// Private properties
this.scanning = false;
})();
constructor(params?: params) {
this.DEFAULT_DISCOVERY_DURATION = 5000;
this.PRIMARY_SERVICE_UUID_LIST = [];
this.ready = this.init(params);
}

// Check parameters
async init(params?: params) {
let noble: any;
if (params && params.noble) {
noble = params.noble;
} else {
noble = (await import('@abandonware/noble')).default;
}

// Public properties
this.noble = noble;
this.ondiscover = null;
this.onadvertisement = null;
this.onlog = null;

// Private properties
this.scanning = false;
}

/* ------------------------------------------------------------------
Expand Down Expand Up @@ -221,7 +224,8 @@ export class SwitchBot {
return promise;
}

_init() {
async _init() {
await this.ready;
const promise = new Promise<void>((resolve, reject) => {
let err;
if (this.noble.state === 'poweredOn') {
Expand Down

0 comments on commit 3877620

Please sign in to comment.