@switchbot/homebridge-switchbot 1.5.0 → 1.5.1-beta.3

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 (71) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/config.schema.json +11 -2
  3. package/dist/devices/bots.d.ts +1 -0
  4. package/dist/devices/bots.d.ts.map +1 -1
  5. package/dist/devices/bots.js +31 -18
  6. package/dist/devices/bots.js.map +1 -1
  7. package/dist/devices/colorbulb.js +13 -12
  8. package/dist/devices/colorbulb.js.map +1 -1
  9. package/dist/devices/contact.js +13 -12
  10. package/dist/devices/contact.js.map +1 -1
  11. package/dist/devices/curtains.d.ts.map +1 -1
  12. package/dist/devices/curtains.js +16 -15
  13. package/dist/devices/curtains.js.map +1 -1
  14. package/dist/devices/humidifiers.js +13 -12
  15. package/dist/devices/humidifiers.js.map +1 -1
  16. package/dist/devices/meters.js +13 -12
  17. package/dist/devices/meters.js.map +1 -1
  18. package/dist/devices/motion.js +13 -12
  19. package/dist/devices/motion.js.map +1 -1
  20. package/dist/devices/plugs.js +13 -12
  21. package/dist/devices/plugs.js.map +1 -1
  22. package/dist/irdevices/airconditioners.d.ts.map +1 -1
  23. package/dist/irdevices/airconditioners.js +11 -1
  24. package/dist/irdevices/airconditioners.js.map +1 -1
  25. package/dist/irdevices/airpurifiers.d.ts.map +1 -1
  26. package/dist/irdevices/airpurifiers.js +11 -1
  27. package/dist/irdevices/airpurifiers.js.map +1 -1
  28. package/dist/irdevices/cameras.d.ts.map +1 -1
  29. package/dist/irdevices/cameras.js +11 -1
  30. package/dist/irdevices/cameras.js.map +1 -1
  31. package/dist/irdevices/fans.d.ts.map +1 -1
  32. package/dist/irdevices/fans.js +11 -1
  33. package/dist/irdevices/fans.js.map +1 -1
  34. package/dist/irdevices/lights.d.ts.map +1 -1
  35. package/dist/irdevices/lights.js +11 -1
  36. package/dist/irdevices/lights.js.map +1 -1
  37. package/dist/irdevices/others.d.ts +2 -0
  38. package/dist/irdevices/others.d.ts.map +1 -1
  39. package/dist/irdevices/others.js +38 -7
  40. package/dist/irdevices/others.js.map +1 -1
  41. package/dist/irdevices/tvs.d.ts.map +1 -1
  42. package/dist/irdevices/tvs.js +11 -1
  43. package/dist/irdevices/tvs.js.map +1 -1
  44. package/dist/irdevices/vacuumcleaners.d.ts.map +1 -1
  45. package/dist/irdevices/vacuumcleaners.js +11 -1
  46. package/dist/irdevices/vacuumcleaners.js.map +1 -1
  47. package/dist/irdevices/waterheaters.d.ts.map +1 -1
  48. package/dist/irdevices/waterheaters.js +11 -1
  49. package/dist/irdevices/waterheaters.js.map +1 -1
  50. package/dist/settings.d.ts +1 -0
  51. package/dist/settings.d.ts.map +1 -1
  52. package/dist/settings.js.map +1 -1
  53. package/package.json +68 -68
  54. package/src/devices/bots.ts +32 -18
  55. package/src/devices/colorbulb.ts +12 -12
  56. package/src/devices/contact.ts +12 -12
  57. package/src/devices/curtains.ts +16 -16
  58. package/src/devices/humidifiers.ts +12 -12
  59. package/src/devices/meters.ts +12 -12
  60. package/src/devices/motion.ts +12 -12
  61. package/src/devices/plugs.ts +12 -12
  62. package/src/irdevices/airconditioners.ts +10 -1
  63. package/src/irdevices/airpurifiers.ts +10 -1
  64. package/src/irdevices/cameras.ts +10 -1
  65. package/src/irdevices/fans.ts +10 -1
  66. package/src/irdevices/lights.ts +10 -1
  67. package/src/irdevices/others.ts +39 -8
  68. package/src/irdevices/tvs.ts +10 -1
  69. package/src/irdevices/vacuumcleaners.ts +10 -1
  70. package/src/irdevices/waterheaters.ts +10 -1
  71. package/src/settings.ts +1 -0
@@ -58,10 +58,19 @@ export class Camera {
58
58
  }
59
59
 
