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,99 @@
1
+ // Nest Temperature Sensor
2
+ // Part of homebridge-nest-accfactory
3
+ //
4
+ // Code version 27/8/2024
5
+ // Mark Hulskamp
6
+ 'use strict';
7
+
8
+ // Define our modules
9
+ import HomeKitDevice from './HomeKitDevice.js';
10
+
11
+ const LOWBATTERYLEVEL = 10; // Low battery level percentage
12
+
13
+ export default class NestTemperatureSensor extends HomeKitDevice {
14
+ batteryService = undefined;
15
+ temperatureService = undefined;
16
+
17
+ constructor(accessory, api, log, eventEmitter, deviceData) {
18
+ super(accessory, api, log, eventEmitter, deviceData);
19
+ }
20
+
21
+ // Class functions
22
+ addServices() {
23
+ // Setup the temperature service if not already present on the accessory
24
+ this.temperatureService = this.accessory.getService(this.hap.Service.TemperatureSensor);
25
+ if (this.temperatureService === undefined) {
26
+ this.temperatureService = this.accessory.addService(this.hap.Service.TemperatureSensor, '', 1);
27
+ }
28
+ this.temperatureService.setPrimaryService();
29
+
30
+ // Setup the battery service if not already present on the accessory
31
+ this.batteryService = this.accessory.getService(this.hap.Service.Battery);
32
+ if (this.batteryService === undefined) {
33
+ this.batteryService = this.accessory.addService(this.hap.Service.Battery, '', 1);
34
+ }
35
+ this.batteryService.setHiddenService(true);
36
+
37
+ // Setup linkage to EveHome app if configured todo so
38
+ if (
39
+ this.deviceData?.eveHistory === true &&
40
+ this.temperatureService !== undefined &&
41
+ typeof this.historyService?.linkToEveHome === 'function'
42
+ ) {
43
+ this.historyService.linkToEveHome(this.temperatureService, {
44
+ description: this.deviceData.description,
45
+ });
46
+ }
47
+ }
48
+
49
+ updateServices(deviceData) {
50
+ if (typeof deviceData !== 'object' || this.temperatureService === undefined || this.batteryService === undefined) {
51
+ return;
52
+ }
53
+
54
+ // If device isn't online report in HomeKit
55
+ this.temperatureService.updateCharacteristic(
56
+ this.hap.Characteristic.StatusFault,
57
+ deviceData.online === true ? this.hap.Characteristic.StatusFault.NO_FAULT : this.hap.Characteristic.StatusFault.GENERAL_FAULT,
58
+ );
59
+
60
+ this.temperatureService.updateCharacteristic(this.hap.Characteristic.StatusActive, deviceData.online);
61
+ if (typeof deviceData?.associated_thermostat === 'string' && deviceData.associated_thermostat !== '') {
62
+ // This tempature sensor is assocated with a theromstat
63
+ // Update sttaus if providing active temperature for the thermostats
64
+ this.temperatureService.updateCharacteristic(
65
+ this.hap.Characteristic.StatusActive,
66
+ deviceData.online === true && deviceData?.active_sensor === true,
67
+ );
68
+ }
69
+
70
+ // Update temperature
71
+ this.temperatureService.updateCharacteristic(this.hap.Characteristic.CurrentTemperature, deviceData.current_temperature);
72
+
73
+ // Update battery level and status
74
+ this.batteryService.updateCharacteristic(this.hap.Characteristic.BatteryLevel, deviceData.battery_level);
75
+ this.batteryService.updateCharacteristic(
76
+ this.hap.Characteristic.StatusLowBattery,
77
+ deviceData.battery_level > LOWBATTERYLEVEL
78
+ ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL
79
+ : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW,
80
+ );
81
+ this.batteryService.updateCharacteristic(this.hap.Characteristic.ChargingState, this.hap.Characteristic.ChargingState.NOT_CHARGEABLE);
82
+
83
+ // If we have the history service running and temperature has changed to previous in past 5mins
84
+ if (
85
+ deviceData.current_temperature !== this.deviceData.current_temperature &&
86
+ this.temperatureService !== undefined &&
87
+ typeof this.historyService?.addHistory === 'function'
88
+ ) {
89
+ this.historyService.addHistory(
90
+ this.temperatureService,
91
+ {
92
+ time: Math.floor(Date.now() / 1000),
93
+ temperature: deviceData.current_temperature,
94
+ },
95
+ 300,
96
+ );
97
+ }
98
+ }
99
+ }