homebridge-nest-accfactory 0.0.4-a

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/LICENSE +176 -0
  3. package/README.md +121 -0
  4. package/config.schema.json +107 -0
  5. package/dist/HomeKitDevice.js +441 -0
  6. package/dist/HomeKitHistory.js +2835 -0
  7. package/dist/camera.js +1276 -0
  8. package/dist/doorbell.js +122 -0
  9. package/dist/index.js +35 -0
  10. package/dist/nexustalk.js +741 -0
  11. package/dist/protect.js +240 -0
  12. package/dist/protobuf/google/rpc/status.proto +91 -0
  13. package/dist/protobuf/google/rpc/stream_body.proto +26 -0
  14. package/dist/protobuf/google/trait/product/camera.proto +53 -0
  15. package/dist/protobuf/googlehome/foyer.proto +208 -0
  16. package/dist/protobuf/nest/messages.proto +8 -0
  17. package/dist/protobuf/nest/services/apigateway.proto +107 -0
  18. package/dist/protobuf/nest/trait/audio.proto +7 -0
  19. package/dist/protobuf/nest/trait/cellular.proto +313 -0
  20. package/dist/protobuf/nest/trait/debug.proto +37 -0
  21. package/dist/protobuf/nest/trait/detector.proto +41 -0
  22. package/dist/protobuf/nest/trait/diagnostics.proto +87 -0
  23. package/dist/protobuf/nest/trait/firmware.proto +221 -0
  24. package/dist/protobuf/nest/trait/guest.proto +105 -0
  25. package/dist/protobuf/nest/trait/history.proto +345 -0
  26. package/dist/protobuf/nest/trait/humanlibrary.proto +19 -0
  27. package/dist/protobuf/nest/trait/hvac.proto +1353 -0
  28. package/dist/protobuf/nest/trait/input.proto +29 -0
  29. package/dist/protobuf/nest/trait/lighting.proto +61 -0
  30. package/dist/protobuf/nest/trait/located.proto +193 -0
  31. package/dist/protobuf/nest/trait/media.proto +68 -0
  32. package/dist/protobuf/nest/trait/network.proto +352 -0
  33. package/dist/protobuf/nest/trait/occupancy.proto +373 -0
  34. package/dist/protobuf/nest/trait/olive.proto +15 -0
  35. package/dist/protobuf/nest/trait/pairing.proto +85 -0
  36. package/dist/protobuf/nest/trait/product/camera.proto +283 -0
  37. package/dist/protobuf/nest/trait/product/detect.proto +67 -0
  38. package/dist/protobuf/nest/trait/product/doorbell.proto +18 -0
  39. package/dist/protobuf/nest/trait/product/guard.proto +59 -0
  40. package/dist/protobuf/nest/trait/product/protect.proto +344 -0
  41. package/dist/protobuf/nest/trait/promonitoring.proto +14 -0
  42. package/dist/protobuf/nest/trait/resourcedirectory.proto +32 -0
  43. package/dist/protobuf/nest/trait/safety.proto +119 -0
  44. package/dist/protobuf/nest/trait/security.proto +516 -0
  45. package/dist/protobuf/nest/trait/selftest.proto +78 -0
  46. package/dist/protobuf/nest/trait/sensor.proto +291 -0
  47. package/dist/protobuf/nest/trait/service.proto +46 -0
  48. package/dist/protobuf/nest/trait/structure.proto +85 -0
  49. package/dist/protobuf/nest/trait/system.proto +51 -0
  50. package/dist/protobuf/nest/trait/test.proto +15 -0
  51. package/dist/protobuf/nest/trait/ui.proto +65 -0
  52. package/dist/protobuf/nest/trait/user.proto +98 -0
  53. package/dist/protobuf/nest/trait/voiceassistant.proto +30 -0
  54. package/dist/protobuf/nestlabs/eventingapi/v1.proto +83 -0
  55. package/dist/protobuf/nestlabs/gateway/v1.proto +273 -0
  56. package/dist/protobuf/nestlabs/gateway/v2.proto +96 -0
  57. package/dist/protobuf/nestlabs/history/v1.proto +73 -0
  58. package/dist/protobuf/root.proto +64 -0
  59. package/dist/protobuf/wdl-event-importance.proto +11 -0
  60. package/dist/protobuf/wdl.proto +450 -0
  61. package/dist/protobuf/weave/common.proto +144 -0
  62. package/dist/protobuf/weave/trait/audio.proto +12 -0
  63. package/dist/protobuf/weave/trait/auth.proto +22 -0
  64. package/dist/protobuf/weave/trait/description.proto +32 -0
  65. package/dist/protobuf/weave/trait/heartbeat.proto +38 -0
  66. package/dist/protobuf/weave/trait/locale.proto +20 -0
  67. package/dist/protobuf/weave/trait/network.proto +24 -0
  68. package/dist/protobuf/weave/trait/pairing.proto +8 -0
  69. package/dist/protobuf/weave/trait/peerdevices.proto +18 -0
  70. package/dist/protobuf/weave/trait/power.proto +86 -0
  71. package/dist/protobuf/weave/trait/schedule.proto +76 -0
  72. package/dist/protobuf/weave/trait/security.proto +343 -0
  73. package/dist/protobuf/weave/trait/telemetry/tunnel.proto +37 -0
  74. package/dist/protobuf/weave/trait/time.proto +16 -0
  75. package/dist/res/Nest_camera_connecting.h264 +0 -0
  76. package/dist/res/Nest_camera_connecting.jpg +0 -0
  77. package/dist/res/Nest_camera_off.h264 +0 -0
  78. package/dist/res/Nest_camera_off.jpg +0 -0
  79. package/dist/res/Nest_camera_offline.h264 +0 -0
  80. package/dist/res/Nest_camera_offline.jpg +0 -0
  81. package/dist/res/Nest_camera_transfer.jpg +0 -0
  82. package/dist/streamer.js +344 -0
  83. package/dist/system.js +3112 -0
  84. package/dist/tempsensor.js +99 -0
  85. package/dist/thermostat.js +1026 -0
  86. package/dist/weather.js +205 -0
  87. package/dist/webrtc.js +55 -0
  88. package/package.json +66 -0
