Skip to content

Commit

Permalink
Bridged core and core cleanup (#1048)
Browse files Browse the repository at this point in the history
* Update pr-labeler.yml

* AdaptiveLightingController fix & improvement (#1038)

* AdaptiveLightingController on update should provide some data without the need to build it yourself

* Fix TypeError

* Fixed linting and test issues

* Typedoc fixes

* Updated examples

* Eslint fixes

---------

Co-authored-by: Donavan Becker <[email protected]>

* BridgedCore.ts and Core.ts cleanup (updated deprecation date from year 2022 to 2024).

* Removed not allowed char from Sprinkler accessory example

* Code review remarks

---------

Co-authored-by: Donavan Becker <[email protected]>
  • Loading branch information
Shaquu and donavanbecker authored Jun 28, 2024
1 parent feb82d8 commit e5383f8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 17 deletions.
10 changes: 4 additions & 6 deletions src/BridgedCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { Accessory, AccessoryEventTypes, AccessoryLoader, Bridge, Categories, HA

console.log(`HAP-NodeJS v${HAPLibraryVersion()} starting...`);

console.warn("DEPRECATION NOTICE: The use of Core and BridgeCore are deprecated and are scheduled to be remove in October 2020. " +
"For more information and some guidance on how to migrate, have a look at https://github.com/homebridge/HAP-NodeJS/wiki/Deprecation-of-Core-and-BridgeCore");
console.warn("DEPRECATION NOTICE: The use of Core and BridgeCore is deprecated and is scheduled to be removed in a future version.");
console.warn("For more information and some guidance on how to migrate, have a look at https://github.com/homebridge/HAP-NodeJS/wiki/Deprecation-of-Core-and-BridgeCore");

Check warning on line 10 in src/BridgedCore.ts

View workflow job for this annotation

GitHub Actions / lint / ESLint

This line has a length of 170. Maximum allowed is 160

Check warning on line 10 in src/BridgedCore.ts

View workflow job for this annotation

GitHub Actions / lint / ESLint

This line has a length of 170. Maximum allowed is 160

// Initialize our storage system
storage.initSync();
Expand Down Expand Up @@ -42,9 +42,7 @@ const signals = { "SIGINT": 2, "SIGTERM": 15 } as Record<string, number>;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Object.keys(signals).forEach((signal: any) => {
process.on(signal, () => {
bridge.unpublish();
setTimeout(()=> {
process.exit(128 + signals[signal]);
}, 1000);
bridge.unpublish()
.then(() => setTimeout(() => process.exit(128 + signals[signal]), 1000));
});
});
13 changes: 4 additions & 9 deletions src/Core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { AccessoryLoader, HAPLibraryVersion } from "./";

console.log(`HAP-NodeJS v${HAPLibraryVersion()} starting...`);

console.warn("DEPRECATION NOTICE: The use of Core and BridgeCore are deprecated and are scheduled to be remove in October 2020. " +
"For more information and some guidance on how to migrate, have a look at https://github.com/homebridge/HAP-NodeJS/wiki/Deprecation-of-Core-and-BridgeCore");
console.warn("DEPRECATION NOTICE: The use of Core and BridgeCore is deprecated and is scheduled to be removed in a future version.");
console.warn("For more information and some guidance on how to migrate, have a look at https://github.com/homebridge/HAP-NodeJS/wiki/Deprecation-of-Core-and-BridgeCore");

Check warning on line 10 in src/Core.ts

View workflow job for this annotation

GitHub Actions / lint / ESLint

This line has a length of 170. Maximum allowed is 160

Check warning on line 10 in src/Core.ts

View workflow job for this annotation

GitHub Actions / lint / ESLint

This line has a length of 170. Maximum allowed is 160

// Initialize our storage system
storage.initSync();
Expand Down Expand Up @@ -50,12 +50,7 @@ const signals = { "SIGINT": 2, "SIGTERM": 15 } as Record<string, number>;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Object.keys(signals).forEach((signal: any) => {
process.on(signal, () => {
for (let i = 0; i < accessories.length; i++) {
accessories[i].unpublish();
}

setTimeout(() => {
process.exit(128 + signals[signal]);
}, 1000);
Promise.all(accessories.map(a => a.unpublish()))
.then(() => setTimeout(() => process.exit(128 + signals[signal]), 1000));
});
});
4 changes: 2 additions & 2 deletions src/accessories/Sprinkler_accessory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const SPRINKLER = {
const sprinklerUUID = uuid.generate("hap-nodejs:accessories:sprinkler");

// This is the Accessory that we'll return to HAP-NodeJS that represents our fake motionSensor.
const sprinkler = exports.accessory = new Accessory("💦 Sprinkler", sprinklerUUID);
const sprinkler = exports.accessory = new Accessory("Sprinkler", sprinklerUUID);

// Add properties for publishing (in case we're using Core.js and not BridgedCore.js)
// @ts-expect-error: Core/BridgeCore API
Expand All @@ -44,7 +44,7 @@ sprinkler.pincode = "123-44-567";
sprinkler.category = Categories.SPRINKLER;

// Add the actual Valve Service and listen for change events from iOS.
const sprinklerService = sprinkler.addService(Service.Valve, "💦 Sprinkler");
const sprinklerService = sprinkler.addService(Service.Valve, "Sprinkler");

// Sprinkler Controll
function openVentile() {
Expand Down

0 comments on commit e5383f8

Please sign in to comment.