Skip to content

Commit

Permalink
Update vastra-radiator-valve to 1.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
adamwych committed Dec 25, 2023
1 parent bac6e77 commit 02da09b
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 26 deletions.
3 changes: 3 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,6 @@ web_modules/
.yarn/unplugged
.yarn/build-state.yml
.pnp.*

dist/fake-bluetooth.*
src/snapshot.bin
6 changes: 3 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"files.eol": "\n",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
"source.fixAll.eslint": "explicit"
},
"editor.rulers": [ 140 ],
"editor.rulers": [140],
"eslint.enable": true
}
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"displayName": "Vastra Radiator Valve",
"name": "homebridge-vastra-radiator-valve",
"version": "1.0.2",
"version": "1.2.0",
"description": "Homebridge integration for Vastra's radiator valves",
"license": "MIT",
"author": {
Expand Down Expand Up @@ -30,7 +30,7 @@
"homebridge-plugin"
],
"dependencies": {
"vastra-radiator-valve": "^1.1.1"
"vastra-radiator-valve": "^1.2.1"
},
"devDependencies": {
"@types/node": "^18.16.20",
Expand Down
26 changes: 9 additions & 17 deletions src/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import {
} from "homebridge";
import {
NobleBluetoothCentral,
RadiatorValves,
Logger as VastraLogger,
RadiatorValveScanner,
} from "vastra-radiator-valve";
import { VastraRadiatorValvePlatformAccessory } from "./radiatorValveAccessory";
import { PLATFORM_NAME, PLUGIN_NAME } from "./settings";
Expand All @@ -23,7 +22,7 @@ export class VastraRadiatorValveHomebridgePlugin
public readonly Characteristic: typeof Characteristic =
this.api.hap.Characteristic;

private radiatorValves?: RadiatorValves;
private scanner?: RadiatorValveScanner;

public readonly accessories: VastraRadiatorValvePlatformAccessory[] = [];

Expand All @@ -37,7 +36,7 @@ export class VastraRadiatorValveHomebridgePlugin
});

this.api.on("shutdown", () => {
this.radiatorValves?.dispose();
this.scanner?.disconnectAll();
});
}

Expand All @@ -49,21 +48,12 @@ export class VastraRadiatorValveHomebridgePlugin
}

startDiscovering() {
this.radiatorValves = new RadiatorValves(new NobleBluetoothCentral(), {
logger: new VastraLogger(false),
this.scanner = new RadiatorValveScanner(new NobleBluetoothCentral(), {
verbose: false,
raspberryFix: true,
});
this.radiatorValves.startScanning(async (valve) => {
try {
await valve.connect();
} catch (error) {
this.log.error(
`Failed to open connection to ${valve.peripheral.address}.`,
error
);
return;
}

this.scanner.on("connected", async (valve) => {
const uuid = this.api.hap.uuid.generate(valve.peripheral.address);
const existingAccessory = this.accessories.find(
(accessory) => accessory.accessory.UUID === uuid
Expand All @@ -78,7 +68,7 @@ export class VastraRadiatorValveHomebridgePlugin
uuid,
Categories.THERMOSTAT
);
accessory.context.serialNumber = valve.getSerialNumber();
accessory.context.serialNumber = await valve.getSerialNumber();
accessory.context.address = valve.peripheral.address;

this.accessories.push(
Expand All @@ -90,5 +80,7 @@ export class VastraRadiatorValveHomebridgePlugin
]);
}
});

this.scanner.start();
}
}
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2043,10 +2043,10 @@ v8-compile-cache-lib@^3.0.1:
resolved "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz"
integrity sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==

vastra-radiator-valve@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/vastra-radiator-valve/-/vastra-radiator-valve-1.1.1.tgz#7ed5414a526dbf2925c9550b5fe90b12742afbeb"
integrity sha512-e/uP7jZuaB+GU2495cSZ8HiGEabsBz0Mh/5fVI1WW5PXhoDd8mGHpuZrnhAsJAZEL4jK1LqZHSDVJ7BULGcMcA==
vastra-radiator-valve@^1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/vastra-radiator-valve/-/vastra-radiator-valve-1.2.1.tgz#6169f82289b596c6e365a6472a76981deb78811b"
integrity sha512-LTNcXAb4t3A8FXyXBdElMuL60dzs2JuOATfJeWETREVS3pJ7wj4rtCaJNvBpzBSpZSekLb7zzRB6pGTuDvZbHA==
dependencies:
"@abandonware/noble" "^1.9.2-23"

Expand Down

0 comments on commit 02da09b

Please sign in to comment.