60
60
  logs() {
61
- if (this.device.logging) {
61
+ if (this.platform.debugMode) {
62
+ this.deviceLogging = this.accessory.context.logging = 'debug';
63
+ this.warnLog(`Water Heater: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
64
+ } else if (this.device.logging) {
62
65
  this.deviceLogging = this.accessory.context.logging = this.device.logging;
66
+ if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
67
+ this.warnLog(`Bot: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
68
+ }
63
69
  } else if (this.platform.config.options?.logging) {
64
70
  this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
71
+ if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
72
+ this.warnLog(`Bot: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
73
+ }
65
74
  } else {
66
75
  this.deviceLogging = this.accessory.context.logging = 'standard';
67
76
  }
@@ -117,10 +117,19 @@ export class Fan {
117
117
  }
118
118
 
119
119
  logs() {
120
- if (this.device.logging) {
120
+ if (this.platform.debugMode) {
121
+ this.deviceLogging = this.accessory.context.logging = 'debug';
122
+ this.warnLog(`Water Heater: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
123
+ } else if (this.device.logging) {
121
124
  this.deviceLogging = this.accessory.context.logging = this.device.logging;
125
+ if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
126
+ this.warnLog(`Bot: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
127
+ }
122
128
  } else if (this.platform.config.options?.logging) {
123
129
  this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
130
+ if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
131
+ this.warnLog(`Bot: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
132
+ }
124
133
  } else {
125
134
  this.deviceLogging = this.accessory.context.logging = 'standard';
126
135
  }
@@ -73,10 +73,19 @@ export class Light {
73
73
  }
74
74
 
75
75
  logs() {
76
- if (this.device.logging) {
76
+ if (this.platform.debugMode) {
77
+ this.deviceLogging = this.accessory.context.logging = 'debug';
78
+ this.warnLog(`Water Heater: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
79
+ } else if (this.device.logging) {
77
80
  this.deviceLogging = this.accessory.context.logging = this.device.logging;
81
+ if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
82
+ this.warnLog(`Bot: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
83
+ }
78
84
  } else if (this.platform.config.options?.logging) {
79
85
  this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
86
+ if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
87
+ this.warnLog(`Bot: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
88
+ }
80
89
  } else {
81
90
  this.deviceLogging = this.accessory.context.logging = 'standard';
82
91
  }
@@ -1,7 +1,7 @@
1
1
  import { AxiosResponse } from 'axios';
2
2
  import { SwitchBotPlatform } from '../platform';
3
3
  import { irDevicesConfig, DeviceURL, irdevice, payload } from '../settings';
4
- import { CharacteristicValue, HAPStatus, PlatformAccessory, Service } from 'homebridge';
4
+ import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
5
5
 
6
6
  /**
7
7
  * Platform Accessory
@@ -18,6 +18,7 @@ export class Others {
18
18
 
19
19
  // Config
20
20
  deviceLogging!: string;
21
+ otherDeviceType?: string;
21
22
 
22
23
  constructor(
23
24
  private readonly platform: SwitchBotPlatform,
@@ -26,6 +27,7 @@ export class Others {
26
27
  ) {
27
28
  // default placeholders
28
29
  this.logs();
30
+ this.deviceType();
29
31
  if (this.Active === undefined) {
30
32
  this.Active = this.platform.Characteristic.Active.INACTIVE;
31
33
  } else {
@@ -41,24 +43,53 @@ export class Others {
41
43
 
42
44
  // get the Television service if it exists, otherwise create a new Television service
43
45
  // you can create multiple services for each accessory
44
- this.service = accessory.getService(this.platform.Service.Fanv2);
45
- if (!this.service && device?.other?.deviceType === 'Fan') {
46
- this.service = accessory.addService(this.platform.Service.Fanv2, `${accessory.displayName} Fan`);
46
+ if (this.otherDeviceType !== 'Fan') {
47
+ this.debugLog(`Other: ${accessory.displayName} Removing Fanv2 Service`);
47
48
 
48
- this.service.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
49
+ if (this.otherDeviceType === undefined) {
50
+ this.errorLog(`Other: ${this.accessory.displayName} No Device Type Set, deviceType: ${device.other?.deviceType}`);
51
+ }
52
+ this.service = this.accessory.getService(this.platform.Service.Fanv2);
53
+ accessory.removeService(this.service!);
54
+ } else if (!this.service && this.otherDeviceType === 'Fan') {
55
+ this.debugLog(`Other: ${accessory.displayName} Add Fanv2 Service`);
56
+ (this.service =
57
+ this.accessory.getService(this.platform.Service.Fanv2) ||
58
+ this.accessory.addService(this.platform.Service.Fanv2)), `${accessory.displayName} Fan`;
59
+
60
+ this.service.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Fan`);
49
61
 
50
62
  this.service.getCharacteristic(this.platform.Characteristic.Active).onSet(this.ActiveSet.bind(this));
51
63
  } else {
52
- accessory.removeService(this.service!);
53
- this.errorLog(`Other: ${this.accessory.displayName} No Device Type Set, deviceType: ${device.other?.deviceType}`);
64
+ this.debugLog(`Other: ${accessory.displayName} Fanv2 Service Not Added, deviceType: ${device.other?.deviceType}`);
65
+ }
66
+ }
67
+
68
+ deviceType() {
69
+ if (this.device?.other?.deviceType) {
70
+ this.otherDeviceType = this.accessory.context.deviceType = this.device?.other?.deviceType;
71
+ if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
72
+ this.warnLog(`Other: ${this.accessory.displayName} Using Device Type: ${this.otherDeviceType}`);
73
+ }
74
+ } else {
75
+ this.errorLog(`Other: ${this.accessory.displayName} No Device Type Set, deviceType: ${this.device.other?.deviceType}`);
54
76
  }
55
77
  }
56
78
 
57
79
  logs() {
58
- if (this.device.logging) {
80
+ if (this.platform.debugMode) {
81
+ this.deviceLogging = this.accessory.context.logging = 'debug';
82
+ this.warnLog(`Water Heater: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
83
+ } else if (this.device.logging) {
59
84
  this.deviceLogging = this.accessory.context.logging = this.device.logging;
85
+ if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
86
+ this.warnLog(`Bot: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
87
+ }
60
88
  } else if (this.platform.config.options?.logging) {
61
89
  this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
90
+ if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
91
+ this.warnLog(`Bot: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
92
+ }
62
93
  } else {
63
94
  this.deviceLogging = this.accessory.context.logging = 'standard';
64
95
  }
@@ -129,10 +129,19 @@ export class TV {
129
129
  }
130
130
 
131
131
  logs() {
132
- if (this.device.logging) {
132
+ if (this.platform.debugMode) {
133
+ this.deviceLogging = this.accessory.context.logging = 'debug';
134
+ this.warnLog(`Water Heater: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
135
+ } else if (this.device.logging) {
133
136
  this.deviceLogging = this.accessory.context.logging = this.device.logging;
137
+ if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
138
+ this.warnLog(`Bot: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
139
+ }
134
140
  } else if (this.platform.config.options?.logging) {
135
141
  this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
142
+ if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
143
+ this.warnLog(`Bot: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
144
+ }
136
145
  } else {
137
146
  this.deviceLogging = this.accessory.context.logging = 'standard';
138
147
  }
@@ -58,10 +58,19 @@ export class VacuumCleaner {
58
58
  }
59
59
 
60
60
  logs() {
61
- if (this.device.logging) {
61
+ if (this.platform.debugMode) {
62
+ this.deviceLogging = this.accessory.context.logging = 'debug';
63
+ this.warnLog(`Water Heater: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
64
+ } else if (this.device.logging) {
62
65
  this.deviceLogging = this.accessory.context.logging = this.device.logging;
66
+ if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
67
+ this.warnLog(`Bot: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
68
+ }
63
69
  } else if (this.platform.config.options?.logging) {
64
70
  this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
71
+ if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
72
+ this.warnLog(`Bot: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
73
+ }
65
74
  } else {
66
75
  this.deviceLogging = this.accessory.context.logging = 'standard';
67
76
  }
@@ -67,10 +67,19 @@ export class WaterHeater {
67
67
  }
68
68
 
69
69
  logs() {
70
- if (this.device.logging) {
70
+ if (this.platform.debugMode) {
71
+ this.deviceLogging = this.accessory.context.logging = 'debug';
72
+ this.warnLog(`Water Heater: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
73
+ } else if (this.device.logging) {
71
74
  this.deviceLogging = this.accessory.context.logging = this.device.logging;
75
+ if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
76
+ this.warnLog(`Bot: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
77
+ }
72
78
  } else if (this.platform.config.options?.logging) {
73
79
  this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
80
+ if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
81
+ this.warnLog(`Bot: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
82
+ }
74
83
  } else {
75
84
  this.deviceLogging = this.accessory.context.logging = 'standard';
76
85
  }
package/src/settings.ts CHANGED
@@ -62,6 +62,7 @@ export type meter = {
62
62
  export type bot = {
63
63
  mode?: string;
64
64
  deviceType?: string;
65
+ doublePress?: number;
65
66
  };
66
67
 
67
68
  export type humidifier = {