diff --git a/CHANGELOG.md b/CHANGELOG.md index ac36a8a4a..262c8ba84 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ All notable changes to `hap-nodejs` will be documented in this file. This projec - AdaptiveLightingController fix & improvement (#1038) (@Shaquu) - Minor fixes to recording logging and one change in logging. (#1040) (@hjdhjd) - Fix Build Issues (#1041) (@NorthernMan54) +- Bridged core and core cleanup (#1048) (@Shaquu) - Correct log spacing - Updated and fixed `typedoc` config file - Updated dependencies diff --git a/README.md b/README.md index b4e77e69e..f95061315 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ +
Coverage Status diff --git a/src/BridgedCore.ts b/src/BridgedCore.ts index 94f3be3c9..c676989ab 100644 --- a/src/BridgedCore.ts +++ b/src/BridgedCore.ts @@ -6,8 +6,9 @@ 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"); // Initialize our storage system storage.initSync(); @@ -42,9 +43,7 @@ const signals = { "SIGINT": 2, "SIGTERM": 15 } as Record; // 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)); }); }); diff --git a/src/Core.ts b/src/Core.ts index b2583c81a..7112c3790 100644 --- a/src/Core.ts +++ b/src/Core.ts @@ -6,8 +6,9 @@ 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"); // Initialize our storage system storage.initSync(); @@ -26,13 +27,13 @@ accessories.forEach((accessory) => { // @ts-expect-error: Core/BridgeCore API if (!accessory.username) { throw new Error("Username not found on accessory '" + accessory.displayName + - "'. Core.js requires all accessories to define a unique 'username' property."); + "'. Core.js requires all accessories to define a unique 'username' property."); } // @ts-expect-error: Core/BridgeCore API if (!accessory.pincode) { throw new Error("Pincode not found on accessory '" + accessory.displayName + - "'. Core.js requires all accessories to define a 'pincode' property."); + "'. Core.js requires all accessories to define a 'pincode' property."); } // publish this Accessory on the local network @@ -50,12 +51,7 @@ const signals = { "SIGINT": 2, "SIGTERM": 15 } as Record; // 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)); }); }); diff --git a/src/accessories/Sprinkler_accessory.ts b/src/accessories/Sprinkler_accessory.ts index f9ee52ca9..69139e435 100644 --- a/src/accessories/Sprinkler_accessory.ts +++ b/src/accessories/Sprinkler_accessory.ts @@ -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 @@ -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() {