@switchbot/homebridge-switchbot 3.5.0-beta.62 → 3.5.0-beta.64

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 (113) hide show
  1. package/dist/device/blindtilt.d.ts.map +1 -1
  2. package/dist/device/blindtilt.js +9 -6
  3. package/dist/device/blindtilt.js.map +1 -1
  4. package/dist/device/bot.d.ts.map +1 -1
  5. package/dist/device/bot.js +33 -22
  6. package/dist/device/bot.js.map +1 -1
  7. package/dist/device/ceilinglight.d.ts.map +1 -1
  8. package/dist/device/ceilinglight.js +4 -3
  9. package/dist/device/ceilinglight.js.map +1 -1
  10. package/dist/device/colorbulb.js +3 -2
  11. package/dist/device/colorbulb.js.map +1 -1
  12. package/dist/device/contact.d.ts.map +1 -1
  13. package/dist/device/contact.js +14 -10
  14. package/dist/device/contact.js.map +1 -1
  15. package/dist/device/curtain.d.ts.map +1 -1
  16. package/dist/device/curtain.js +11 -8
  17. package/dist/device/curtain.js.map +1 -1
  18. package/dist/device/device.js +11 -10
  19. package/dist/device/device.js.map +1 -1
  20. package/dist/device/fan.d.ts.map +1 -1
  21. package/dist/device/fan.js +7 -5
  22. package/dist/device/fan.js.map +1 -1
  23. package/dist/device/hub.d.ts.map +1 -1
  24. package/dist/device/hub.js +9 -6
  25. package/dist/device/hub.js.map +1 -1
  26. package/dist/device/humidifier.d.ts.map +1 -1
  27. package/dist/device/humidifier.js +6 -4
  28. package/dist/device/humidifier.js.map +1 -1
  29. package/dist/device/iosensor.d.ts.map +1 -1
  30. package/dist/device/iosensor.js +10 -6
  31. package/dist/device/iosensor.js.map +1 -1
  32. package/dist/device/lightstrip.d.ts.map +1 -1
  33. package/dist/device/lightstrip.js +3 -2
  34. package/dist/device/lightstrip.js.map +1 -1
  35. package/dist/device/lock.d.ts.map +1 -1
  36. package/dist/device/lock.js +12 -8
  37. package/dist/device/lock.js.map +1 -1
  38. package/dist/device/meter.d.ts.map +1 -1
  39. package/dist/device/meter.js +8 -5
  40. package/dist/device/meter.js.map +1 -1
  41. package/dist/device/meterplus.d.ts.map +1 -1
  42. package/dist/device/meterplus.js +9 -6
  43. package/dist/device/meterplus.js.map +1 -1
  44. package/dist/device/motion.d.ts.map +1 -1
  45. package/dist/device/motion.js +10 -6
  46. package/dist/device/motion.js.map +1 -1
  47. package/dist/device/plug.d.ts.map +1 -1
  48. package/dist/device/plug.js +3 -2
  49. package/dist/device/plug.js.map +1 -1
  50. package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
  51. package/dist/device/robotvacuumcleaner.js +6 -4
  52. package/dist/device/robotvacuumcleaner.js.map +1 -1
  53. package/dist/device/waterdetector.d.ts.map +1 -1
  54. package/dist/device/waterdetector.js +6 -4
  55. package/dist/device/waterdetector.js.map +1 -1
  56. package/dist/irdevice/airconditioner.d.ts +1 -1
  57. package/dist/irdevice/airconditioner.d.ts.map +1 -1
  58. package/dist/irdevice/airconditioner.js +65 -83
  59. package/dist/irdevice/airconditioner.js.map +1 -1
  60. package/dist/irdevice/airpurifier.d.ts.map +1 -1
  61. package/dist/irdevice/airpurifier.js +37 -19
  62. package/dist/irdevice/airpurifier.js.map +1 -1
  63. package/dist/irdevice/camera.d.ts.map +1 -1
  64. package/dist/irdevice/camera.js +13 -11
  65. package/dist/irdevice/camera.js.map +1 -1
  66. package/dist/irdevice/fan.d.ts.map +1 -1
  67. package/dist/irdevice/fan.js +25 -15
  68. package/dist/irdevice/fan.js.map +1 -1
  69. package/dist/irdevice/light.d.ts.map +1 -1
  70. package/dist/irdevice/light.js +50 -24
  71. package/dist/irdevice/light.js.map +1 -1
  72. package/dist/irdevice/other.d.ts +1 -1
  73. package/dist/irdevice/other.d.ts.map +1 -1
  74. package/dist/irdevice/other.js +180 -138
  75. package/dist/irdevice/other.js.map +1 -1
  76. package/dist/irdevice/tv.d.ts.map +1 -1
  77. package/dist/irdevice/tv.js +50 -59
  78. package/dist/irdevice/tv.js.map +1 -1
  79. package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
  80. package/dist/irdevice/vacuumcleaner.js +13 -10
  81. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  82. package/dist/irdevice/waterheater.d.ts.map +1 -1
  83. package/dist/irdevice/waterheater.js +14 -13
  84. package/dist/irdevice/waterheater.js.map +1 -1
  85. package/package.json +1 -1
  86. package/src/device/blindtilt.ts +9 -6
  87. package/src/device/bot.ts +33 -22
  88. package/src/device/ceilinglight.ts +4 -3
  89. package/src/device/colorbulb.ts +3 -3
  90. package/src/device/contact.ts +14 -10
  91. package/src/device/curtain.ts +11 -8
  92. package/src/device/device.ts +11 -11
  93. package/src/device/fan.ts +7 -5
  94. package/src/device/hub.ts +9 -6
  95. package/src/device/humidifier.ts +6 -4
  96. package/src/device/iosensor.ts +10 -6
  97. package/src/device/lightstrip.ts +3 -2
  98. package/src/device/lock.ts +12 -8
  99. package/src/device/meter.ts +8 -5
  100. package/src/device/meterplus.ts +9 -6
  101. package/src/device/motion.ts +10 -6
  102. package/src/device/plug.ts +3 -2
  103. package/src/device/robotvacuumcleaner.ts +6 -4
  104. package/src/device/waterdetector.ts +6 -4
  105. package/src/irdevice/airconditioner.ts +73 -86
  106. package/src/irdevice/airpurifier.ts +43 -23
  107. package/src/irdevice/camera.ts +14 -13
  108. package/src/irdevice/fan.ts +26 -18
  109. package/src/irdevice/light.ts +65 -45
  110. package/src/irdevice/other.ts +210 -154
  111. package/src/irdevice/tv.ts +57 -70
  112. package/src/irdevice/vacuumcleaner.ts +14 -12
  113. package/src/irdevice/waterheater.ts +15 -16
