@switchbot/homebridge-switchbot 3.5.0-beta.31 → 3.5.0-beta.33

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.
package/src/device/bot.ts CHANGED
@@ -1064,92 +1064,92 @@ export class Bot extends deviceBase {
1064
1064
 
1065
1065
  async removeOutletService(accessory: PlatformAccessory): Promise<void> {
1066
1066
  // If outletService still present, then remove first
1067
- this.Outlet!.Service = this.accessory.getService(this.hap.Service.Outlet) as Service;
1068
1067
  if (this.Outlet?.Service) {
1069
- this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Outlet Service`);
1070
- }
1068
+ this.Outlet!.Service = this.accessory.getService(this.hap.Service.Outlet) as Service;
1069
+ this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Outlet Service`);
1071
1070
  accessory.removeService(this.Outlet!.Service);
1071
+ }
1072
1072
  }
1073
1073
 
1074
1074
  async removeGarageDoorService(accessory: PlatformAccessory): Promise<void> {
1075
1075
  // If garageDoorService still present, then remove first
1076
- this.GarageDoor!.Service = this.accessory.getService(this.hap.Service.GarageDoorOpener) as Service;
1077
1076
  if (this.GarageDoor?.Service) {
1078
- this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Garage Door Service`);
1079
- }
1077
+ this.GarageDoor!.Service = this.accessory.getService(this.hap.Service.GarageDoorOpener) as Service;
1078
+ this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Garage Door Service`);
1080
1079
  accessory.removeService(this.GarageDoor!.Service);
1080
+ }
1081
1081
  }
1082
1082
 
1083
1083
  async removeDoorService(accessory: PlatformAccessory): Promise<void> {
1084
1084
  // If doorService still present, then remove first
1085
- this.Door!.Service = this.accessory.getService(this.hap.Service.Door) as Service;
1086
1085
  if (this.Door?.Service) {
1087
- this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Door Service`);
1088
- }
1086
+ this.Door!.Service = this.accessory.getService(this.hap.Service.Door) as Service;
1087
+ this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Door Service`);
1089
1088
  accessory.removeService(this.Door!.Service);
1089
+ }
1090
1090
  }
1091
1091
 
1092
1092
  async removeLockService(accessory: PlatformAccessory): Promise<void> {
1093
1093
  // If lockService still present, then remove first
1094
- this.Lock!.Service = this.accessory.getService(this.hap.Service.LockMechanism) as Service;
1095
1094
  if (this.Lock?.Service) {
1096
- this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Lock Service`);
1097
- }
1095
+ this.Lock!.Service = this.accessory.getService(this.hap.Service.LockMechanism) as Service;
1096
+ this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Lock Service`);
1098
1097
  accessory.removeService(this.Lock!.Service);
1098
+ }
1099
1099
  }
1100
1100
 
