@switchbot/homebridge-switchbot 2.3.0-beta.3 → 2.3.0-beta.4

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 (89) hide show
  1. package/dist/device/bot.d.ts.map +1 -1
  2. package/dist/device/bot.js +33 -11
  3. package/dist/device/bot.js.map +1 -1
  4. package/dist/device/ceilinglight.d.ts.map +1 -1
  5. package/dist/device/ceilinglight.js +3 -1
  6. package/dist/device/ceilinglight.js.map +1 -1
  7. package/dist/device/colorbulb.d.ts.map +1 -1
  8. package/dist/device/colorbulb.js +3 -1
  9. package/dist/device/colorbulb.js.map +1 -1
  10. package/dist/device/contact.d.ts.map +1 -1
  11. package/dist/device/contact.js +3 -1
  12. package/dist/device/contact.js.map +1 -1
  13. package/dist/device/curtain.d.ts.map +1 -1
  14. package/dist/device/curtain.js +9 -3
  15. package/dist/device/curtain.js.map +1 -1
  16. package/dist/device/humidifier.d.ts.map +1 -1
  17. package/dist/device/humidifier.js +6 -2
  18. package/dist/device/humidifier.js.map +1 -1
  19. package/dist/device/lock.d.ts.map +1 -1
  20. package/dist/device/lock.js +7 -2
  21. package/dist/device/lock.js.map +1 -1
  22. package/dist/device/meter.d.ts.map +1 -1
  23. package/dist/device/meter.js +9 -3
  24. package/dist/device/meter.js.map +1 -1
  25. package/dist/device/meterplus.d.ts.map +1 -1
  26. package/dist/device/meterplus.js +9 -3
  27. package/dist/device/meterplus.js.map +1 -1
  28. package/dist/device/motion.d.ts.map +1 -1
  29. package/dist/device/motion.js +3 -1
  30. package/dist/device/motion.js.map +1 -1
  31. package/dist/device/plug.d.ts.map +1 -1
  32. package/dist/device/plug.js +3 -1
  33. package/dist/device/plug.js.map +1 -1
  34. package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
  35. package/dist/device/robotvacuumcleaner.js +3 -1
  36. package/dist/device/robotvacuumcleaner.js.map +1 -1
  37. package/dist/device/striplight.d.ts.map +1 -1
  38. package/dist/device/striplight.js +3 -1
  39. package/dist/device/striplight.js.map +1 -1
  40. package/dist/irdevice/airconditioner.d.ts.map +1 -1
  41. package/dist/irdevice/airconditioner.js +3 -1
  42. package/dist/irdevice/airconditioner.js.map +1 -1
  43. package/dist/irdevice/airpurifier.d.ts.map +1 -1
  44. package/dist/irdevice/airpurifier.js +3 -1
  45. package/dist/irdevice/airpurifier.js.map +1 -1
  46. package/dist/irdevice/camera.d.ts.map +1 -1
  47. package/dist/irdevice/camera.js +3 -1
  48. package/dist/irdevice/camera.js.map +1 -1
  49. package/dist/irdevice/fan.d.ts.map +1 -1
  50. package/dist/irdevice/fan.js +3 -1
  51. package/dist/irdevice/fan.js.map +1 -1
  52. package/dist/irdevice/light.d.ts.map +1 -1
  53. package/dist/irdevice/light.js +4 -2
  54. package/dist/irdevice/light.js.map +1 -1
  55. package/dist/irdevice/other.d.ts.map +1 -1
  56. package/dist/irdevice/other.js +3 -1
  57. package/dist/irdevice/other.js.map +1 -1
  58. package/dist/irdevice/tv.d.ts.map +1 -1
  59. package/dist/irdevice/tv.js +9 -3
  60. package/dist/irdevice/tv.js.map +1 -1
  61. package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
  62. package/dist/irdevice/vacuumcleaner.js +3 -1
  63. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  64. package/dist/irdevice/waterheater.d.ts.map +1 -1
  65. package/dist/irdevice/waterheater.js +4 -2
  66. package/dist/irdevice/waterheater.js.map +1 -1
  67. package/package.json +1 -1
  68. package/src/device/bot.ts +33 -11
  69. package/src/device/ceilinglight.ts +3 -2
  70. package/src/device/colorbulb.ts +3 -1
  71. package/src/device/contact.ts +3 -2
  72. package/src/device/curtain.ts +9 -3
  73. package/src/device/humidifier.ts +6 -2
  74. package/src/device/lock.ts +7 -2
  75. package/src/device/meter.ts +9 -3
  76. package/src/device/meterplus.ts +9 -3
  77. package/src/device/motion.ts +3 -2
  78. package/src/device/plug.ts +3 -2
  79. package/src/device/robotvacuumcleaner.ts +3 -2
  80. package/src/device/striplight.ts +3 -2
  81. package/src/irdevice/airconditioner.ts +3 -1
  82. package/src/irdevice/airpurifier.ts +3 -2
  83. package/src/irdevice/camera.ts +3 -1
  84. package/src/irdevice/fan.ts +3 -1
  85. package/src/irdevice/light.ts +4 -2
  86. package/src/irdevice/other.ts +3 -1
  87. package/src/irdevice/tv.ts +10 -3
  88. package/src/irdevice/vacuumcleaner.ts +3 -1
  89. package/src/irdevice/waterheater.ts +4 -2