@@ -18,6 +18,8 @@ import type { CharacteristicValue, PlatformAccessory, Service } from 'homebridge
18
18
  export class TV extends irdeviceBase {
19
19
  // Services
20
20
  private Television: {
21
+ Name: CharacteristicValue;
22
+ ConfiguredName: CharacteristicValue;
21
23
  Service: Service;
22
24
  Active: CharacteristicValue;
23
25
  ActiveIdentifier: CharacteristicValue;
@@ -26,6 +28,7 @@ export class TV extends irdeviceBase {
26
28
  };
27
29
 
28
30
  private TelevisionSpeaker: {
31
+ Name: CharacteristicValue;
29
32
  Service: Service;
30
33
  Active: CharacteristicValue;
31
34
  VolumeControlType: CharacteristicValue;
@@ -41,101 +44,85 @@ export class TV extends irdeviceBase {
41
44
  ) {
42
45
  super(platform, accessory, device);
43
46
 
44
- // Initialize Television property
47
+ // Initialize Television Service
48
+ accessory.context.Television = accessory.context.Television ?? {};
45
49
  this.Television = {
46
- Service: accessory.getService(this.hap.Service.Television) as Service,
47
- Active: accessory.context.Active || this.hap.Characteristic.Active.INACTIVE,
48
- ActiveIdentifier: accessory.context.ActiveIdentifier || 1,
49
- SleepDiscoveryMode: accessory.context.SleepDiscoveryMode || this.hap.Characteristic.SleepDiscoveryMode.ALWAYS_DISCOVERABLE,
50
- RemoteKey: accessory.context.RemoteKey || this.hap.Characteristic.RemoteKey.EXIT,
50
+ Name: accessory.context.Television.Name ?? `${accessory.displayName} ${device.remoteType}`,
51
+ ConfiguredName: accessory.context.Television.ConfiguredName ?? `${accessory.displayName} ${device.remoteType}`,
52
+ Service: accessory.getService(this.hap.Service.Television) ?? accessory.addService(this.hap.Service.Television) as Service,
53
+ Active: accessory.context.Active ?? this.hap.Characteristic.Active.INACTIVE,
54
+ ActiveIdentifier: accessory.context.ActiveIdentifier ?? 1,
55
+ SleepDiscoveryMode: accessory.context.SleepDiscoveryMode ?? this.hap.Characteristic.SleepDiscoveryMode.ALWAYS_DISCOVERABLE,
56
+ RemoteKey: accessory.context.RemoteKey ?? this.hap.Characteristic.RemoteKey.EXIT,
51
57
  };
58
+ accessory.context.Television = this.Television as object;
52
59
 
53
- // Initialize TelevisionSpeaker property
54
- this.TelevisionSpeaker = {
55
- Service: accessory.getService(this.hap.Service.TelevisionSpeaker) as Service,
56
- Active: accessory.context.Active || false,
57
- VolumeControlType: accessory.context.VolumeControlType || this.hap.Characteristic.VolumeControlType.ABSOLUTE,
58
- VolumeSelector: accessory.context.VolumeSelector || this.hap.Characteristic.VolumeSelector.INCREMENT,
59
- };
60
-
61
- // default placeholders
62
- if (this.Television.Active === undefined) {
63
- this.Television.Active = this.hap.Characteristic.Active.INACTIVE;
64
- } else {
65
- this.Television.Active = this.accessory.context.Active;
66
- }
67
- if (this.Television.ActiveIdentifier === undefined) {
68
- this.Television.ActiveIdentifier = 1;
69
- } else {
70
- this.Television.ActiveIdentifier = this.accessory.context.ActiveIdentifier;
71
- }
72
-
73
- // set the accessory category
74
- const TelevisionServiceCategory = `${accessory.displayName} ${device.remoteType}`;
75
60
  switch (device.remoteType) {
76
61
  case 'Speaker':
77
62
  case 'DIY Speaker':
78
63
  accessory.category = this.platform.api.hap.Categories.SPEAKER;
79
- (this.Television.Service = accessory.getService(this.hap.Service.Television)
80
- || accessory.addService(this.hap.Service.Television)), TelevisionServiceCategory;
81
64
  break;
82
65
  case 'IPTV':
83
66
  case 'DIY IPTV':
84
67
  accessory.category = this.platform.api.hap.Categories.TV_STREAMING_STICK;
85
- (this.Television.Service = accessory.getService(this.hap.Service.Television)
86
- || accessory.addService(this.hap.Service.Television)), TelevisionServiceCategory;
87
68
  break;
88
69
  case 'DVD':
89
70
  case 'DIY DVD':
90
71
  case 'Set Top Box':
91
72
  case 'DIY Set Top Box':
92
73
  accessory.category = this.platform.api.hap.Categories.TV_SET_TOP_BOX;
93
- (this.Television.Service = accessory.getService(this.hap.Service.Television)
94
- || accessory.addService(this.hap.Service.Television)), TelevisionServiceCategory;
95
74
  break;
96
75
  default:
97
76
  accessory.category = this.platform.api.hap.Categories.TELEVISION;
98
-
99
- // get the Television service if it exists, otherwise create a new Television service
100
- // you can create multiple services for each accessory
101
- (this.Television.Service = accessory.getService(this.hap.Service.Television)
102
- || accessory.addService(this.hap.Service.Television)), TelevisionServiceCategory;
103
77
  }
104
78
 
105
- this.Television.Service.getCharacteristic(this.hap.Characteristic.ConfiguredName);
106
-
107
- // set sleep discovery characteristic
108
- this.Television.Service.setCharacteristic(
109
- this.hap.Characteristic.SleepDiscoveryMode,
110
- this.hap.Characteristic.SleepDiscoveryMode.ALWAYS_DISCOVERABLE,
111
- );
112
-
113
- // handle on / off events using the Active characteristic
114
- this.Television.Service.getCharacteristic(this.hap.Characteristic.Active).onSet(this.ActiveSet.bind(this));
115
-
116
- this.Television.Service.setCharacteristic(this.hap.Characteristic.ActiveIdentifier, 1);
117
-
118
- // handle input source changes
119
- this.Television.Service.getCharacteristic(this.hap.Characteristic.ActiveIdentifier).onSet(this.ActiveIdentifierSet.bind(this));
120
-
121
- // handle remote control input
122
- this.Television.Service.getCharacteristic(this.hap.Characteristic.RemoteKey).onSet(this.RemoteKeySet.bind(this));
123
-
124
- /**
125
- * Create a speaker service to allow volume control
126
- */
127
- // create a new Television Speaker service
128
- const TelevisionSpeakerService = `${accessory.displayName} Speaker`;
129
- (this.TelevisionSpeaker.Service = accessory.getService(this.hap.Service.TelevisionSpeaker)
130
- || accessory.addService(this.hap.Service.TelevisionSpeaker)), TelevisionSpeakerService;
79
+ this.Television.Service
80
+ .setCharacteristic(this.hap.Characteristic.SleepDiscoveryMode, this.hap.Characteristic.SleepDiscoveryMode.ALWAYS_DISCOVERABLE)
81
+ .setCharacteristic(this.hap.Characteristic.ConfiguredName, this.Television.ConfiguredName)
82
+ .getCharacteristic(this.hap.Characteristic.ConfiguredName);
83
+
84
+ this.Television.Service
85
+ .setCharacteristic(this.hap.Characteristic.ActiveIdentifier, 1)
86
+ .getCharacteristic(this.hap.Characteristic.Active)
87
+ .onGet(() => {
88
+ return this.Television.Active;
89
+ })
90
+ .onSet(this.ActiveSet.bind(this));
91
+
92
+ this.Television.Service
93
+ .getCharacteristic(this.hap.Characteristic.ActiveIdentifier)
94
+ .onGet(() => {
95
+ return this.Television.ActiveIdentifier;
96
+ })
97
+ .onSet(this.ActiveIdentifierSet.bind(this));
98
+
99
+ this.Television.Service
100
+ .getCharacteristic(this.hap.Characteristic.RemoteKey)
101
+ .onGet(() => {
102
+ return this.Television.RemoteKey;
103
+ })
104
+ .onSet(this.RemoteKeySet.bind(this));
105
+
106
+ // Initialize TelevisionSpeaker Service
107
+ accessory.context.TelevisionSpeaker = accessory.context.TelevisionSpeaker ?? {};
108
+ this.TelevisionSpeaker = {
109
+ Name: accessory.context.TelevisionSpeaker.Name ?? `${accessory.displayName} ${device.remoteType} Speaker`,
110
+ Service: accessory.getService(this.hap.Service.TelevisionSpeaker) ?? accessory.addService(this.hap.Service.TelevisionSpeaker) as Service,
111
+ Active: accessory.context.Active ?? false,
112
+ VolumeControlType: accessory.context.VolumeControlType ?? this.hap.Characteristic.VolumeControlType.ABSOLUTE,
113
+ VolumeSelector: accessory.context.VolumeSelector ?? this.hap.Characteristic.VolumeSelector.INCREMENT,
114
+ };
115
+ accessory.context.TelevisionSpeaker = this.TelevisionSpeaker as object;
131
116
 
132
- this.TelevisionSpeaker.Service.setCharacteristic(this.hap.Characteristic.Name, TelevisionSpeakerService);
133
117
  this.TelevisionSpeaker.Service
118
+ .setCharacteristic(this.hap.Characteristic.Name, this.TelevisionSpeaker.Name)
134
119
  .setCharacteristic(this.hap.Characteristic.Active, this.hap.Characteristic.Active.ACTIVE)
135
- .setCharacteristic(this.hap.Characteristic.VolumeControlType, this.hap.Characteristic.VolumeControlType.ABSOLUTE);
136
-
137
- // handle volume control
138
- this.TelevisionSpeaker.Service.getCharacteristic(this.hap.Characteristic.VolumeSelector).onSet(this.VolumeSelectorSet.bind(this));
120
+ .setCharacteristic(this.hap.Characteristic.VolumeControlType, this.hap.Characteristic.VolumeControlType.ABSOLUTE)
121
+ .getCharacteristic(this.hap.Characteristic.VolumeSelector)
122
+ .onGet(() => {
123
+ return this.TelevisionSpeaker.VolumeSelector;
124
+ })
125
+ .onSet(this.VolumeSelectorSet.bind(this));
139
126
  }
140
127
 
141
128
  async VolumeSelectorSet(value: CharacteristicValue): Promise<void> {
@@ -18,6 +18,7 @@ import type { CharacteristicValue, PlatformAccessory, Service } from 'homebridge
18
18
  export class VacuumCleaner extends irdeviceBase {
19
19
  // Services
20
20
  private Switch: {
21
+ Name: CharacteristicValue;
21
22
  Service: Service;
22
23
  On: CharacteristicValue;
23
24
  };
@@ -29,21 +30,22 @@ export class VacuumCleaner extends irdeviceBase {
29
30
  ) {
30
31
  super(platform, accessory, device);
31
32
 
32
- // Initialize Switch property
33
+ // Initialize Switch Service
34
+ accessory.context.Switch = accessory.context.Switch ?? {};
33
35
  this.Switch = {
34
- Service: accessory.getService(this.hap.Service.Switch) as Service,
35
- On: accessory.context.On || false,
36
+ Name: accessory.context.Switch.Name ?? `${accessory.displayName} ${device.remoteType}`,
37
+ Service: accessory.getService(this.hap.Service.Switch) ?? accessory.addService(this.hap.Service.Switch) as Service,
38
+ On: accessory.context.On ?? false,
36
39
  };
40
+ accessory.context.Switch = this.Switch as object;
37
41
 
38
- // get the Switch service if it exists, otherwise create a new Switch service
39
- const SwitchService = `${accessory.displayName} ${device.remoteType}`;
40
- (this.Switch.Service = accessory.getService(this.hap.Service.Switch)
41
- || accessory.addService(this.hap.Service.Switch)), SwitchService;
42
-
43
- this.Switch.Service.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
44
-
45
- // handle on / off events using the On characteristic
46
- this.Switch.Service.getCharacteristic(this.hap.Characteristic.On).onSet(this.OnSet.bind(this));
42
+ this.Switch.Service
43
+ .setCharacteristic(this.hap.Characteristic.Name, this.Switch.Name)
44
+ .getCharacteristic(this.hap.Characteristic.On)
45
+ .onGet(() => {
46
+ return this.Switch.On;
47
+ })
48
+ .onSet(this.OnSet.bind(this));
47
49
  }
48
50
 
49
51
  async OnSet(value: CharacteristicValue): Promise<void> {
@@ -18,6 +18,7 @@ import type { CharacteristicValue, PlatformAccessory, Service } from 'homebridge
18
18
  export class WaterHeater extends irdeviceBase {
19
19
  // Services
20
20
  private Valve: {
21
+ Name: CharacteristicValue;
21
22
  Service: Service;
22
23
  Active: CharacteristicValue;
23
24
  };
@@ -29,25 +30,23 @@ export class WaterHeater extends irdeviceBase {
29
30
  ) {
30
31
  super(platform, accessory, device);
31
32
 
32
- // Initialize Valve property
33
+ // Initialize Switch Service
34
+ accessory.context.Valve = accessory.context.Valve ?? {};
33
35
  this.Valve = {
34
- Service: accessory.getService(this.hap.Service.Valve) as Service,
35
- Active: accessory.context.Active || this.hap.Characteristic.Active.INACTIVE,
36
+ Name: accessory.context.Valve.Name ?? `${accessory.displayName} ${device.remoteType}`,
37
+ Service: accessory.getService(this.hap.Service.Valve) ?? accessory.addService(this.hap.Service.Valve) as Service,
38
+ Active: accessory.context.Active ?? this.hap.Characteristic.Active.INACTIVE,
36
39
  };
40
+ accessory.context.Valve = this.Valve as object;
37
41
 
38
- // get the Television service if it exists, otherwise create a new Television service
39
- // you can create multiple services for each accessory
40
- const ValveService = `${accessory.displayName} ${device.remoteType}`;
41
- (this.Valve.Service = accessory.getService(this.hap.Service.Valve)
42
- || accessory.addService(this.hap.Service.Valve)), ValveService;
43
-
44
- this.Valve.Service.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
45
-
46
- // set sleep discovery characteristic
47
- this.Valve.Service.setCharacteristic(this.hap.Characteristic.ValveType, this.hap.Characteristic.ValveType.GENERIC_VALVE);
48
-
49
- // handle on / off events using the Active characteristic
50
- this.Valve.Service.getCharacteristic(this.hap.Characteristic.Active).onSet(this.ActiveSet.bind(this));
42
+ this.Valve.Service
43
+ .setCharacteristic(this.hap.Characteristic.Name, accessory.displayName)
44
+ .setCharacteristic(this.hap.Characteristic.ValveType, this.hap.Characteristic.ValveType.GENERIC_VALVE)
45
+ .getCharacteristic(this.hap.Characteristic.Active)
46
+ .onGet(() => {
47
+ return this.Valve.Active;
48
+ })
49
+ .onSet(this.ActiveSet.bind(this));
51
50
  }
52
51
 
53
52
  async ActiveSet(value: CharacteristicValue): Promise<void> {