1101
1101
  async removeFaucetService(accessory: PlatformAccessory): Promise<void> {
1102
1102
  // If faucetService still present, then remove first
1103
- this.Faucet!.Service = this.accessory.getService(this.hap.Service.Faucet) as Service;
1104
1103
  if (this.Faucet?.Service) {
1104
+ this.Faucet!.Service = this.accessory.getService(this.hap.Service.Faucet) as Service;
1105
1105
  this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Faucet Service`);
1106
+ accessory.removeService(this.Faucet!.Service);
1106
1107
  }
1107
- accessory.removeService(this.Faucet!.Service);
1108
1108
  }
1109
1109
 
1110
1110
  async removeFanService(accessory: PlatformAccessory): Promise<void> {
1111
1111
  // If fanService still present, then remove first
1112
- this.Fan!.Service = this.accessory.getService(this.hap.Service.Fanv2) as Service;
1113
1112
  if (this.Fan?.Service) {
1114
- this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Fan Service`);
1115
- }
1113
+ this.Fan!.Service = this.accessory.getService(this.hap.Service.Fanv2) as Service;
1114
+ this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Fan Service`);
1116
1115
  accessory.removeService(this.Fan!.Service);
1116
+ }
1117
1117
  }
1118
1118
 
1119
1119
  async removeWindowService(accessory: PlatformAccessory): Promise<void> {
1120
1120
  // If windowService still present, then remove first
1121
- this.Window!.Service = this.accessory.getService(this.hap.Service.Window) as Service;
1122
1121
  if (this.Window?.Service) {
1123
- this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Window Service`);
1124
- }
1122
+ this.Window!.Service = this.accessory.getService(this.hap.Service.Window) as Service;
1123
+ this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Window Service`);
1125
1124
  accessory.removeService(this.Window!.Service);
1125
+ }
1126
1126
  }
1127
1127
 
1128
1128
  async removeWindowCoveringService(accessory: PlatformAccessory): Promise<void> {
1129
1129
  // If windowCoveringService still present, then remove first
1130
- this.WindowCovering!.Service = this.accessory.getService(this.hap.Service.WindowCovering) as Service;
1131
1130
  if (this.WindowCovering?.Service) {
1132
- this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Window Covering Service`);
1133
- }
1131
+ this.WindowCovering!.Service = this.accessory.getService(this.hap.Service.WindowCovering) as Service;
1132
+ this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Window Covering Service`);
1134
1133
  accessory.removeService(this.WindowCovering!.Service);
1134
+ }
1135
1135
  }
1136
1136
 
1137
1137
  async removeStatefulProgrammableSwitchService(accessory: PlatformAccessory): Promise<void> {
1138
1138
  // If statefulProgrammableSwitchService still present, then remove first
1139
- this.StatefulProgrammableSwitch!.Service = this.accessory.getService(this.hap.Service.StatefulProgrammableSwitch) as Service;
1140
1139
  if (this.StatefulProgrammableSwitch?.Service) {
1140
+ this.StatefulProgrammableSwitch!.Service = this.accessory.getService(this.hap.Service.StatefulProgrammableSwitch) as Service;
1141
1141
  this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Stateful Programmable Switch Service`);
1142
+ accessory.removeService(this.StatefulProgrammableSwitch!.Service);
1142
1143
  }
1143
- accessory.removeService(this.StatefulProgrammableSwitch!.Service);
1144
1144
  }
1145
1145
 
1146
1146
  async removeSwitchService(accessory: PlatformAccessory): Promise<void> {
1147
1147
  // If switchService still present, then remove first
1148
- this.Switch!.Service = this.accessory.getService(this.hap.Service.Switch) as Service;
1149
1148
  if (this.Switch?.Service) {
1150
- this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Switch Service`);
1151
- }
1149
+ this.Switch!.Service = this.accessory.getService(this.hap.Service.Switch) as Service;
1150
+ this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Switch Service`);
1152
1151
  accessory.removeService(this.Switch!.Service);
1152
+ }
1153
1153
  }
1154
1154
 
1155
1155
  async getOn(): Promise<boolean> {
@@ -528,11 +528,14 @@ export abstract class deviceBase {
528
528
  accessory.context.model = device.model;
529
529
  accessory.context.deviceId = device.deviceId;
530
530
  accessory.context.deviceType = device.deviceType;
531
- if (device.firmware === undefined) {
532
- device.firmware = this.platform.version;
531
+
532
+ if (device.firmware) {
533
533
  accessory.context.FirmwareRevision = device.firmware;
534
+ } else if (device.firmware === undefined && device.version === undefined) {
535
+ device.version = this.platform.version;
536
+ accessory.context.FirmwareRevision = device.version;
534
537
  } else {
535
- accessory.context.FirmwareRevision = device.firmware;
538
+ accessory.context.FirmwareRevision = device.version;
536
539
  }
537
540
  }
538
541
 
@@ -325,11 +325,13 @@ export abstract class irdeviceBase {
325
325
  accessory.context.model = device.remoteType;
326
326
  accessory.context.deviceId = device.deviceId;
327
327
  accessory.context.remoteType = device.remoteType;
328
- if (device.firmware === undefined) {
328
+ if (device.firmware) {
329
+ accessory.context.FirmwareRevision = device.firmware;
330
+ } else if (device.firmware === undefined) {
329
331
  device.firmware = this.platform.version;
330
332
  accessory.context.FirmwareRevision = device.firmware;
331
333
  } else {
332
- accessory.context.FirmwareRevision = device.firmware;
334
+ accessory.context.FirmwareRevision = 'Unknown';
333
335
  }
334
336
  }
335
337