@@ -0,0 +1,122 @@
1
+ // Nest Doorbell(s)
2
+ // Part of homebridge-nest-accfactory
3
+ //
4
+ // Code version 6/9/2024
5
+ // Mark Hulskamp
6
+ 'use strict';
7
+
8
+ // Define nodejs module requirements
9
+ import { setTimeout, clearTimeout } from 'node:timers';
10
+
11
+ // Define external module requirements
12
+ import NestCamera from './camera.js';
13
+
14
+ export default class NestDoorbell extends NestCamera {
15
+ doorbellTimer = undefined; // Cooldown timer for doorbell events
16
+ switchService = undefined; // HomeKit switch for enabling/disabling chime
17
+
18
+ constructor(accessory, api, log, eventEmitter, deviceData) {
19
+ super(accessory, api, log, eventEmitter, deviceData);
20
+ }
21
+
22
+ // Class functions
23
+ addServices() {
24
+ // Setup some details around the doorbell BEFORE will call out parent addServices function
25
+ this.createCameraMotionServices();
26
+ this.controller = new this.hap.DoorbellController(this.generateControllerOptions());
27
+ this.accessory.configureController(this.controller);
28
+
29
+ // Call parent to setup the common camera things. Once we return, we can add in the specifics for our doorbell
30
+ let postSetupDetails = super.addServices();
31
+
32
+ this.switchService = this.accessory.getService(this.hap.Service.Switch);
33
+ if (this.deviceData.has_indoor_chime === true && this.deviceData.chimeSwitch === true) {
34
+ // Add service to allow automation and enabling/disabling indoor chiming.
35
+ // This needs to be explically enabled via a configuration option for the device
36
+ if (this.switchService === undefined) {
37
+ this.switchService = this.accessory.addService(this.hap.Service.Switch, '', 1);
38
+ }
39
+
40
+ // Setup set callback for this switch service
41
+ this.switchService.getCharacteristic(this.hap.Characteristic.On).onSet((value) => {
42
+ if (value !== this.deviceData.indoor_chime_enabled) {
43
+ // only change indoor chime status value if different than on-device
44
+ this.set({ 'doorbell.indoor_chime.enabled': value });
45
+
46
+ this?.log?.info && this.log.info('Indoor chime on "%s" was turned', this.deviceData.description, value === true ? 'on' : 'off');
47
+ }
48
+ });
49
+
50
+ this.switchService.getCharacteristic(this.hap.Characteristic.On).onGet(() => {
51
+ return this.deviceData.indoor_chime_enabled === true;
52
+ });
53
+ }
54
+ if (this.switchService !== undefined && (this.deviceData.has_indoor_chime === false || this.deviceData.chimeSwitch === false)) {
55
+ // No longer required to have the switch service
56
+ // This is to handle Homebridge cached restored accessories and if configuration options have changed
57
+ this.accessory.removeService(this.switchService);
58
+ this.switchService === undefined;
59
+ }
60
+
61
+ // Create extra details for output
62
+ this.switchService !== undefined && postSetupDetails.push('Chime switch');
63
+ return postSetupDetails;
64
+ }
65
+
66
+ removeServices() {
67
+ super.removeServices();
68
+
69
+ this.doorbellTimer = clearTimeout(this.doorbellTimer);
70
+ if (this.switchService !== undefined) {
71
+ this.accessory.removeService(this.switchService);
72
+ }
73
+ this.switchService = undefined;
74
+ }
75
+
76
+ updateServices(deviceData) {
77
+ if (typeof deviceData !== 'object' || this.controller === undefined) {
78
+ return;
79
+ }
80
+
81
+ // Get the camera class todo all its updates first, then we'll handle the doorbell specific stuff
82
+ super.updateServices(deviceData);
83
+
84
+ if (this.switchService !== undefined) {
85
+ // Update status of indoor chime enable/disable switch
86
+ this.switchService.updateCharacteristic(this.hap.Characteristic.On, deviceData.indoor_chime_enabled);
87
+ }
88
+
89
+ deviceData.alerts.forEach((event) => {
90
+ // Handle doorbell event, should always be handled first
91
+ if (event.types.includes('doorbell') === true && this.doorbellTimer === undefined) {
92
+ // Cooldown for doorbell button being pressed (filters out constant pressing for time period)
93
+ // Start this before we process further
94
+ this.doorbellTimer = setTimeout(() => {
95
+ this.doorbellTimer = undefined; // No doorbell timer active
96
+ }, this.deviceData.doorbellCooldown * 1000);
97
+
98
+ if (deviceData.indoor_chime_enabled === false || deviceData.quiet_time_enabled === true) {
99
+ // Indoor chime is disabled or quiet time is enabled, so we won't 'ring' the doorbell
100
+ this?.log?.warn && this.log.warn('Doorbell rung at "%s" but indoor chime is silenced', this.deviceData.description);
101
+ }
102
+ if (deviceData.indoor_chime_enabled === true && deviceData.quiet_time_enabled === false) {
103
+ // Indoor chime is enabled and quiet time isn't enabled, so 'ring' the doorbell
104
+ this?.log?.info && this.log.info('Doorbell rung at "%s"', this.deviceData.description);
105
+ this.controller.ringDoorbell();
106
+ }
107
+
108
+ if (this.controller?.doorbellService !== undefined && typeof this.historyService?.addHistory === 'function') {
109
+ // Record a doorbell press and unpress event to our history
110
+ this.historyService.addHistory(this.controller.doorbellService, {
111
+ time: Math.floor(Date.now() / 1000),
112
+ status: 1,
113
+ });
114
+ this.historyService.addHistory(this.controller.doorbellService, {
115
+ time: Math.floor(Date.now() / 1000),
116
+ status: 0,
117
+ });
118
+ }
119
+ }
120
+ });
121
+ }
122
+ }
package/dist/index.js ADDED
@@ -0,0 +1,35 @@
1
+ // Homebridge platform allowing Nest devices to be used with HomeKit
2
+ // This is a port from my standalone project, Nest_accfactory to Homebridge
3
+ //
4
+ // This includes having support for HomeKit Secure Video (HKSV) on doorbells and cameras
5
+ //
6
+ // The following Nest devices are supported
7
+ //
8
+ // Nest Thermostats (Gen 1, Gen 2, Gen 3, E, Mirrored 2020)
9
+ // Nest Protects (Gen 1, Gen 2)
10
+ // Nest Temperature Sensors
11
+ // Nest Cameras (Cam Indoor, IQ Indoor, Outdoor, IQ Outdoor)
12
+ // Nest Hello (Wired Gen 1)
13
+ //
14
+ // The accessory supports authentication to Nest/Google using either a Nest account OR Google (migrated Nest account) account.
15
+ // "preliminary" support for using FieldTest account types also.
16
+ //
17
+ // Supports both Nest REST and protobuf APIs for communication to Nest systems
18
+ //
19
+ // Code version 21/8/2024
20
+ // Mark Hulskamp
21
+ 'use strict';
22
+
23
+ // Import our modules
24
+ import NestAccfactory from './system.js';
25
+ import HomeKitDevice from './HomeKitDevice.js';
26
+ HomeKitDevice.PLUGIN_NAME = 'homebridge-nest-accfactory';
27
+ HomeKitDevice.PLATFORM_NAME = 'NestAccfactory';
28
+
29
+ import HomeKitHistory from './HomeKitHistory.js';
30
+ HomeKitDevice.HISTORY = HomeKitHistory;
31
+
32
+ export default (api) => {
33
+ // Register our platform with HomeBridge
34
+ api.registerPlatform(HomeKitDevice.PLATFORM_NAME, NestAccfactory);
35
+ };