Skip to content

Commit ba388e8

Browse files
authored
Homebridge 1.3.3 (homebridge#2867)
* update changelog * hap-nodejs 0.9.3-beta.1 * handle exceptions from duplicate UUID accessories when restoring cached accessories * update changelog * hap-nodejs 0.9.3-beta.3 * hap-nodejs@0.9.3-beta.5 * hap-nodejs@0.9.3-beta.6 * hap-nodejs@0.9.3-beta.8 * add ipc message for homebridge status * hap-nodejs@0.9.3-beta.12 * hap-nodejs@0.9.3 * set version back to 1.3.2 for pre-release * fix bad typo
1 parent 206a02d commit ba388e8

File tree

6 files changed

+112
-30
lines changed

6 files changed

+112
-30
lines changed

CHANGELOG.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# Change Log
22

3+
## NEXT
4+
5+
### Bug Fixes
6+
7+
* [#2855](https://github.com/homebridge/homebridge/issues/2855) - Fixed an issue to handle the situation where Siri sends unexpected values for the characteristic format type.
8+
9+
### Other Changes
10+
11+
* [#2856](https://github.com/homebridge/homebridge/issues/2856) - Gracefully handle duplicate UUID errors when restoring the accessory cache.
12+
* Update [HAP-NodeJS](https://github.com/homebridge/HAP-NodeJS) to [v0.9.3](https://github.com/homebridge/HAP-NodeJS/releases/tag/v0.9.3).
13+
314
## v1.3.2 (2021-03-04)
415

516
Please make sure you have done the following before updating:
@@ -8,11 +19,11 @@ Please make sure you have done the following before updating:
819

920
### Notable Changes
1021

11-
* [#2845](https://github.com/homebridge/homebridge/issues/2820) - Added the ability for more than one accessory of the same type to be added to a single child bridge. [See docs for more info](https://github.com/homebridge/homebridge/wiki/Child-Bridges#multiple-accessories-on-the-same-child-bridge).
22+
* [#2849](https://github.com/homebridge/homebridge/issues/2849) - Added the ability for more than one accessory of the same type to be added to a single child bridge. [See docs for more info](https://github.com/homebridge/homebridge/wiki/Child-Bridges#multiple-accessories-on-the-same-child-bridge).
1223

1324
### Other Changes
1425

15-
* Warnings about "slow" plugin characteristics will no longer be shown for external / unbridges accessories (typically Cameras or TVs) as these do not slow down the entire bridge.
26+
* Warnings about "slow" plugin characteristics will no longer be shown for external / unbridged accessories (typically Cameras or TVs) as these do not slow down the entire bridge.
1627

1728
## v1.3.1 (2021-02-23)
1829

package-lock.json

Lines changed: 42 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "homebridge",
33
"description": "HomeKit support for the impatient",
44
"version": "1.3.2",
5-
"betaVersion": "1.3.2",
5+
"betaVersion": "1.3.3",
66
"main": "lib/index.js",
77
"types": "lib/index.d.ts",
88
"license": "Apache-2.0",
@@ -47,7 +47,7 @@
4747
"chalk": "^4.1.0",
4848
"commander": "5.1.0",
4949
"fs-extra": "^9.1.0",
50-
"hap-nodejs": "0.9.2",
50+
"hap-nodejs": "0.9.3",
5151
"qrcode-terminal": "^0.12.0",
5252
"semver": "^7.3.4",
5353
"source-map-support": "^0.5.19"

src/bridgeService.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,9 @@ export class BridgeService {
169169
case CharacteristicWarningType.ERROR_MESSAGE:
170170
log.error(getLogPrefix(plugin.getPluginIdentifier()), `This plugin threw an error from the characteristic '${warning.characteristic.displayName}':`, warning.message + ".", wikiInfo);
171171
break;
172+
case CharacteristicWarningType.DEBUG_MESSAGE:
173+
log.debug(getLogPrefix(plugin.getPluginIdentifier()), `Characteristic '${warning.characteristic.displayName}':`, warning.message + ".", wikiInfo);
174+
break;
172175
default: // generic message for yet unknown types
173176
log.info(getLogPrefix(plugin.getPluginIdentifier()), `This plugin generated a warning from the characteristic '${warning.characteristic.displayName}':`, warning.message + ".", wikiInfo);
174177
break;
@@ -323,7 +326,12 @@ export class BridgeService {
323326
platformPlugins.configureAccessory(accessory);
324327
}
325328

326-
this.bridge.addBridgedAccessory(accessory._associatedHAPAccessory);
329+
try {
330+
this.bridge.addBridgedAccessory(accessory._associatedHAPAccessory);
331+
} catch (e) {
332+
log.warn(`${accessory._associatedPlugin ? getLogPrefix(accessory._associatedPlugin): ""} Could not restore cached accessory '${accessory._associatedHAPAccessory.displayName}':`, e?.message);
333+
return false; // filter it from the list
334+
}
327335
return true; // keep it in the list
328336
});
329337
}

src/ipcService.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export const enum IpcIncomingEvent {
66
}
77

88
export const enum IpcOutgoingEvent {
9+
SERVER_STATUS_UPDATE = "serverStatusUpdate",
910
CHILD_BRIDGE_METADATA_RESPONSE = "childBridgeMetadataResponse",
1011
CHILD_BRIDGE_STATUS_UPDATE = "childBridgeStatusUpdate",
1112
}

src/server.ts

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@ import fs from "fs";
22
import chalk from "chalk";
33
import qrcode from "qrcode-terminal";
44

5-
import { MacAddress, MDNSAdvertiser } from "hap-nodejs";
65
import * as mac from "./util/mac";
76
import { Logger } from "./logger";
87
import { User } from "./user";
98
import { Plugin } from "./plugin";
109
import { ChildBridgeService } from "./childBridgeService";
1110
import { ExternalPortService } from "./externalPortService";
11+
import {
12+
AccessoryEventTypes,
13+
MacAddress,
14+
MDNSAdvertiser,
15+
} from "hap-nodejs";
1216
import {
1317
IpcIncomingEvent,
1418
IpcOutgoingEvent,
@@ -50,6 +54,23 @@ export interface HomebridgeOptions {
5054
customStoragePath?: string;
5155
}
5256

57+
export const enum ServerStatus {
58+
/**
59+
* When the server is starting up
60+
*/
61+
PENDING = "pending",
62+
63+
/**
64+
* When the server is online and has published the main bridge
65+
*/
66+
OK = "ok",
67+
68+
/**
69+
* When the server is shutting down
70+
*/
71+
DOWN = "down",
72+
}
73+
5374
export class Server {
5475
private readonly api: HomebridgeAPI;
5576
private readonly pluginManager: PluginManager;
@@ -62,6 +83,9 @@ export class Server {
6283
// used to keep track of child bridges
6384
private readonly childBridges: Map<MacAddress, ChildBridgeService> = new Map();
6485

86+
// current server status
87+
private serverStatus: ServerStatus = ServerStatus.PENDING;
88+
6589
constructor(
6690
private options: HomebridgeOptions = {},
6791
) {
@@ -72,6 +96,9 @@ export class Server {
7296
this.ipcService = new IpcService();
7397
this.externalPortService = new ExternalPortService(this.config.ports);
7498

99+
// set status to pending
100+
this.setServerStatus(ServerStatus.PENDING);
101+
75102
// create new plugin manager
76103
const pluginManagerOptions: PluginManagerOptions = {
77104
activePlugins: this.config.plugins,
@@ -97,6 +124,22 @@ export class Server {
97124
this.config.bridge,
98125
this.config,
99126
);
127+
128+
// watch bridge events to check when server is online
129+
this.bridgeService.bridge.on(AccessoryEventTypes.LISTENING, () => {
130+
this.setServerStatus(ServerStatus.OK);
131+
});
132+
}
133+
134+
/**
135+
* Set the current server status and update parent via IPC
136+
* @param status
137+
*/
138+
private setServerStatus(status: ServerStatus) {
139+
this.serverStatus = status;
140+
this.ipcService.sendMessage(IpcOutgoingEvent.SERVER_STATUS_UPDATE, {
141+
status: this.serverStatus,
142+
});
100143
}
101144

102145
public async start(): Promise<void> {
@@ -136,6 +179,7 @@ export class Server {
136179

137180
public teardown(): void {
138181
this.bridgeService.teardown();
182+
this.setServerStatus(ServerStatus.DOWN);
139183
}
140184

141185
private publishBridge(): void {

0 commit comments

Comments
 (0)