@switchbot/homebridge-switchbot 2.3.0-beta.2 → 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 -0
  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 -0
  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 -0
  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 +6 -0
  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 -0
  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 -0
  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 +6 -0
  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 -0
  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 -0
  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 +5 -0
  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 -0
  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 -0
  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 -0
  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 -0
  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 -0
  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 -0
  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 -0
  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 -1
  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 -0
  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 -1
  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 -0
  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 -1
  66. package/dist/irdevice/waterheater.js.map +1 -1
  67. package/package.json +1 -1
  68. package/src/device/bot.ts +33 -0
  69. package/src/device/ceilinglight.ts +3 -1
  70. package/src/device/colorbulb.ts +3 -0
  71. package/src/device/contact.ts +6 -1
  72. package/src/device/curtain.ts +9 -0
  73. package/src/device/humidifier.ts +6 -1
  74. package/src/device/lock.ts +6 -0
  75. package/src/device/meter.ts +9 -3
  76. package/src/device/meterplus.ts +9 -3
  77. package/src/device/motion.ts +5 -1
  78. package/src/device/plug.ts +3 -1
  79. package/src/device/robotvacuumcleaner.ts +3 -1
  80. package/src/device/striplight.ts +3 -1
  81. package/src/irdevice/airconditioner.ts +3 -0
  82. package/src/irdevice/airpurifier.ts +3 -1
  83. package/src/irdevice/camera.ts +3 -0
  84. package/src/irdevice/fan.ts +3 -0
  85. package/src/irdevice/light.ts +4 -1
  86. package/src/irdevice/other.ts +3 -1
  87. package/src/irdevice/tv.ts +10 -2
  88. package/src/irdevice/vacuumcleaner.ts +3 -0
  89. package/src/irdevice/waterheater.ts +4 -1
@@ -98,7 +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
-
101
+ if (!this.motionSensorService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
102
+ this.motionSensorService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
103
+ }
102
104
  // each service must implement at-minimum the "required characteristics" for the given service type
103
105
  // see https://developers.homebridge.io/#/service/MotionSensor
104
106
 
@@ -114,6 +116,7 @@ export class Motion {
114
116
  `${accessory.displayName} Light Sensor`;
115
117
 
116
118
  this.lightSensorService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Light Sensor`);
119
+ this.lightSensorService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Light Sensor`);
117
120
  } else {
118
121
  this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Light Sensor Service Not Added`);
119
122
  }
@@ -129,6 +132,7 @@ export class Motion {
129
132
  `${accessory.displayName} Battery`;
130
133
 
131
134
  this.batteryService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Battery`);
135
+ this.batteryService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Battery`);
132
136
  } else {
133
137
  this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Battery Service Not Added`);
134
138
  }
@@ -83,7 +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
-
86
+ if (!this.outletService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
87
+ this.outletService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
88
+ }
87
89
  // each service must implement at-minimum the "required characteristics" for the given service type
88
90
  // see https://developers.homebridge.io/#/service/Outlet
89
91
 
@@ -81,7 +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
-
84
+ if (!this.robotVacuumCleanerService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
85
+ this.robotVacuumCleanerService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
86
+ }
85
87
  // each service must implement at-minimum the "required characteristics" for the given service type
86
88
  // see https://developers.homebridge.io/#/service/Lightbulb
87
89
 
@@ -108,7 +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
-
111
+ if (!this.lightBulbService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
112
+ this.lightBulbService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
113
+ }
112
114
  // handle on / off events using the On characteristic
113
115
  this.lightBulbService.getCharacteristic(this.platform.Characteristic.On).onSet(this.OnSet.bind(this));
114
116
 
@@ -76,6 +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
+ if (!this.coolerService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
80
+ this.coolerService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
81
+ }
79
82
 
80
83
  // handle on / off events using the Active characteristic
81
84
  this.coolerService.getCharacteristic(this.platform.Characteristic.Active).onSet(this.ActiveSet.bind(this));
@@ -71,7 +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
-
74
+ if (!this.airPurifierService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
75
+ this.airPurifierService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
76
+ }
75
77
  // handle on / off events using the Active characteristic
76
78
  this.airPurifierService.getCharacteristic(this.platform.Characteristic.Active).onSet(this.ActiveSet.bind(this));
77
79
 
@@ -53,6 +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
+ if (!this.switchService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
57
+ this.switchService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
58
+ }
56
59
 
57
60
  // handle on / off events using the On characteristic
58
61
  this.switchService.getCharacteristic(this.platform.Characteristic.On).onSet(this.OnSet.bind(this));
@@ -63,6 +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
+ if (!this.fanService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
67
+ this.fanService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
68
+ }
66
69
 
67
70
  // handle on / off events using the Active characteristic
68
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,6 +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
+ if (!this.lightBulbService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
57
+ this.lightBulbService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
58
+ }
56
59
 
57
60
  // handle on / off events using the On characteristic
58
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
-
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,7 +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
44
  .setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
46
45
  .setCharacteristic(this.platform.Characteristic.Model, device.remoteType)
47
46
  .setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!)
@@ -49,6 +48,13 @@ export class TV {
49
48
  .getCharacteristic(this.platform.Characteristic.FirmwareRevision)
50
49
  .updateValue(this.FirmwareRevision(accessory, device));
51
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
+
52
58
  // set the accessory category
53
59
  switch (device.remoteType) {
54
60
  case 'Speaker':
@@ -114,7 +120,9 @@ export class TV {
114
120
  `${accessory.displayName} Speaker`;
115
121
 
116
122
  this.speakerService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Speaker`);
117
-
123
+ if (!this.speakerService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
124
+ this.speakerService.addCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Speaker`);
125
+ }
118
126
  this.speakerService
119
127
  .setCharacteristic(this.platform.Characteristic.Active, this.platform.Characteristic.Active.ACTIVE)
120
128
  .setCharacteristic(this.platform.Characteristic.VolumeControlType, this.platform.Characteristic.VolumeControlType.ABSOLUTE);
@@ -53,6 +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
+ if (!this.switchService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
57
+ this.switchService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
58
+ }
56
59
 
57
60
  // handle on / off events using the On characteristic
58
61
  this.switchService.getCharacteristic(this.platform.Characteristic.On).onSet(this.OnSet.bind(this));
@@ -52,7 +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}`);
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
+ }
56
59
 
57
60
  // set sleep discovery characteristic
58
61
  this.valveService.setCharacteristic(this.platform.Characteristic.ValveType, this.platform.Characteristic.ValveType.GENERIC_VALVE);