Skip to content

Deprecation of Core and BridgeCore

Miguel Ripoll edited this page Sep 24, 2021 · 5 revisions

As of releases before 0.7.0 users were advised to download the HAP-NodeJS repository and startup HAP-NodeJS using Core.ts and BridgeCore.ts to load accessories located in the accessories folder.
This way of using HAP-NodeJS is deprecated with the release of 0.7.0 and is scheduled to be removed in October 2020.

The following reasons lead to the decision to deprecate this style of creating accessories:

  • It is and was always difficult for users to update to the latest version of HAP-NodeJS. In certain circumstances merge conflicts could appear making an update even more difficult.
  • It brought some inflexibility. For example, it is not really possible to delay publishing of the accessory, which is important for some applications where devices need to be discovered on the network first.
  • It is hard to share and maintain your custom accessories. For example publishing those to GitHub or releasing them would always require the whole library to be published.
  • There is the potential, that users are running an unstable version of HAP-NodeJS as the master branch may not always be stable and include changes not yet released.
  • With the latest migration to Typescript it got less straight forward for users to set up and start their accessories.

As a result we strongly encourage users to write their plugins using HAP-NodeJS as a library. There is a guide to get you started: Beginners guide for using HAP-NodeJS as a library.

Migration

First of all, you may have a look at the already mentioned Beginners guide for using HAP-NodeJS as a library.

But in short:

  • You will need to set up a new node project. You can choose to write your plugin in JavaScript or Typescript.
  • You will need to add "hap-nodejs" to your list of dependencies in your package.json
  • You may need to move your persist folder into the new location where your project will be running in oder to keep up the pairing between your accessories and your home.
  • Move your code over to the new project. You can basically keep the code pretty much the same if you are using standalone accessories (You have to write your own Bridge if you were using the BridgeCore). You will need to adjust the imports at the top and add a accessory.publish call at the bottom.
    When using object literal notation, you will need to call the AccessoryLoader.parseAccessoryJSON function with your json representation of the accessory.

For further guidance you can refer to the HAP-NodeJS Examples repository.