@switchbot/homebridge-switchbot 2.8.2 → 2.9.0-beta.0
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/.github/npm-version-script.js +81 -0
- package/CHANGELOG.md +9 -0
- package/config.schema.json +37 -1
- package/dist/device/bot.d.ts +2 -0
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +48 -37
- package/dist/device/bot.js.map +1 -1
- package/dist/irdevice/other.d.ts +24 -2
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +572 -38
- package/dist/irdevice/other.js.map +1 -1
- package/package.json +4 -4
- package/src/device/bot.ts +49 -37
- package/src/irdevice/other.ts +605 -39
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
#!/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This scripts queries the npm registry to pull out the latest version for a given tag.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const fs = require("fs");
|
|
8
|
+
const semver = require("semver");
|
|
9
|
+
const child_process = require("child_process");
|
|
10
|
+
const assert = require("assert");
|
|
11
|
+
|
|
12
|
+
const BRANCH_VERSION_PATTERN = /^([A-Za-z]*)-(\d+.\d+.\d+)$/
|
|
13
|
+
|
|
14
|
+
// Load the contents of the package.json file
|
|
15
|
+
const packageJSON = JSON.parse(fs.readFileSync("package.json", "utf8"));
|
|
16
|
+
|
|
17
|
+
let refArgument = process.argv[2];
|
|
18
|
+
let tagArgument = process.argv[3] || "latest";
|
|
19
|
+
|
|
20
|
+
if (refArgument == null) {
|
|
21
|
+
console.error("ref argument is missing");
|
|
22
|
+
console.error("Usage: npm-version-script.js <ref> [tag]");
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Queries the NPM registry for the latest version for the provided tag.
|
|
28
|
+
* @param tag The tag to query for.
|
|
29
|
+
* @returns {string} Returns the version.
|
|
30
|
+
*/
|
|
31
|
+
function getTagVersionFromNpm(tag) {
|
|
32
|
+
try {
|
|
33
|
+
return child_process.execSync(`npm info ${packageJSON.name} version --tag="${tag}"`).toString("utf8").trim();
|
|
34
|
+
} catch (e) {
|
|
35
|
+
throw e;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function desiredTargetVersion(ref) {
|
|
40
|
+
// ref is a GitHub action ref string
|
|
41
|
+
if (ref.startsWith("refs/pull/")) {
|
|
42
|
+
throw Error("The version script was executed inside a PR!");
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
assert(ref.startsWith("refs/heads/"))
|
|
46
|
+
let branchName = ref.slice("refs/heads/".length);
|
|
47
|
+
|
|
48
|
+
let results = branchName.match(BRANCH_VERSION_PATTERN);
|
|
49
|
+
if (results != null) {
|
|
50
|
+
if (results[1] !== tagArgument) {
|
|
51
|
+
console.warn(`The base branch name (${results[1]}) differs from the tag name ${tagArgument}`);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return results[2];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// legacy mode were we use the `betaVersion` property in the package.json
|
|
58
|
+
if (branchName === "beta" && packageJSON.betaVersion) {
|
|
59
|
+
return packageJSON.betaVersion
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
throw new Error("Malformed branch name for ref: " + ref + ". Can't derive the base version. Use a branch name like: beta-x.x.x!");
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// derive the base version from the branch ref
|
|
66
|
+
const baseVersion = desiredTargetVersion(refArgument);
|
|
67
|
+
|
|
68
|
+
// query the npm registry for the latest version of the provided tag name
|
|
69
|
+
const latestReleasedVersion = getTagVersionFromNpm(tagArgument); // e.g. 0.7.0-beta.12
|
|
70
|
+
const latestReleaseBase = semver.inc(latestReleasedVersion, "patch"); // will produce 0.7.0 (removing the preid, needed for the equality check below)
|
|
71
|
+
|
|
72
|
+
let publishTag;
|
|
73
|
+
if (semver.eq(baseVersion, latestReleaseBase)) { // check if we are releasing another version for the latest beta
|
|
74
|
+
publishTag = latestReleasedVersion; // set the current latest beta to be incremented
|
|
75
|
+
} else {
|
|
76
|
+
publishTag = baseVersion; // start of with a new beta version
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// save the package.json
|
|
80
|
+
packageJSON.version = publishTag;
|
|
81
|
+
fs.writeFileSync("package.json", JSON.stringify(packageJSON, null, 2));
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. This project uses [Semantic Versioning](https://semver.org/)
|
|
4
4
|
|
|
5
|
+
## [Version 2.9.0](https://github.com/OpenWonderLabs/homebridge-switchbot/releases/tag/v2.9.0) (2023-08-XX)
|
|
6
|
+
|
|
7
|
+
## What's Changed
|
|
8
|
+
|
|
9
|
+
- Add other `deviceTypes` for IR Type `Other`.
|
|
10
|
+
- Housekeeping and updated dependencies.
|
|
11
|
+
|
|
12
|
+
**Full Changelog**: https://github.com/OpenWonderLabs/homebridge-switchbot/compare/v2.8.2....v2.9.0
|
|
13
|
+
|
|
5
14
|
## [Version 2.8.2](https://github.com/OpenWonderLabs/homebridge-switchbot/releases/tag/v2.8.2) (2023-08-27)
|
|
6
15
|
|
|
7
16
|
## What's Changed
|
package/config.schema.json
CHANGED
|
@@ -1102,9 +1102,45 @@
|
|
|
1102
1102
|
"title": "What Type of Device do you want to display in the Home App?",
|
|
1103
1103
|
"type": "string",
|
|
1104
1104
|
"oneOf": [
|
|
1105
|
+
{
|
|
1106
|
+
"title": "Outlet",
|
|
1107
|
+
"enum": ["outlet"]
|
|
1108
|
+
},
|
|
1109
|
+
{
|
|
1110
|
+
"title": "Garage Door",
|
|
1111
|
+
"enum": ["garagedoor"]
|
|
1112
|
+
},
|
|
1113
|
+
{
|
|
1114
|
+
"title": "Door",
|
|
1115
|
+
"enum": ["door"]
|
|
1116
|
+
},
|
|
1117
|
+
{
|
|
1118
|
+
"title": "Lock",
|
|
1119
|
+
"enum": ["lock"]
|
|
1120
|
+
},
|
|
1121
|
+
{
|
|
1122
|
+
"title": "Faucet",
|
|
1123
|
+
"enum": ["faucet"]
|
|
1124
|
+
},
|
|
1105
1125
|
{
|
|
1106
1126
|
"title": "Fan",
|
|
1107
|
-
"enum": ["
|
|
1127
|
+
"enum": ["fan"]
|
|
1128
|
+
},
|
|
1129
|
+
{
|
|
1130
|
+
"title": "Window",
|
|
1131
|
+
"enum": ["window"]
|
|
1132
|
+
},
|
|
1133
|
+
{
|
|
1134
|
+
"title": "Window Covering",
|
|
1135
|
+
"enum": ["windowcovering"]
|
|
1136
|
+
},
|
|
1137
|
+
{
|
|
1138
|
+
"title": "Stateful Programmable Switch (Only Works in 3rd Party Home Apps)",
|
|
1139
|
+
"enum": ["stateful"]
|
|
1140
|
+
},
|
|
1141
|
+
{
|
|
1142
|
+
"title": "Switch",
|
|
1143
|
+
"enum": ["switch"]
|
|
1108
1144
|
}
|
|
1109
1145
|
],
|
|
1110
1146
|
"condition": {
|
package/dist/device/bot.d.ts
CHANGED
|
@@ -39,6 +39,7 @@ export declare class Bot {
|
|
|
39
39
|
allowPush?: boolean;
|
|
40
40
|
doublePress: number;
|
|
41
41
|
scanDuration: number;
|
|
42
|
+
botDeviceType: string;
|
|
42
43
|
pushRatePress: number;
|
|
43
44
|
deviceLogging: string;
|
|
44
45
|
multiPressCount: number;
|
|
@@ -108,6 +109,7 @@ export declare class Bot {
|
|
|
108
109
|
offlineOff(): Promise<void>;
|
|
109
110
|
apiError(e: any): Promise<void>;
|
|
110
111
|
setFirmwareRevision(accessory: PlatformAccessory<Context>, device: device & devicesConfig): CharacteristicValue;
|
|
112
|
+
deviceType(device: device & devicesConfig): Promise<void>;
|
|
111
113
|
context(): Promise<void>;
|
|
112
114
|
refreshRate(device: device & devicesConfig): Promise<void>;
|
|
113
115
|
config(device: device & devicesConfig): Promise<void>;
|
package/dist/device/bot.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bot.d.ts","sourceRoot":"","sources":["../../src/device/bot.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAG7B,OAAO,EAAY,OAAO,EAAE,MAAM,MAAM,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAC7E,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,YAAY,EAAM,WAAW,EAAW,MAAM,aAAa,CAAC;AAE5F;;;;GAIG;AACH,qBAAa,GAAG;
|
|
1
|
+
{"version":3,"file":"bot.d.ts","sourceRoot":"","sources":["../../src/device/bot.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAG7B,OAAO,EAAY,OAAO,EAAE,MAAM,MAAM,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAC7E,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,YAAY,EAAM,WAAW,EAAW,MAAM,aAAa,CAAC;AAE5F;;;;GAIG;AACH,qBAAa,GAAG;IAqDZ,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,SAAS;IACV,MAAM,EAAE,MAAM,GAAG,aAAa;IArDvC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,cAAc,EAAE,OAAO,C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M,EAAE,MAAM,GAAG,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAgBzD;;OAEG;IACH,OAAO,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI;IAM5B,OAAO,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI;IAM5B,YAAY,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI;IAQjC,QAAQ,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI;IAM7B,aAAa,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI;IAQlC,QAAQ,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI;IAU7B,qBAAqB,IAAI,OAAO;CAGjC"}
|
package/dist/device/bot.js
CHANGED
|
@@ -21,6 +21,7 @@ class Bot {
|
|
|
21
21
|
this.OpenAPI = this.device.connectionType === 'OpenAPI' || this.device.connectionType === 'BLE/OpenAPI';
|
|
22
22
|
// default placeholders
|
|
23
23
|
this.logs(device);
|
|
24
|
+
this.deviceType(device);
|
|
24
25
|
this.scan(device);
|
|
25
26
|
this.refreshRate(device);
|
|
26
27
|
this.PressOrSwitch(device);
|
|
@@ -43,9 +44,8 @@ class Bot {
|
|
|
43
44
|
.setCharacteristic(this.platform.Characteristic.FirmwareRevision, this.setFirmwareRevision(accessory, device))
|
|
44
45
|
.getCharacteristic(this.platform.Characteristic.FirmwareRevision)
|
|
45
46
|
.updateValue(this.setFirmwareRevision(accessory, device));
|
|
46
|
-
//
|
|
47
|
-
|
|
48
|
-
if (device.bot?.deviceType === 'switch') {
|
|
47
|
+
// deviceType
|
|
48
|
+
if (this.botDeviceType === 'switch') {
|
|
49
49
|
this.removeFanService(accessory);
|
|
50
50
|
this.removeLockService(accessory);
|
|
51
51
|
this.removeDoorService(accessory);
|
|
@@ -65,7 +65,7 @@ class Bot {
|
|
|
65
65
|
}
|
|
66
66
|
this.switchService.getCharacteristic(this.platform.Characteristic.On).onSet(this.OnSet.bind(this));
|
|
67
67
|
}
|
|
68
|
-
else if (
|
|
68
|
+
else if (this.botDeviceType === 'garagedoor') {
|
|
69
69
|
this.removeFanService(accessory);
|
|
70
70
|
this.removeLockService(accessory);
|
|
71
71
|
this.removeDoorService(accessory);
|
|
@@ -87,7 +87,7 @@ class Bot {
|
|
|
87
87
|
this.garageDoorService.getCharacteristic(this.platform.Characteristic.TargetDoorState).onSet(this.OnSet.bind(this));
|
|
88
88
|
this.garageDoorService.setCharacteristic(this.platform.Characteristic.ObstructionDetected, false);
|
|
89
89
|
}
|
|
90
|
-
else if (
|
|
90
|
+
else if (this.botDeviceType === 'door') {
|
|
91
91
|
this.removeFanService(accessory);
|
|
92
92
|
this.removeLockService(accessory);
|
|
93
93
|
this.removeOutletService(accessory);
|
|
@@ -116,7 +116,7 @@ class Bot {
|
|
|
116
116
|
.onSet(this.OnSet.bind(this));
|
|
117
117
|
this.doorService.setCharacteristic(this.platform.Characteristic.PositionState, this.platform.Characteristic.PositionState.STOPPED);
|
|
118
118
|
}
|
|
119
|
-
else if (
|
|
119
|
+
else if (this.botDeviceType === 'window') {
|
|
120
120
|
this.removeFanService(accessory);
|
|
121
121
|
this.removeLockService(accessory);
|
|
122
122
|
this.removeDoorService(accessory);
|
|
@@ -145,7 +145,7 @@ class Bot {
|
|
|
145
145
|
.onSet(this.OnSet.bind(this));
|
|
146
146
|
this.windowService.setCharacteristic(this.platform.Characteristic.PositionState, this.platform.Characteristic.PositionState.STOPPED);
|
|
147
147
|
}
|
|
148
|
-
else if (
|
|
148
|
+
else if (this.botDeviceType === 'windowcovering') {
|
|
149
149
|
this.removeFanService(accessory);
|
|
150
150
|
this.removeLockService(accessory);
|
|
151
151
|
this.removeDoorService(accessory);
|
|
@@ -175,7 +175,7 @@ class Bot {
|
|
|
175
175
|
.onSet(this.OnSet.bind(this));
|
|
176
176
|
this.windowCoveringService.setCharacteristic(this.platform.Characteristic.PositionState, this.platform.Characteristic.PositionState.STOPPED);
|
|
177
177
|
}
|
|
178
|
-
else if (
|
|
178
|
+
else if (this.botDeviceType === 'lock') {
|
|
179
179
|
this.removeFanService(accessory);
|
|
180
180
|
this.removeDoorService(accessory);
|
|
181
181
|
this.removeOutletService(accessory);
|
|
@@ -195,7 +195,7 @@ class Bot {
|
|
|
195
195
|
}
|
|
196
196
|
this.lockService.getCharacteristic(this.platform.Characteristic.LockTargetState).onSet(this.OnSet.bind(this));
|
|
197
197
|
}
|
|
198
|
-
else if (
|
|
198
|
+
else if (this.botDeviceType === 'faucet') {
|
|
199
199
|
this.removeFanService(accessory);
|
|
200
200
|
this.removeLockService(accessory);
|
|
201
201
|
this.removeDoorService(accessory);
|
|
@@ -215,7 +215,7 @@ class Bot {
|
|
|
215
215
|
}
|
|
216
216
|
this.faucetService.getCharacteristic(this.platform.Characteristic.Active).onSet(this.OnSet.bind(this));
|
|
217
217
|
}
|
|
218
|
-
else if (
|
|
218
|
+
else if (this.botDeviceType === 'fan') {
|
|
219
219
|
this.removeLockService(accessory);
|
|
220
220
|
this.removeDoorService(accessory);
|
|
221
221
|
this.removeFaucetService(accessory);
|
|
@@ -235,7 +235,7 @@ class Bot {
|
|
|
235
235
|
}
|
|
236
236
|
this.fanService.getCharacteristic(this.platform.Characteristic.On).onSet(this.OnSet.bind(this));
|
|
237
237
|
}
|
|
238
|
-
else if (
|
|
238
|
+
else if (this.botDeviceType === 'stateful') {
|
|
239
239
|
this.removeFanService(accessory);
|
|
240
240
|
this.removeLockService(accessory);
|
|
241
241
|
this.removeDoorService(accessory);
|
|
@@ -558,7 +558,7 @@ class Bot {
|
|
|
558
558
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Done.`);
|
|
559
559
|
this.accessory.context.On = this.On;
|
|
560
560
|
setTimeout(() => {
|
|
561
|
-
if (this.
|
|
561
|
+
if (this.botDeviceType === 'switch') {
|
|
562
562
|
this.switchService?.getCharacteristic(this.platform.Characteristic.On).updateValue(this.On);
|
|
563
563
|
}
|
|
564
564
|
else {
|
|
@@ -689,7 +689,7 @@ class Bot {
|
|
|
689
689
|
* Handle requests to set the "On" characteristic
|
|
690
690
|
*/
|
|
691
691
|
async OnSet(value) {
|
|
692
|
-
if (this.
|
|
692
|
+
if (this.botDeviceType === 'garagedoor') {
|
|
693
693
|
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set TargetDoorState: ${value}`);
|
|
694
694
|
if (value === this.platform.Characteristic.TargetDoorState.CLOSED) {
|
|
695
695
|
this.On = false;
|
|
@@ -698,9 +698,9 @@ class Bot {
|
|
|
698
698
|
this.On = true;
|
|
699
699
|
}
|
|
700
700
|
}
|
|
701
|
-
else if (this.
|
|
702
|
-
this.
|
|
703
|
-
this.
|
|
701
|
+
else if (this.botDeviceType === 'door' ||
|
|
702
|
+
this.botDeviceType === 'window' ||
|
|
703
|
+
this.botDeviceType === 'windowcovering') {
|
|
704
704
|
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set TargetPosition: ${value}`);
|
|
705
705
|
if (value === 0) {
|
|
706
706
|
this.On = false;
|
|
@@ -709,7 +709,7 @@ class Bot {
|
|
|
709
709
|
this.On = true;
|
|
710
710
|
}
|
|
711
711
|
}
|
|
712
|
-
else if (this.
|
|
712
|
+
else if (this.botDeviceType === 'lock') {
|
|
713
713
|
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set LockTargetState: ${value}`);
|
|
714
714
|
if (value === this.platform.Characteristic.LockTargetState.SECURED) {
|
|
715
715
|
this.On = false;
|
|
@@ -718,7 +718,7 @@ class Bot {
|
|
|
718
718
|
this.On = true;
|
|
719
719
|
}
|
|
720
720
|
}
|
|
721
|
-
else if (this.
|
|
721
|
+
else if (this.botDeviceType === 'faucet') {
|
|
722
722
|
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set Active: ${value}`);
|
|
723
723
|
if (value === this.platform.Characteristic.Active.INACTIVE) {
|
|
724
724
|
this.On = false;
|
|
@@ -727,7 +727,7 @@ class Bot {
|
|
|
727
727
|
this.On = true;
|
|
728
728
|
}
|
|
729
729
|
}
|
|
730
|
-
else if (this.
|
|
730
|
+
else if (this.botDeviceType === 'stateful') {
|
|
731
731
|
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set ProgrammableSwitchOutputState: ${value}`);
|
|
732
732
|
if (value === 0) {
|
|
733
733
|
this.On = false;
|
|
@@ -753,7 +753,7 @@ class Bot {
|
|
|
753
753
|
*/
|
|
754
754
|
async updateHomeKitCharacteristics() {
|
|
755
755
|
// State
|
|
756
|
-
if (this.
|
|
756
|
+
if (this.botDeviceType === 'garagedoor') {
|
|
757
757
|
if (this.On === undefined) {
|
|
758
758
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
759
759
|
}
|
|
@@ -771,7 +771,7 @@ class Bot {
|
|
|
771
771
|
}
|
|
772
772
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Garage Door On: ${this.On}`);
|
|
773
773
|
}
|
|
774
|
-
else if (this.
|
|
774
|
+
else if (this.botDeviceType === 'door') {
|
|
775
775
|
if (this.On === undefined) {
|
|
776
776
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
777
777
|
}
|
|
@@ -791,7 +791,7 @@ class Bot {
|
|
|
791
791
|
}
|
|
792
792
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Door On: ${this.On}`);
|
|
793
793
|
}
|
|
794
|
-
else if (this.
|
|
794
|
+
else if (this.botDeviceType === 'window') {
|
|
795
795
|
if (this.On === undefined) {
|
|
796
796
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
797
797
|
}
|
|
@@ -811,7 +811,7 @@ class Bot {
|
|
|
811
811
|
}
|
|
812
812
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Window On: ${this.On}`);
|
|
813
813
|
}
|
|
814
|
-
else if (this.
|
|
814
|
+
else if (this.botDeviceType === 'windowcovering') {
|
|
815
815
|
if (this.On === undefined) {
|
|
816
816
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
817
817
|
}
|
|
@@ -831,7 +831,7 @@ class Bot {
|
|
|
831
831
|
}
|
|
832
832
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Window Covering On: ${this.On}`);
|
|
833
833
|
}
|
|
834
|
-
else if (this.
|
|
834
|
+
else if (this.botDeviceType === 'lock') {
|
|
835
835
|
if (this.On === undefined) {
|
|
836
836
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
837
837
|
}
|
|
@@ -850,7 +850,7 @@ class Bot {
|
|
|
850
850
|
}
|
|
851
851
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Lock On: ${this.On}`);
|
|
852
852
|
}
|
|
853
|
-
else if (this.
|
|
853
|
+
else if (this.botDeviceType === 'faucet') {
|
|
854
854
|
if (this.On === undefined) {
|
|
855
855
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
856
856
|
}
|
|
@@ -866,7 +866,7 @@ class Bot {
|
|
|
866
866
|
}
|
|
867
867
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Faucet On: ${this.On}`);
|
|
868
868
|
}
|
|
869
|
-
else if (this.
|
|
869
|
+
else if (this.botDeviceType === 'fan') {
|
|
870
870
|
if (this.On === undefined) {
|
|
871
871
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
872
872
|
}
|
|
@@ -882,7 +882,7 @@ class Bot {
|
|
|
882
882
|
}
|
|
883
883
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Fan On: ${this.On}`);
|
|
884
884
|
}
|
|
885
|
-
else if (this.
|
|
885
|
+
else if (this.botDeviceType === 'stateful') {
|
|
886
886
|
if (this.On === undefined) {
|
|
887
887
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
888
888
|
}
|
|
@@ -902,7 +902,7 @@ class Bot {
|
|
|
902
902
|
}
|
|
903
903
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} StatefulProgrammableSwitch On: ${this.On}`);
|
|
904
904
|
}
|
|
905
|
-
else if (this.
|
|
905
|
+
else if (this.botDeviceType === 'switch') {
|
|
906
906
|
if (this.On === undefined) {
|
|
907
907
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
908
908
|
}
|
|
@@ -1186,41 +1186,41 @@ class Bot {
|
|
|
1186
1186
|
}
|
|
1187
1187
|
}
|
|
1188
1188
|
async apiError(e) {
|
|
1189
|
-
if (this.
|
|
1189
|
+
if (this.botDeviceType === 'garagedoor') {
|
|
1190
1190
|
this.garageDoorService?.updateCharacteristic(this.platform.Characteristic.TargetDoorState, e);
|
|
1191
1191
|
this.garageDoorService?.updateCharacteristic(this.platform.Characteristic.CurrentDoorState, e);
|
|
1192
1192
|
this.garageDoorService?.updateCharacteristic(this.platform.Characteristic.ObstructionDetected, e);
|
|
1193
1193
|
}
|
|
1194
|
-
else if (this.
|
|
1194
|
+
else if (this.botDeviceType === 'door') {
|
|
1195
1195
|
this.doorService?.updateCharacteristic(this.platform.Characteristic.TargetPosition, e);
|
|
1196
1196
|
this.doorService?.updateCharacteristic(this.platform.Characteristic.CurrentPosition, e);
|
|
1197
1197
|
this.doorService?.updateCharacteristic(this.platform.Characteristic.PositionState, e);
|
|
1198
1198
|
}
|
|
1199
|
-
else if (this.
|
|
1199
|
+
else if (this.botDeviceType === 'window') {
|
|
1200
1200
|
this.windowService?.updateCharacteristic(this.platform.Characteristic.TargetPosition, e);
|
|
1201
1201
|
this.windowService?.updateCharacteristic(this.platform.Characteristic.CurrentPosition, e);
|
|
1202
1202
|
this.windowService?.updateCharacteristic(this.platform.Characteristic.PositionState, e);
|
|
1203
1203
|
}
|
|
1204
|
-
else if (this.
|
|
1204
|
+
else if (this.botDeviceType === 'windowcovering') {
|
|
1205
1205
|
this.windowCoveringService?.updateCharacteristic(this.platform.Characteristic.TargetPosition, e);
|
|
1206
1206
|
this.windowCoveringService?.updateCharacteristic(this.platform.Characteristic.CurrentPosition, e);
|
|
1207
1207
|
this.windowCoveringService?.updateCharacteristic(this.platform.Characteristic.PositionState, e);
|
|
1208
1208
|
}
|
|
1209
|
-
else if (this.
|
|
1209
|
+
else if (this.botDeviceType === 'lock') {
|
|
1210
1210
|
this.doorService?.updateCharacteristic(this.platform.Characteristic.LockTargetState, e);
|
|
1211
1211
|
this.doorService?.updateCharacteristic(this.platform.Characteristic.LockCurrentState, e);
|
|
1212
1212
|
}
|
|
1213
|
-
else if (this.
|
|
1213
|
+
else if (this.botDeviceType === 'faucet') {
|
|
1214
1214
|
this.faucetService?.updateCharacteristic(this.platform.Characteristic.Active, e);
|
|
1215
1215
|
}
|
|
1216
|
-
else if (this.
|
|
1216
|
+
else if (this.botDeviceType === 'fan') {
|
|
1217
1217
|
this.fanService?.updateCharacteristic(this.platform.Characteristic.On, e);
|
|
1218
1218
|
}
|
|
1219
|
-
else if (this.
|
|
1219
|
+
else if (this.botDeviceType === 'stateful') {
|
|
1220
1220
|
this.statefulProgrammableSwitchService?.updateCharacteristic(this.platform.Characteristic.ProgrammableSwitchEvent, e);
|
|
1221
1221
|
this.statefulProgrammableSwitchService?.updateCharacteristic(this.platform.Characteristic.ProgrammableSwitchOutputState, e);
|
|
1222
1222
|
}
|
|
1223
|
-
else if (this.
|
|
1223
|
+
else if (this.botDeviceType === 'switch') {
|
|
1224
1224
|
this.switchService?.updateCharacteristic(this.platform.Characteristic.On, e);
|
|
1225
1225
|
}
|
|
1226
1226
|
else {
|
|
@@ -1248,6 +1248,17 @@ class Bot {
|
|
|
1248
1248
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} setFirmwareRevision: ${this.FirmwareRevision}`);
|
|
1249
1249
|
return this.FirmwareRevision;
|
|
1250
1250
|
}
|
|
1251
|
+
async deviceType(device) {
|
|
1252
|
+
if (device.bot?.deviceType) {
|
|
1253
|
+
this.botDeviceType = this.accessory.context.deviceType = device.bot.deviceType;
|
|
1254
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Device Type: ${this.botDeviceType}`);
|
|
1255
|
+
}
|
|
1256
|
+
else {
|
|
1257
|
+
this.botDeviceType = 'outlet';
|
|
1258
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} No Device Type Set, deviceType: ${this.device.bot?.deviceType}`);
|
|
1259
|
+
this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Using default deviceType: ${this.botDeviceType}`);
|
|
1260
|
+
}
|
|
1261
|
+
}
|
|
1251
1262
|
async context() {
|
|
1252
1263
|
if (this.On === undefined) {
|
|
1253
1264
|
this.On = false;
|