Skip to content

Commit 740c93d

Browse files
authored
1.4.2 Resolve issue with customCharacteristics not loading from file (#442)
### Fixed - Resolve issue with customCharacteristics not loading from file - Fixed publish process
1 parent 4833319 commit 740c93d

File tree

7 files changed

+119
-89
lines changed

7 files changed

+119
-89
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ All notable changes to this project will be documented in this file.
1111
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres
1212
to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
1313

14+
## [1.4.2]
15+
16+
### Fixed
17+
18+
- Resolve issue with customCharacteristics not loading from file
19+
- Fixed publish process
20+
1421
## [1.4.1]
1522

1623
### Fixed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "node-red-contrib-homekit-bridged",
3-
"version": "1.4.1",
3+
"version": "1.4.2",
44
"description": "Node-RED nodes to simulate Apple HomeKit devices.",
55
"main": "build/nodes/nrchkb.js",
66
"scripts": {
@@ -61,8 +61,8 @@
6161
"@types/node-red": "^1.1.1",
6262
"@types/semver": "^7.3.8",
6363
"@types/uuid": "^8.3.1",
64-
"@typescript-eslint/eslint-plugin": "^4.32.0",
65-
"@typescript-eslint/parser": "^4.32.0",
64+
"@typescript-eslint/eslint-plugin": "^4.33.0",
65+
"@typescript-eslint/parser": "^4.33.0",
6666
"babel-eslint": "^10.1.0",
6767
"eslint": "^7.32.0",
6868
"eslint-config-prettier": "^8.3.0",

src/lib/HAPHostNode.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ module.exports = (RED: NodeAPI, hostType: HostType) => {
7272
}
7373
}
7474

75-
self.accessoryCategory = ((self.hostType == HostType.BRIDGE
75+
self.accessoryCategory = (self.hostType == HostType.BRIDGE
7676
? HapCategories.BRIDGE
77-
: self.config.accessoryCategory) as unknown) as Categories
77+
: self.config.accessoryCategory) as unknown as Categories
7878

7979
self.published = false
8080

src/lib/Storage.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,12 @@ export class Storage {
4747

4848
static save(
4949
type: StorageType,
50-
key: string,
50+
key: string | undefined,
5151
value: unknown
5252
): Promise<storage.WriteFileResult> {
53-
Storage.log.trace(`Saving ${type}, ${key}:${value}`)
54-
return storage.set(`${type}-${key}`, value)
53+
const itemName = key ? `${type}-${key}` : type
54+
Storage.log.trace(`Saving ${itemName}:${value}`)
55+
return storage.set(itemName, value)
5556
}
5657

5758
static saveCallback(eventCallback: EventCallback, ttl = 10000) {
@@ -74,7 +75,11 @@ export class Storage {
7475
static saveCustomCharacteristics(
7576
value: unknown
7677
): Promise<storage.WriteFileResult> {
77-
return Storage.save(StorageType.CUSTOM_CHARACTERISTICS, '', value)
78+
return Storage.save(
79+
StorageType.CUSTOM_CHARACTERISTICS,
80+
undefined,
81+
value
82+
)
7883
}
7984

8085
static saveService(
@@ -98,9 +103,10 @@ export class Storage {
98103
return Storage.save(StorageType.HOST, key, serializedHost)
99104
}
100105

101-
static load(type: StorageType, key: string): Promise<any> {
102-
Storage.log.trace(`Loading ${type}, ${key}`)
103-
return storage.get(`${type}-${key}`)
106+
static load(type: StorageType, key?: string): Promise<any> {
107+
const itemName = key ? `${type}-${key}` : type
108+
Storage.log.trace(`Loading ${itemName}`)
109+
return storage.get(itemName)
104110
}
105111

106112
static loadCallback(key: string): EventCallback | undefined {
@@ -115,7 +121,7 @@ export class Storage {
115121
}
116122

117123
static loadCustomCharacteristics(): Promise<any> {
118-
return Storage.load(StorageType.CUSTOM_CHARACTERISTICS, '')
124+
return Storage.load(StorageType.CUSTOM_CHARACTERISTICS)
119125
}
120126

121127
static loadService(key: string): Promise<SerializedService> {

src/lib/api.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ module.exports = function (RED: NodeAPI) {
142142
const getCustomCharacteristics = () => {
143143
return Storage.loadCustomCharacteristics()
144144
.then((value) => {
145+
log.trace(`loadCustomCharacteristics()`)
146+
log.trace(value)
147+
145148
if (Array.isArray(value)) {
146149
return value
147150
} else {
@@ -342,7 +345,7 @@ module.exports = function (RED: NodeAPI) {
342345
.sort()
343346
.filter((x) => parseInt(x) >= 0)
344347
.forEach((key) => {
345-
const keyNumber = (key as unknown) as number
348+
const keyNumber = key as unknown as number
346349
accessoryCategoriesData[keyNumber] = HapCategories[keyNumber]
347350
})
348351

src/test/lib/HAPBridgeNode.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ describe('HAPHostNode', function () {
1414
})
1515

1616
it('null string macify should fail', function (done) {
17-
const stringToMacify = (null as unknown) as string
17+
const stringToMacify = null as unknown as string
1818
should.throws(() => {
1919
HAPHostNode.macify(stringToMacify)
2020
}, 'nodeId cannot be empty in macify process')
2121
done()
2222
})
2323

2424
it('undefined string macify should fail', function (done) {
25-
const stringToMacify = (undefined as unknown) as string
25+
const stringToMacify = undefined as unknown as string
2626
should.throws(() => {
2727
HAPHostNode.macify(stringToMacify)
2828
}, 'nodeId cannot be empty in macify process')

0 commit comments

Comments
 (0)