@@ -104,7 +104,9 @@ export class MeterPlus {
104
104
  `${accessory.displayName} Temperature Sensor`;
105
105
 
106
106
  this.temperatureservice.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Temperature Sensor`);
107
- this.temperatureservice.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Temperature Sensor`);
107
+ if (!this.temperatureservice.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
108
+ this.temperatureservice.addCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Temperature Sensor`);
109
+ }
108
110
  this.temperatureservice
109
111
  .getCharacteristic(this.platform.Characteristic.CurrentTemperature)
110
112
  .setProps({
@@ -133,7 +135,9 @@ export class MeterPlus {
133
135
  `${accessory.displayName} Humidity Sensor`;
134
136
 
135
137
  this.humidityservice.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Humidity Sensor`);
136
- this.humidityservice.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Humidity Sensor`);
138
+ if (!this.humidityservice.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
139
+ this.humidityservice.addCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Humidity Sensor`);
140
+ }
137
141
  this.humidityservice
138
142
  .getCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity)
139
143
  .setProps({
@@ -157,7 +161,9 @@ export class MeterPlus {
157
161
  `${accessory.displayName} Battery`;
158
162
 
159
163
  this.batteryService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Battery`);
160
- this.batteryService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Battery`);
164
+ if (!this.batteryService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
165
+ this.batteryService.addCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Battery`);
166
+ }
161
167
  this.batteryService.setCharacteristic(this.platform.Characteristic.ChargingState, this.platform.Characteristic.ChargingState.NOT_CHARGEABLE);
162
168
  } else {
163
169
  this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Battery Service Not Added`);
@@ -98,8 +98,9 @@ export class Motion {
98
98
  // set the service name, this is what is displayed as the default name on the Home app
99
99
  // in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
100
100
  this.motionSensorService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
101
- this.motionSensorService.setCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
102
-
101
+ if (!this.motionSensorService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
102
+ this.motionSensorService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
103
+ }
103
104
  // each service must implement at-minimum the "required characteristics" for the given service type
104
105
  // see https://developers.homebridge.io/#/service/MotionSensor
105
106
 
@@ -83,8 +83,9 @@ export class Plug {
83
83
  // set the service name, this is what is displayed as the default name on the Home app
84
84
  // in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
85
85
  this.outletService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
86
- this.outletService.setCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
87
-
86
+ if (!this.outletService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
87
+ this.outletService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
88
+ }
88
89
  // each service must implement at-minimum the "required characteristics" for the given service type
89
90
  // see https://developers.homebridge.io/#/service/Outlet
90
91
 
@@ -81,8 +81,9 @@ export class RobotVacuumCleaner {
81
81
  // set the service name, this is what is displayed as the default name on the Home app
82
82
  // in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
83
83
  this.robotVacuumCleanerService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
84
- this.robotVacuumCleanerService.setCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
85
-
84
+ if (!this.robotVacuumCleanerService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
85
+ this.robotVacuumCleanerService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
86
+ }
86
87
  // each service must implement at-minimum the "required characteristics" for the given service type
87
88
  // see https://developers.homebridge.io/#/service/Lightbulb
88
89
 
@@ -108,8 +108,9 @@ export class StripLight {
108
108
  // set the service name, this is what is displayed as the default name on the Home app
109
109
  // in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
110
110
  this.lightBulbService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
111
- this.lightBulbService.setCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
112
-
111
+ if (!this.lightBulbService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
112
+ this.lightBulbService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
113
+ }
113
114
  // handle on / off events using the On characteristic
114
115
  this.lightBulbService.getCharacteristic(this.platform.Characteristic.On).onSet(this.OnSet.bind(this));
115
116
 
@@ -76,7 +76,9 @@ export class AirConditioner {
76
76
  // set the service name, this is what is displayed as the default name on the Home app
77
77
  // in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
78
78
  this.coolerService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
79
- this.coolerService.setCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
79
+ if (!this.coolerService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
80
+ this.coolerService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
81
+ }
80
82
 
81
83
  // handle on / off events using the Active characteristic
82
84
  this.coolerService.getCharacteristic(this.platform.Characteristic.Active).onSet(this.ActiveSet.bind(this));
@@ -71,8 +71,9 @@ export class AirPurifier {
71
71
  // set the service name, this is what is displayed as the default name on the Home app
72
72
  // in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
73
73
  this.airPurifierService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
74
- this.airPurifierService.setCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
75
-
74
+ if (!this.airPurifierService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
75
+ this.airPurifierService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
76
+ }
76
77
  // handle on / off events using the Active characteristic
77
78
  this.airPurifierService.getCharacteristic(this.platform.Characteristic.Active).onSet(this.ActiveSet.bind(this));
78
79
 
@@ -53,7 +53,9 @@ export class Camera {
53
53
  // set the service name, this is what is displayed as the default name on the Home app
54
54
  // in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
55
55
  this.switchService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
56
- this.switchService.setCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
56
+ if (!this.switchService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
57
+ this.switchService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
58
+ }
57
59
 
58
60
  // handle on / off events using the On characteristic
59
61
  this.switchService.getCharacteristic(this.platform.Characteristic.On).onSet(this.OnSet.bind(this));
@@ -63,7 +63,9 @@ export class Fan {
63
63
  // set the service name, this is what is displayed as the default name on the Home app
64
64
  // in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
65
65
  this.fanService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
66
- this.fanService.setCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
66
+ if (!this.fanService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
67
+ this.fanService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
68
+ }
67
69
 
68
70
  // handle on / off events using the Active characteristic
69
71
  this.fanService.getCharacteristic(this.platform.Characteristic.Active).onSet(this.ActiveSet.bind(this));
@@ -41,7 +41,7 @@ export class Light {
41
41
  .getCharacteristic(this.platform.Characteristic.FirmwareRevision)
42
42
  .updateValue(this.FirmwareRevision(accessory, device));
43
43
 
44
- // get the Television service if it exists, otherwise create a new Television service
44
+ // get the Light service if it exists, otherwise create a new Light service
45
45
  // you can create multiple services for each accessory
46
46
  (this.lightBulbService = accessory.getService(this.platform.Service.Lightbulb) || accessory.addService(this.platform.Service.Lightbulb)),
47
47
  `${accessory.displayName} ${device.remoteType}`;
@@ -53,7 +53,9 @@ export class Light {
53
53
  // set the service name, this is what is displayed as the default name on the Home app
54
54
  // in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
55
55
  this.lightBulbService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
56
- this.lightBulbService.setCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
56
+ if (!this.lightBulbService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
57
+ this.lightBulbService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
58
+ }
57
59
 
58
60
  // handle on / off events using the On characteristic
59
61
  this.lightBulbService.getCharacteristic(this.platform.Characteristic.On).onSet(this.OnSet.bind(this));
@@ -59,7 +59,9 @@ export class Others {
59
59
  `${accessory.displayName} Fan`;
60
60
 
61
61
  this.fanService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Fan`);
62
- this.fanService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Fan`);
62
+ if (!this.fanService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
63
+ this.fanService.addCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Fan`);
64
+ }
63
65
  this.fanService.getCharacteristic(this.platform.Characteristic.Active).onSet(this.ActiveSet.bind(this));
64
66
  } else {
65
67
  this.debugLog(`${this.device.remoteType}: ${accessory.displayName} Fanv2 Service Not Added, deviceType: ${device.other?.deviceType}`);
@@ -41,8 +41,6 @@ export class TV {
41
41
  // set accessory information
42
42
  accessory
43
43
  .getService(this.platform.Service.AccessoryInformation)!
44
- .setCharacteristic(this.platform.Characteristic.Name, `${device.deviceName} ${device.remoteType}`)
45
- .setCharacteristic(this.platform.Characteristic.ConfiguredName, `${device.deviceName} ${device.remoteType}`)
46
44
  .setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
47
45
  .setCharacteristic(this.platform.Characteristic.Model, device.remoteType)
48
46
  .setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!)
@@ -50,6 +48,13 @@ export class TV {
50
48
  .getCharacteristic(this.platform.Characteristic.FirmwareRevision)
51
49
  .updateValue(this.FirmwareRevision(accessory, device));
52
50
 
51
+ // get the Television service if it exists, otherwise create a new Television service
52
+ // you can create multiple services for each accessory
53
+ this.tvService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
54
+ if (!this.tvService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
55
+ this.tvService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
56
+ }
57
+
53
58
  // set the accessory category
54
59
  switch (device.remoteType) {
55
60
  case 'Speaker':
@@ -115,7 +120,9 @@ export class TV {
115
120
  `${accessory.displayName} Speaker`;
116
121
 
117
122
  this.speakerService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Speaker`);
118
- this.speakerService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Speaker`);
123
+ if (!this.speakerService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
124
+ this.speakerService.addCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Speaker`);
125
+ }
119
126
  this.speakerService
120
127
  .setCharacteristic(this.platform.Characteristic.Active, this.platform.Characteristic.Active.ACTIVE)
121
128
  .setCharacteristic(this.platform.Characteristic.VolumeControlType, this.platform.Characteristic.VolumeControlType.ABSOLUTE);
@@ -53,7 +53,9 @@ export class VacuumCleaner {
53
53
  // set the service name, this is what is displayed as the default name on the Home app
54
54
  // in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
55
55
  this.switchService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
56
- this.switchService.setCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
56
+ if (!this.switchService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
57
+ this.switchService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
58
+ }
57
59
 
58
60
  // handle on / off events using the On characteristic
59
61
  this.switchService.getCharacteristic(this.platform.Characteristic.On).onSet(this.OnSet.bind(this));
@@ -52,8 +52,10 @@ export class WaterHeater {
52
52
 
53
53
  // set the service name, this is what is displayed as the default name on the Home app
54
54
  // in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
55
- this.valveService.setCharacteristic(this.platform.Characteristic.Name, `${device.deviceName} ${device.remoteType}`);
56
- this.valveService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${device.deviceName} ${device.remoteType}`);
55
+ this.valveService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
56
+ if (!this.valveService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
57
+ this.valveService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
58
+ }
57
59
 
58
60
  // set sleep discovery characteristic
59
61
  this.valveService.setCharacteristic(this.platform.Characteristic.ValveType, this.platform.Characteristic.ValveType.GENERIC_VALVE);