Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bad listeners detachment for characteristics #563

Merged
merged 3 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres
to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.7.1] - 2024-09-24

### Fixed

- Fix bad listeners detachment for characteristics [#563](https://github.com/NRCHKB/node-red-contrib-homekit-bridged/issues/563)

## [1.7.0] - 2024-09-19

### Fixed
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node-red-contrib-homekit-bridged",
"version": "1.7.0",
"version": "1.7.1",
"description": "Node-RED nodes to simulate Apple HomeKit devices.",
"main": "build/nodes/nrchkb.js",
"scripts": {
Expand Down
19 changes: 10 additions & 9 deletions src/lib/utils/CharacteristicUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,21 @@ module.exports = function (node: HAPServiceNodeType) {
service.optionalCharacteristics
)

// Listen to characteristic events and store the listener functions
// to be able to remove them later
node.onCharacteristicGet = ServiceUtils.onCharacteristicGet
node.onCharacteristicSet = ServiceUtils.onCharacteristicSet(
service.characteristics
)
node.onCharacteristicChange = ServiceUtils.onCharacteristicChange(
service.characteristics
)

allCharacteristics.map((characteristic) => {
const cKey = characteristic.constructor.name

supported.push(cKey)

// Listen to characteristic events and store the listener functions
// to be able to remove them later
node.onCharacteristicGet = ServiceUtils.onCharacteristicGet
node.onCharacteristicSet = ServiceUtils.onCharacteristicSet(
service.characteristics
)
node.onCharacteristicChange = ServiceUtils.onCharacteristicChange(
service.characteristics
)
characteristic.on('get', node.onCharacteristicGet)
characteristic.on('set', node.onCharacteristicSet)
characteristic.on('change', node.onCharacteristicChange)
Expand Down
23 changes: 12 additions & 11 deletions src/lib/utils/CharacteristicUtils2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,22 +64,23 @@ module.exports = function (node: HAPService2NodeType) {
service.optionalCharacteristics
)

// Listen to characteristic events and store the listener functions
// to be able to remove them later
node.onCharacteristicGet = ServiceUtils.onCharacteristicGet(
service.characteristics
)
node.onCharacteristicSet = ServiceUtils.onCharacteristicSet(
service.characteristics
)
node.onCharacteristicChange = ServiceUtils.onCharacteristicChange(
service.characteristics
)

allCharacteristics.map((characteristic) => {
const cKey = characteristic.constructor.name

supported.push(cKey)

// Listen to characteristic events and store the listener functions
// to be able to remove them later
node.onCharacteristicGet = ServiceUtils.onCharacteristicGet(
service.characteristics
)
node.onCharacteristicSet = ServiceUtils.onCharacteristicSet(
service.characteristics
)
node.onCharacteristicChange = ServiceUtils.onCharacteristicChange(
service.characteristics
)
characteristic.on('get', node.onCharacteristicGet)
characteristic.on('set', node.onCharacteristicSet)
characteristic.on('change', node.onCharacteristicChange)
Expand Down
Loading