homebridge-nest-accfactory 0.2.11 → 0.3.0
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.
- package/CHANGELOG.md +24 -0
- package/README.md +14 -7
- package/config.schema.json +118 -0
- package/dist/HomeKitDevice.js +194 -77
- package/dist/HomeKitHistory.js +1 -1
- package/dist/config.js +207 -0
- package/dist/devices.js +113 -0
- package/dist/index.js +2 -1
- package/dist/nexustalk.js +19 -21
- package/dist/{camera.js → plugins/camera.js} +212 -239
- package/dist/{doorbell.js → plugins/doorbell.js} +32 -30
- package/dist/plugins/floodlight.js +91 -0
- package/dist/plugins/heatlink.js +17 -0
- package/dist/{protect.js → plugins/protect.js} +24 -41
- package/dist/{tempsensor.js → plugins/tempsensor.js} +13 -17
- package/dist/{thermostat.js → plugins/thermostat.js} +424 -381
- package/dist/{weather.js → plugins/weather.js} +26 -60
- package/dist/protobuf/nest/services/apigateway.proto +31 -1
- package/dist/protobuf/nest/trait/firmware.proto +207 -89
- package/dist/protobuf/nest/trait/hvac.proto +1052 -312
- package/dist/protobuf/nest/trait/located.proto +51 -8
- package/dist/protobuf/nest/trait/network.proto +366 -36
- package/dist/protobuf/nest/trait/occupancy.proto +145 -17
- package/dist/protobuf/nest/trait/product/protect.proto +57 -43
- package/dist/protobuf/nest/trait/resourcedirectory.proto +8 -0
- package/dist/protobuf/nest/trait/sensor.proto +7 -1
- package/dist/protobuf/nest/trait/service.proto +3 -1
- package/dist/protobuf/nest/trait/structure.proto +60 -14
- package/dist/protobuf/nest/trait/ui.proto +41 -1
- package/dist/protobuf/nest/trait/user.proto +6 -1
- package/dist/protobuf/nest/trait/voiceassistant.proto +2 -1
- package/dist/protobuf/nestlabs/eventingapi/v1.proto +20 -1
- package/dist/protobuf/root.proto +1 -0
- package/dist/protobuf/wdl.proto +18 -2
- package/dist/protobuf/weave/common.proto +2 -1
- package/dist/protobuf/weave/trait/heartbeat.proto +41 -1
- package/dist/protobuf/weave/trait/power.proto +1 -0
- package/dist/protobuf/weave/trait/security.proto +10 -1
- package/dist/streamer.js +68 -72
- package/dist/system.js +1208 -1245
- package/dist/webrtc.js +28 -23
- package/package.json +12 -12
- package/dist/floodlight.js +0 -97
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// Nest Doorbell(s)
|
|
2
2
|
// Part of homebridge-nest-accfactory
|
|
3
3
|
//
|
|
4
|
-
// Code version 2025/03/19
|
|
5
4
|
// Mark Hulskamp
|
|
6
5
|
'use strict';
|
|
7
6
|
|
|
@@ -12,6 +11,9 @@ import { setTimeout, clearTimeout } from 'node:timers';
|
|
|
12
11
|
import NestCamera from './camera.js';
|
|
13
12
|
|
|
14
13
|
export default class NestDoorbell extends NestCamera {
|
|
14
|
+
static TYPE = 'Doorbell';
|
|
15
|
+
static VERSION = '2025.06.11';
|
|
16
|
+
|
|
15
17
|
doorbellTimer = undefined; // Cooldown timer for doorbell events
|
|
16
18
|
switchService = undefined; // HomeKit switch for enabling/disabling chime
|
|
17
19
|
|
|
@@ -20,47 +22,47 @@ export default class NestDoorbell extends NestCamera {
|
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
// Class functions
|
|
23
|
-
|
|
25
|
+
setupDevice() {
|
|
24
26
|
// Call parent to setup the common camera things. Once we return, we can add in the specifics for our doorbell
|
|
25
27
|
// We pass in the HAP Doorbell controller constructor function here also
|
|
26
|
-
|
|
28
|
+
super.setupDevice(this.hap.DoorbellController);
|
|
27
29
|
|
|
28
|
-
this.
|
|
29
|
-
if (this.deviceData.has_indoor_chime === true && this.deviceData.chimeSwitch === true) {
|
|
30
|
+
if (this.deviceData?.has_indoor_chime === true && this.deviceData?.chimeSwitch === true) {
|
|
30
31
|
// Add service to allow automation and enabling/disabling indoor chiming.
|
|
31
32
|
// This needs to be explically enabled via a configuration option for the device
|
|
32
|
-
|
|
33
|
-
this.switchService = this.accessory.addService(this.hap.Service.Switch, '', 1);
|
|
34
|
-
}
|
|
33
|
+
this.switchService = this.addHKService(this.hap.Service.Switch, '', 1);
|
|
35
34
|
|
|
36
35
|
// Setup set callback for this switch service
|
|
37
|
-
this.
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
36
|
+
this.addHKCharacteristic(this.switchService, this.hap.Characteristic.On, {
|
|
37
|
+
onSet: (value) => {
|
|
38
|
+
if (value !== this.deviceData.indoor_chime_enabled) {
|
|
39
|
+
// only change indoor chime status value if different than on-device
|
|
40
|
+
this.set({ uuid: this.deviceData.nest_google_uuid, indoor_chime_enabled: value });
|
|
41
|
+
|
|
42
|
+
this?.log?.info?.('Indoor chime on "%s" was turned', this.deviceData.description, value === true ? 'on' : 'off');
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
onGet: () => {
|
|
46
|
+
return this.deviceData.indoor_chime_enabled === true;
|
|
47
|
+
},
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
|
-
if (this.
|
|
50
|
+
if (this.deviceData?.has_indoor_chime === false || this.deviceData?.chimeSwitch === false) {
|
|
51
51
|
// No longer required to have the switch service
|
|
52
52
|
// This is to handle Homebridge cached restored accessories and if configuration options have changed
|
|
53
|
-
this.accessory.
|
|
53
|
+
this.switchService = this.accessory.getService(this.hap.Service.Switch);
|
|
54
|
+
if (this.switchService !== undefined) {
|
|
55
|
+
this.accessory.removeService(this.switchService);
|
|
56
|
+
}
|
|
54
57
|
this.switchService = undefined;
|
|
55
58
|
}
|
|
56
59
|
|
|
57
|
-
//
|
|
58
|
-
this.switchService !== undefined &&
|
|
59
|
-
return postSetupDetails;
|
|
60
|
+
// Extra setup details for output
|
|
61
|
+
this.switchService !== undefined && this.postSetupDetail('Chime switch');
|
|
60
62
|
}
|
|
61
63
|
|
|
62
|
-
|
|
63
|
-
super.
|
|
64
|
+
removeDevice() {
|
|
65
|
+
super.removeDevice();
|
|
64
66
|
|
|
65
67
|
clearTimeout(this.doorbellTimer);
|
|
66
68
|
this.doorbellTimer = undefined;
|
|
@@ -71,13 +73,13 @@ export default class NestDoorbell extends NestCamera {
|
|
|
71
73
|
this.switchService = undefined;
|
|
72
74
|
}
|
|
73
75
|
|
|
74
|
-
|
|
76
|
+
updateDevice(deviceData) {
|
|
75
77
|
if (typeof deviceData !== 'object' || this.controller === undefined) {
|
|
76
78
|
return;
|
|
77
79
|
}
|
|
78
80
|
|
|
79
81
|
// Get the camera class todo all its updates first, then we'll handle the doorbell specific stuff
|
|
80
|
-
super.
|
|
82
|
+
super.updateDevice(deviceData);
|
|
81
83
|
|
|
82
84
|
if (this.switchService !== undefined) {
|
|
83
85
|
// Update status of indoor chime enable/disable switch
|
|
@@ -95,11 +97,11 @@ export default class NestDoorbell extends NestCamera {
|
|
|
95
97
|
|
|
96
98
|
if (deviceData.indoor_chime_enabled === false || deviceData.quiet_time_enabled === true) {
|
|
97
99
|
// Indoor chime is disabled or quiet time is enabled, so we won't 'ring' the doorbell
|
|
98
|
-
this?.log?.warn
|
|
100
|
+
this?.log?.warn?.('Doorbell rung at "%s" but indoor chime is silenced', deviceData.description);
|
|
99
101
|
}
|
|
100
102
|
if (deviceData.indoor_chime_enabled === true && deviceData.quiet_time_enabled === false) {
|
|
101
103
|
// Indoor chime is enabled and quiet time isn't enabled, so 'ring' the doorbell
|
|
102
|
-
this?.log?.info
|
|
104
|
+
this?.log?.info?.('Doorbell rung at "%s"', deviceData.description);
|
|
103
105
|
this.controller.ringDoorbell();
|
|
104
106
|
}
|
|
105
107
|
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// Nest Cam with Floodlight
|
|
2
|
+
// Part of homebridge-nest-accfactory
|
|
3
|
+
//
|
|
4
|
+
// Mark Hulskamp
|
|
5
|
+
'use strict';
|
|
6
|
+
|
|
7
|
+
// Define external module requirements
|
|
8
|
+
import NestCamera from './camera.js';
|
|
9
|
+
|
|
10
|
+
export default class NestFloodlight extends NestCamera {
|
|
11
|
+
static TYPE = 'FloodlightCamera';
|
|
12
|
+
static VERSION = '2025.06.11';
|
|
13
|
+
|
|
14
|
+
lightService = undefined; // HomeKit light
|
|
15
|
+
|
|
16
|
+
constructor(accessory, api, log, eventEmitter, deviceData) {
|
|
17
|
+
super(accessory, api, log, eventEmitter, deviceData);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Class functions
|
|
21
|
+
setupDevice() {
|
|
22
|
+
// Call parent to setup the common camera things. Once we return, we can add in the specifics for our floodlight
|
|
23
|
+
super.setupDevice();
|
|
24
|
+
|
|
25
|
+
if (this.deviceData.has_light === true) {
|
|
26
|
+
// Add service to for a light, including brightness control
|
|
27
|
+
this.lightService = this.addHKService(this.hap.Service.Lightbulb, '', 1);
|
|
28
|
+
this.addHKCharacteristic(this.lightService, this.hap.Characteristic.Brightness, {
|
|
29
|
+
props: { minStep: 10 }, // Light only goes in 10% increments
|
|
30
|
+
onSet: (value) => {
|
|
31
|
+
if (value !== this.deviceData.light_brightness) {
|
|
32
|
+
this.set({ uuid: this.deviceData.nest_google_uuid, light_brightness: value });
|
|
33
|
+
|
|
34
|
+
this?.log?.info?.('Floodlight brightness on "%s" was set to "%s %"', this.deviceData.description, value);
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
onGet: () => {
|
|
38
|
+
return this.deviceData.light_brightness;
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
this.addHKCharacteristic(this.lightService, this.hap.Characteristic.On, {
|
|
43
|
+
onSet: (value) => {
|
|
44
|
+
if (value !== this.deviceData.light_enabled) {
|
|
45
|
+
this.set({ uuid: this.deviceData.nest_google_uuid, light_enabled: value });
|
|
46
|
+
|
|
47
|
+
this?.log?.info?.('Floodlight on "%s" was turned', this.deviceData.description, value === true ? 'on' : 'off');
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
onGet: () => {
|
|
51
|
+
return this.deviceData.light_enabled === true;
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
if (this.deviceData.has_light !== true) {
|
|
56
|
+
// No longer required to have the light service
|
|
57
|
+
this.lightService = this.accessory.getService(this.hap.Service.Lightbulb);
|
|
58
|
+
if (this.lightService !== undefined) {
|
|
59
|
+
this.accessory.removeService(this.lightService);
|
|
60
|
+
}
|
|
61
|
+
this.lightService === undefined;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Extra setup details for output
|
|
65
|
+
this.lightService !== undefined && this.postSetupDetails('Light support');
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
removeDevice() {
|
|
69
|
+
super.removeDevice();
|
|
70
|
+
|
|
71
|
+
if (this.lightService !== undefined) {
|
|
72
|
+
this.accessory.removeService(this.lightService);
|
|
73
|
+
}
|
|
74
|
+
this.lightService = undefined;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
updateDevice(deviceData) {
|
|
78
|
+
if (typeof deviceData !== 'object' || this.controller === undefined) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Get the camera class todo all its updates first, then we'll handle the doorbell specific stuff
|
|
83
|
+
super.updateDevice(deviceData);
|
|
84
|
+
|
|
85
|
+
if (this.lightService !== undefined) {
|
|
86
|
+
// Update status of light, including brightness
|
|
87
|
+
this.lightService.updateCharacteristic(this.hap.Characteristic.On, deviceData.light_enabled);
|
|
88
|
+
this.lightService.updateCharacteristic(this.hap.Characteristic.Brightness, deviceData.light_brightness);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Nest Heatlink
|
|
2
|
+
// Part of homebridge-nest-accfactory
|
|
3
|
+
//
|
|
4
|
+
// Mark Hulskamp
|
|
5
|
+
'use strict';
|
|
6
|
+
|
|
7
|
+
// Define our modules
|
|
8
|
+
import NestTemperatureSensor from './tempsensor.js';
|
|
9
|
+
|
|
10
|
+
export default class NestHeatlink extends NestTemperatureSensor {
|
|
11
|
+
static TYPE = 'Heatlink';
|
|
12
|
+
static VERSION = '2025.06.11';
|
|
13
|
+
|
|
14
|
+
constructor(accessory, api, log, eventEmitter, deviceData) {
|
|
15
|
+
super(accessory, api, log, eventEmitter, deviceData);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
// Nest Protect
|
|
2
2
|
// Part of homebridge-nest-accfactory
|
|
3
3
|
//
|
|
4
|
-
// Code version 2025/01/17
|
|
5
4
|
// Mark Hulskamp
|
|
6
5
|
'use strict';
|
|
7
6
|
|
|
8
7
|
// Define our modules
|
|
9
|
-
import HomeKitDevice from '
|
|
8
|
+
import HomeKitDevice from '../HomeKitDevice.js';
|
|
10
9
|
|
|
11
10
|
const LOWBATTERYLEVEL = 10; // Low battery level percentage
|
|
12
11
|
|
|
13
12
|
export default class NestProtect extends HomeKitDevice {
|
|
13
|
+
static TYPE = 'Protect';
|
|
14
|
+
static VERSION = '2025.06.11';
|
|
15
|
+
|
|
14
16
|
batteryService = undefined;
|
|
15
17
|
smokeService = undefined;
|
|
16
18
|
motionService = undefined;
|
|
@@ -21,43 +23,25 @@ export default class NestProtect extends HomeKitDevice {
|
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
// Class functions
|
|
24
|
-
|
|
25
|
-
// Create extra details for output
|
|
26
|
-
let postSetupDetails = [];
|
|
27
|
-
|
|
26
|
+
setupDevice() {
|
|
28
27
|
// Setup the smoke sensor service if not already present on the accessory
|
|
29
|
-
this.smokeService = this.
|
|
30
|
-
if (this.smokeService === undefined) {
|
|
31
|
-
this.smokeService = this.accessory.addService(this.hap.Service.SmokeSensor, '', 1);
|
|
32
|
-
}
|
|
33
|
-
if (this.smokeService.testCharacteristic(this.hap.Characteristic.StatusActive) === false) {
|
|
34
|
-
this.smokeService.addCharacteristic(this.hap.Characteristic.StatusActive);
|
|
35
|
-
}
|
|
36
|
-
if (this.smokeService.testCharacteristic(this.hap.Characteristic.StatusFault) === false) {
|
|
37
|
-
this.smokeService.addCharacteristic(this.hap.Characteristic.StatusFault);
|
|
38
|
-
}
|
|
28
|
+
this.smokeService = this.addHKService(this.hap.Service.SmokeSensor, '', 1);
|
|
39
29
|
this.smokeService.setPrimaryService();
|
|
40
30
|
|
|
31
|
+
this.addHKCharacteristic(this.smokeService, this.hap.Characteristic.StatusActive);
|
|
32
|
+
this.addHKCharacteristic(this.smokeService, this.hap.Characteristic.StatusFault);
|
|
33
|
+
|
|
41
34
|
// Setup the carbon monoxide service if not already present on the accessory
|
|
42
|
-
this.carbonMonoxideService = this.
|
|
43
|
-
if (this.carbonMonoxideService === undefined) {
|
|
44
|
-
this.carbonMonoxideService = this.accessory.addService(this.hap.Service.CarbonMonoxideSensor, '', 1);
|
|
45
|
-
}
|
|
35
|
+
this.carbonMonoxideService = this.addHKService(this.hap.Service.CarbonMonoxideSensor, '', 1);
|
|
46
36
|
|
|
47
37
|
// Setup battery service if not already present on the accessory
|
|
48
|
-
this.batteryService = this.
|
|
49
|
-
if (this.batteryService === undefined) {
|
|
50
|
-
this.batteryService = this.accessory.addService(this.hap.Service.Battery, '', 1);
|
|
51
|
-
}
|
|
38
|
+
this.batteryService = this.addHKService(this.hap.Service.Battery, '', 1);
|
|
52
39
|
this.batteryService.setHiddenService(true);
|
|
53
40
|
|
|
54
41
|
// Setup motion service if not already present on the accessory and Nest protect is a wired version
|
|
55
|
-
if (
|
|
56
|
-
this.motionService = this.
|
|
57
|
-
|
|
58
|
-
this.motionService = this.accessory.addService(this.hap.Service.MotionSensor, '', 1);
|
|
59
|
-
}
|
|
60
|
-
postSetupDetails.push('With motion sensor');
|
|
42
|
+
if (this.deviceData?.wired_or_battery === 0) {
|
|
43
|
+
this.motionService = this.addHKService(this.hap.Service.MotionSensor, '', 1);
|
|
44
|
+
this.postSetupDetail('With motion sensor');
|
|
61
45
|
}
|
|
62
46
|
|
|
63
47
|
// Setup linkage to EveHome app if configured todo so
|
|
@@ -79,11 +63,9 @@ export default class NestProtect extends HomeKitDevice {
|
|
|
79
63
|
EveSmoke_heattestpassed: this.deviceData.heat_test_passed,
|
|
80
64
|
});
|
|
81
65
|
}
|
|
82
|
-
|
|
83
|
-
return postSetupDetails;
|
|
84
66
|
}
|
|
85
67
|
|
|
86
|
-
|
|
68
|
+
updateDevice(deviceData) {
|
|
87
69
|
if (
|
|
88
70
|
typeof deviceData !== 'object' ||
|
|
89
71
|
this.smokeService === undefined ||
|
|
@@ -101,6 +83,7 @@ export default class NestProtect extends HomeKitDevice {
|
|
|
101
83
|
? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL
|
|
102
84
|
: this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW,
|
|
103
85
|
);
|
|
86
|
+
this.batteryService.updateCharacteristic(this.hap.Characteristic.ChargingState, this.hap.Characteristic.ChargingState.NOT_CHARGEABLE);
|
|
104
87
|
|
|
105
88
|
// Update smoke details
|
|
106
89
|
// If protect isn't online, replacement date past, report in HomeKit
|
|
@@ -124,11 +107,11 @@ export default class NestProtect extends HomeKitDevice {
|
|
|
124
107
|
);
|
|
125
108
|
|
|
126
109
|
if (deviceData.smoke_status === true && this.deviceData.smoke_status === false) {
|
|
127
|
-
this?.log?.warn
|
|
110
|
+
this?.log?.warn?.('Smoke detected in "%s"', deviceData.description);
|
|
128
111
|
}
|
|
129
112
|
|
|
130
113
|
if (deviceData.smoke_status === false && this.deviceData.smoke_status === true) {
|
|
131
|
-
this?.log?.info
|
|
114
|
+
this?.log?.info?.('Smoke is nolonger detected in "%s"', deviceData.description);
|
|
132
115
|
}
|
|
133
116
|
|
|
134
117
|
// Update carbon monoxide details
|
|
@@ -140,20 +123,20 @@ export default class NestProtect extends HomeKitDevice {
|
|
|
140
123
|
);
|
|
141
124
|
|
|
142
125
|
if (deviceData.co_status === true && this.deviceData.co_status === false) {
|
|
143
|
-
this?.log?.warn
|
|
126
|
+
this?.log?.warn?.('Abnormal carbon monoxide levels detected in "%s"', deviceData.description);
|
|
144
127
|
}
|
|
145
128
|
|
|
146
129
|
if (deviceData.co_status === false && this.deviceData.co_status === true) {
|
|
147
|
-
this?.log?.info
|
|
130
|
+
this?.log?.info?.('Carbon monoxide levels have returned to normal in "%s"', deviceData.description);
|
|
148
131
|
}
|
|
149
132
|
|
|
150
133
|
// Update self testing details
|
|
151
134
|
if (deviceData.self_test_in_progress === true && this.deviceData.self_test_in_progress === false) {
|
|
152
|
-
this?.log?.warn
|
|
135
|
+
this?.log?.warn?.('Smoke and Carbon monoxide sensor testing has started in "%s"', deviceData.description);
|
|
153
136
|
}
|
|
154
137
|
|
|
155
138
|
if (deviceData.self_test_in_progress === false && this.deviceData.self_test_in_progress === true) {
|
|
156
|
-
this?.log?.info
|
|
139
|
+
this?.log?.info?.('Smoke and Carbon monoxide sensor testing completed in "%s"', deviceData.description);
|
|
157
140
|
}
|
|
158
141
|
|
|
159
142
|
// Update motion service if present
|
|
@@ -161,7 +144,7 @@ export default class NestProtect extends HomeKitDevice {
|
|
|
161
144
|
this.motionService.updateCharacteristic(this.hap.Characteristic.MotionDetected, deviceData.detected_motion === true);
|
|
162
145
|
|
|
163
146
|
if (deviceData.detected_motion === true && this.deviceData.detected_motion === false) {
|
|
164
|
-
this?.log?.info
|
|
147
|
+
this?.log?.info?.('Motion detected in "%s"', deviceData.description);
|
|
165
148
|
}
|
|
166
149
|
|
|
167
150
|
// Log motion to history only if changed to previous recording
|
|
@@ -211,7 +194,7 @@ export default class NestProtect extends HomeKitDevice {
|
|
|
211
194
|
}
|
|
212
195
|
|
|
213
196
|
if (typeof EveHomeSetData?.alarmtest === 'boolean') {
|
|
214
|
-
//this
|
|
197
|
+
//this?.log?.info?.('Eve Smoke Alarm test', (EveHomeSetData.alarmtest === true ? 'start' : 'stop'));
|
|
215
198
|
}
|
|
216
199
|
if (typeof EveHomeSetData?.statusled === 'boolean') {
|
|
217
200
|
this.set({ uuid: this.deviceData.nest_google_uuid, ntp_green_led_enable: EveHomeSetData.statusled });
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
// Nest Temperature Sensor
|
|
2
2
|
// Part of homebridge-nest-accfactory
|
|
3
3
|
//
|
|
4
|
-
// Code version 27/8/2024
|
|
5
4
|
// Mark Hulskamp
|
|
6
5
|
'use strict';
|
|
7
6
|
|
|
8
7
|
// Define our modules
|
|
9
|
-
import HomeKitDevice from '
|
|
8
|
+
import HomeKitDevice from '../HomeKitDevice.js';
|
|
10
9
|
|
|
11
10
|
const LOWBATTERYLEVEL = 10; // Low battery level percentage
|
|
12
11
|
|
|
13
12
|
export default class NestTemperatureSensor extends HomeKitDevice {
|
|
13
|
+
static TYPE = 'TemperatureSensor';
|
|
14
|
+
static VERSION = '2025.06.11';
|
|
15
|
+
|
|
14
16
|
batteryService = undefined;
|
|
15
17
|
temperatureService = undefined;
|
|
16
18
|
|
|
@@ -19,19 +21,13 @@ export default class NestTemperatureSensor extends HomeKitDevice {
|
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
// Class functions
|
|
22
|
-
|
|
23
|
-
// Setup
|
|
24
|
-
this.temperatureService = this.
|
|
25
|
-
if (this.temperatureService === undefined) {
|
|
26
|
-
this.temperatureService = this.accessory.addService(this.hap.Service.TemperatureSensor, '', 1);
|
|
27
|
-
}
|
|
24
|
+
setupDevice() {
|
|
25
|
+
// Setup temperature service if not already present on the accessory
|
|
26
|
+
this.temperatureService = this.addHKService(this.hap.Service.TemperatureSensor, '', 1);
|
|
28
27
|
this.temperatureService.setPrimaryService();
|
|
29
28
|
|
|
30
|
-
// Setup
|
|
31
|
-
this.batteryService = this.
|
|
32
|
-
if (this.batteryService === undefined) {
|
|
33
|
-
this.batteryService = this.accessory.addService(this.hap.Service.Battery, '', 1);
|
|
34
|
-
}
|
|
29
|
+
// Setup battery service if not already present on the accessory
|
|
30
|
+
this.batteryService = this.addHKService(this.hap.Service.Battery, '', 1);
|
|
35
31
|
this.batteryService.setHiddenService(true);
|
|
36
32
|
|
|
37
33
|
// Setup linkage to EveHome app if configured todo so
|
|
@@ -46,7 +42,7 @@ export default class NestTemperatureSensor extends HomeKitDevice {
|
|
|
46
42
|
}
|
|
47
43
|
}
|
|
48
44
|
|
|
49
|
-
|
|
45
|
+
updateDevice(deviceData) {
|
|
50
46
|
if (typeof deviceData !== 'object' || this.temperatureService === undefined || this.batteryService === undefined) {
|
|
51
47
|
return;
|
|
52
48
|
}
|
|
@@ -57,10 +53,10 @@ export default class NestTemperatureSensor extends HomeKitDevice {
|
|
|
57
53
|
deviceData.online === true ? this.hap.Characteristic.StatusFault.NO_FAULT : this.hap.Characteristic.StatusFault.GENERAL_FAULT,
|
|
58
54
|
);
|
|
59
55
|
|
|
60
|
-
this.temperatureService.updateCharacteristic(this.hap.Characteristic.StatusActive, deviceData.online);
|
|
56
|
+
this.temperatureService.updateCharacteristic(this.hap.Characteristic.StatusActive, deviceData.online === true);
|
|
61
57
|
if (typeof deviceData?.associated_thermostat === 'string' && deviceData.associated_thermostat !== '') {
|
|
62
|
-
// This
|
|
63
|
-
// Update
|
|
58
|
+
// This temperature sensor is assocated with a thermostat
|
|
59
|
+
// Update status if providing active temperature for the thermostats
|
|
64
60
|
this.temperatureService.updateCharacteristic(
|
|
65
61
|
this.hap.Characteristic.StatusActive,
|
|
66
62
|
deviceData.online === true && deviceData?.active_sensor === true,
|