homebridge-nest-accfactory 0.0.4-a → 0.0.6

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.
@@ -0,0 +1,97 @@
1
+ // Nest Cam with Floodlight
2
+ // Part of homebridge-nest-accfactory
3
+ //
4
+ // Code version 13/9/2024
5
+ // Mark Hulskamp
6
+ 'use strict';
7
+
8
+ // Define external module requirements
9
+ import NestCamera from './camera.js';
10
+
11
+ export default class NestFloodlight extends NestCamera {
12
+ lightService = undefined; // HomeKit light
13
+
14
+ constructor(accessory, api, log, eventEmitter, deviceData) {
15
+ super(accessory, api, log, eventEmitter, deviceData);
16
+ }
17
+
18
+ // Class functions
19
+ addServices() {
20
+ // Call parent to setup the common camera things. Once we return, we can add in the specifics for our floodlight
21
+ let postSetupDetails = super.addServices();
22
+
23
+ this.lightService = this.accessory.getService(this.hap.Service.Switch);
24
+ if (this.deviceData.has_light === true) {
25
+ // Add service to for a light, including brightness control
26
+ if (this.lightService === undefined) {
27
+ this.lightService = this.accessory.addService(this.hap.Service.Lightbulb, '', 1);
28
+ }
29
+
30
+ if (this.lightService.testCharacteristic(this.hap.Characteristic.Brightness) === false) {
31
+ this.lightService.addCharacteristic(this.hap.Characteristic.Brightness);
32
+ }
33
+
34
+ this.lightService.getCharacteristic(this.hap.Characteristic.Brightness).setProps({
35
+ minStep: 10, // Light only goes in 10% increments
36
+ });
37
+
38
+ // Setup set callback for this light service
39
+ this.lightService.getCharacteristic(this.hap.Characteristic.On).onSet((value) => {
40
+ if (value !== this.deviceData.light_enabled) {
41
+ this.set({ light_enabled: value });
42
+
43
+ this?.log?.info && this.log.info('Floodlight on "%s" was turned', this.deviceData.description, value === true ? 'on' : 'off');
44
+ }
45
+ });
46
+
47
+ this.lightService.getCharacteristic(this.hap.Characteristic.Brightness).onSet((value) => {
48
+ if (value !== this.deviceData.light_brightness) {
49
+ this.set({ light_brightness: value });
50
+
51
+ this?.log?.info && this.log.info('Floodlight brightness on "%s" was set to "%s %"', this.deviceData.description, value);
52
+ }
53
+ });
54
+
55
+ this.lightService.getCharacteristic(this.hap.Characteristic.On).onGet(() => {
56
+ return this.deviceData.light_enabled === true;
57
+ });
58
+
59
+ this.lightService.getCharacteristic(this.hap.Characteristic.Brightness).onGet(() => {
60
+ return this.deviceData.light_brightness;
61
+ });
62
+ }
63
+ if (this.lightService !== undefined && this.deviceData.has_light !== true) {
64
+ // No longer required to have the light service
65
+ this.accessory.removeService(this.lightService);
66
+ this.lightService === undefined;
67
+ }
68
+
69
+ // Create extra details for output
70
+ this.lightService !== undefined && postSetupDetails.push('Light support');
71
+ return postSetupDetails;
72
+ }
73
+
74
+ removeServices() {
75
+ super.removeServices();
76
+
77
+ if (this.lightService !== undefined) {
78
+ this.accessory.removeService(this.lightService);
79
+ }
80
+ this.lightService = undefined;
81
+ }
82
+
83
+ updateServices(deviceData) {
84
+ if (typeof deviceData !== 'object' || this.controller === undefined) {
85
+ return;
86
+ }
87
+
88
+ // Get the camera class todo all its updates first, then we'll handle the doorbell specific stuff
89
+ super.updateServices(deviceData);
90
+
91
+ if (this.lightService !== undefined) {
92
+ // Update status of light, including brightness
93
+ this.lightService.updateCharacteristic(this.hap.Characteristic.On, deviceData.light_enabled);
94
+ this.lightService.updateCharacteristic(this.hap.Characteristic.Brightness, deviceData.light_brightness);
95
+ }
96
+ }
97
+ }
package/dist/index.js CHANGED
@@ -5,18 +5,18 @@
5
5
  //
6
6
  // The following Nest devices are supported
7
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)
8
+ // Nest Thermostats (1st gen, 2nd gen, 3rd gen, E, 2020 mirror edition, 4th gen)
9
+ // Nest Protects (1st and 2nd gen)
10
+ // Nest Temp Sensors (1st gen)
11
+ // Nest Cameras (Cam Indoor, IQ Indoor, Outdoor, IQ Outdoor, Cam with Floodlight)
12
+ // Nest Doorbells (wired 1st gen)
13
13
  //
14
14
  // The accessory supports authentication to Nest/Google using either a Nest account OR Google (migrated Nest account) account.
15
15
  // "preliminary" support for using FieldTest account types also.
16
16
  //
17
- // Supports both Nest REST and protobuf APIs for communication to Nest systems
17
+ // Supports both Nest REST and Protobuf APIs for communication
18
18
  //
19
- // Code version 21/8/2024
19
+ // Code version 12/9/2024
20
20
  // Mark Hulskamp
21
21
  'use strict';
22
22