@switchbot/homebridge-switchbot 5.0.0-beta.128 → 5.0.0-beta.129
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/config.schema.json +11 -0
- package/dist/devices/genericDevice.d.ts.map +1 -1
- package/dist/devices/genericDevice.js +55 -10
- package/dist/devices/genericDevice.js.map +1 -1
- package/dist/homebridge-ui/endpoints/discovery.d.ts.map +1 -1
- package/dist/homebridge-ui/endpoints/discovery.js +10 -1
- package/dist/homebridge-ui/endpoints/discovery.js.map +1 -1
- package/dist/homebridge-ui/public/js/api.d.ts +4 -1
- package/dist/homebridge-ui/public/js/api.d.ts.map +1 -1
- package/dist/homebridge-ui/public/js/api.js +7 -1
- package/dist/homebridge-ui/public/js/api.js.map +1 -1
- package/dist/homebridge-ui/public/js/api.ts +8 -1
- package/dist/homebridge-ui/public/js/app.js +149 -24
- package/dist/homebridge-ui/public/js/app.js.map +2 -2
- package/dist/homebridge-ui/public/js/devices.d.ts.map +1 -1
- package/dist/homebridge-ui/public/js/devices.js +1 -0
- package/dist/homebridge-ui/public/js/devices.js.map +1 -1
- package/dist/homebridge-ui/public/js/devices.ts +5 -2
- package/dist/homebridge-ui/public/js/modals.d.ts.map +1 -1
- package/dist/homebridge-ui/public/js/modals.js +149 -20
- package/dist/homebridge-ui/public/js/modals.js.map +1 -1
- package/dist/homebridge-ui/public/js/modals.ts +156 -26
- package/docs/variables/default.html +1 -1
- package/package.json +1 -1
- package/src/devices/genericDevice.ts +64 -10
- package/src/homebridge-ui/endpoints/discovery.ts +9 -1
- package/src/homebridge-ui/public/js/api.ts +8 -1
- package/src/homebridge-ui/public/js/devices.ts +5 -2
- package/src/homebridge-ui/public/js/modals.ts +156 -26
|
@@ -443,6 +443,9 @@ async function addDevice(deviceId, name, type, options) {
|
|
|
443
443
|
if (options?.keyId) {
|
|
444
444
|
payload.keyId = options.keyId;
|
|
445
445
|
}
|
|
446
|
+
if (options?.matterType !== void 0) {
|
|
447
|
+
payload.matterType = options.matterType;
|
|
448
|
+
}
|
|
446
449
|
uiLog.info("Adding device to config:", payload);
|
|
447
450
|
const resp = await homebridge.request("/add-device", payload);
|
|
448
451
|
uiLog.info("Add device response:", resp);
|
|
@@ -459,7 +462,7 @@ async function addDevicesInBulk(devices) {
|
|
|
459
462
|
}
|
|
460
463
|
return resp.data || resp;
|
|
461
464
|
}
|
|
462
|
-
async function updateDevice(deviceId, configDeviceName, configDeviceType) {
|
|
465
|
+
async function updateDevice(deviceId, configDeviceName, configDeviceType, options) {
|
|
463
466
|
const params = { deviceId };
|
|
464
467
|
if (configDeviceName) {
|
|
465
468
|
params.configDeviceName = configDeviceName;
|
|
@@ -467,6 +470,9 @@ async function updateDevice(deviceId, configDeviceName, configDeviceType) {
|
|
|
467
470
|
if (configDeviceType) {
|
|
468
471
|
params.configDeviceType = configDeviceType;
|
|
469
472
|
}
|
|
473
|
+
if (options?.matterType !== void 0) {
|
|
474
|
+
params.matterType = options.matterType;
|
|
475
|
+
}
|
|
470
476
|
uiLog.info("[Update Device] Sending update request with params:", params);
|
|
471
477
|
const resp = await homebridge.request("/update-device", params);
|
|
472
478
|
uiLog.info("[Update Device] Update response:", resp);
|
|
@@ -1919,6 +1925,56 @@ async function importDiscoveredDevice(device) {
|
|
|
1919
1925
|
});
|
|
1920
1926
|
typeSelect.appendChild(optgroup);
|
|
1921
1927
|
});
|
|
1928
|
+
const windowCoveringTypes = ["Roller Shade", "Curtain", "Curtain3", "Blind Tilt"];
|
|
1929
|
+
const matterTypeLabel = document.createElement("label");
|
|
1930
|
+
matterTypeLabel.textContent = "Matter Window Covering Type (Advanced)";
|
|
1931
|
+
matterTypeLabel.style.display = "block";
|
|
1932
|
+
matterTypeLabel.style.marginBottom = "6px";
|
|
1933
|
+
matterTypeLabel.style.fontWeight = "500";
|
|
1934
|
+
matterTypeLabel.style.fontSize = "12px";
|
|
1935
|
+
matterTypeLabel.style.color = "#6b7280";
|
|
1936
|
+
matterTypeLabel.style.marginTop = "2px";
|
|
1937
|
+
const matterTypes = [
|
|
1938
|
+
{ value: "", label: "Auto-detect (recommended)" },
|
|
1939
|
+
{ value: 0, label: "Roller Shade (0)" },
|
|
1940
|
+
{ value: 1, label: "Roman Shade (1)" },
|
|
1941
|
+
{ value: 2, label: "Balloon Shade (2)" },
|
|
1942
|
+
{ value: 3, label: "Woven Wood (3)" },
|
|
1943
|
+
{ value: 4, label: "Drapery (4)" },
|
|
1944
|
+
{ value: 5, label: "Awning (5)" },
|
|
1945
|
+
{ value: 6, label: "Shutter (6)" },
|
|
1946
|
+
{ value: 7, label: "Tilt Blind (7)" },
|
|
1947
|
+
{ value: 8, label: "Blind Tilt (8)" },
|
|
1948
|
+
{ value: 9, label: "Projector Screen (9)" },
|
|
1949
|
+
{ value: 15, label: "Other (15)" }
|
|
1950
|
+
];
|
|
1951
|
+
const matterTypeSelect = document.createElement("select");
|
|
1952
|
+
matterTypeSelect.style.width = "100%";
|
|
1953
|
+
matterTypeSelect.style.marginBottom = "12px";
|
|
1954
|
+
matterTypeSelect.style.padding = "8px 10px";
|
|
1955
|
+
matterTypeSelect.style.borderRadius = "6px";
|
|
1956
|
+
matterTypeSelect.style.fontSize = "14px";
|
|
1957
|
+
matterTypeSelect.style.boxSizing = "border-box";
|
|
1958
|
+
matterTypes.forEach((opt) => {
|
|
1959
|
+
const option = document.createElement("option");
|
|
1960
|
+
option.value = String(opt.value);
|
|
1961
|
+
option.textContent = opt.label;
|
|
1962
|
+
if (device.matterType != null && String(opt.value) === String(device.matterType)) {
|
|
1963
|
+
option.selected = true;
|
|
1964
|
+
}
|
|
1965
|
+
matterTypeSelect.appendChild(option);
|
|
1966
|
+
});
|
|
1967
|
+
function updateMatterTypeVisibility() {
|
|
1968
|
+
if (windowCoveringTypes.includes(typeSelect.value)) {
|
|
1969
|
+
matterTypeLabel.style.display = "block";
|
|
1970
|
+
matterTypeSelect.style.display = "block";
|
|
1971
|
+
} else {
|
|
1972
|
+
matterTypeLabel.style.display = "none";
|
|
1973
|
+
matterTypeSelect.style.display = "none";
|
|
1974
|
+
}
|
|
1975
|
+
}
|
|
1976
|
+
typeSelect.addEventListener("change", updateMatterTypeVisibility);
|
|
1977
|
+
updateMatterTypeVisibility();
|
|
1922
1978
|
const macLabel = document.createElement("label");
|
|
1923
1979
|
macLabel.textContent = "BLE MAC Address (optional)";
|
|
1924
1980
|
macLabel.style.display = "block";
|
|
@@ -1998,7 +2054,8 @@ async function importDiscoveredDevice(device) {
|
|
|
1998
2054
|
configDeviceType: typeSelect.value || device.type,
|
|
1999
2055
|
address: macInput.value || void 0,
|
|
2000
2056
|
encryptionKey: encryptionKeyInput.value || void 0,
|
|
2001
|
-
keyId: keyIdInput.value || void 0
|
|
2057
|
+
keyId: keyIdInput.value || void 0,
|
|
2058
|
+
...windowCoveringTypes.includes(typeSelect.value) && matterTypeSelect.value !== "" ? { matterType: Number(matterTypeSelect.value) } : {}
|
|
2002
2059
|
});
|
|
2003
2060
|
div.addEventListener("click", (event) => {
|
|
2004
2061
|
if (event.target === div) {
|
|
@@ -2011,6 +2068,8 @@ async function importDiscoveredDevice(device) {
|
|
|
2011
2068
|
contentDiv.appendChild(nameInput);
|
|
2012
2069
|
contentDiv.appendChild(typeLabel);
|
|
2013
2070
|
contentDiv.appendChild(typeSelect);
|
|
2071
|
+
contentDiv.appendChild(matterTypeLabel);
|
|
2072
|
+
contentDiv.appendChild(matterTypeSelect);
|
|
2014
2073
|
contentDiv.appendChild(macLabel);
|
|
2015
2074
|
contentDiv.appendChild(macInput);
|
|
2016
2075
|
contentDiv.appendChild(encryptionKeyLabel);
|
|
@@ -2026,6 +2085,87 @@ async function importDiscoveredDevice(device) {
|
|
|
2026
2085
|
});
|
|
2027
2086
|
}
|
|
2028
2087
|
async function editDevice(device) {
|
|
2088
|
+
const typeLabel = document.createElement("label");
|
|
2089
|
+
typeLabel.textContent = "Config Device Type";
|
|
2090
|
+
typeLabel.style.display = "block";
|
|
2091
|
+
typeLabel.style.marginBottom = "6px";
|
|
2092
|
+
typeLabel.style.fontWeight = "500";
|
|
2093
|
+
typeLabel.style.fontSize = "12px";
|
|
2094
|
+
typeLabel.style.color = "#6b7280";
|
|
2095
|
+
const typeSelect = document.createElement("select");
|
|
2096
|
+
typeSelect.style.width = "100%";
|
|
2097
|
+
typeSelect.style.padding = "8px 10px";
|
|
2098
|
+
typeSelect.style.marginBottom = "12px";
|
|
2099
|
+
typeSelect.style.borderRadius = "6px";
|
|
2100
|
+
typeSelect.style.fontSize = "14px";
|
|
2101
|
+
typeSelect.style.background = getComputedStyle(document.body).backgroundColor;
|
|
2102
|
+
typeSelect.style.color = getComputedStyle(document.body).color;
|
|
2103
|
+
typeSelect.style.border = "1px solid #ccc";
|
|
2104
|
+
typeSelect.style.boxSizing = "border-box";
|
|
2105
|
+
Object.keys(DEVICE_TYPES).forEach((categoryName) => {
|
|
2106
|
+
const optgroup = document.createElement("optgroup");
|
|
2107
|
+
optgroup.label = categoryName;
|
|
2108
|
+
DEVICE_TYPES[categoryName].forEach((deviceType) => {
|
|
2109
|
+
const opt = document.createElement("option");
|
|
2110
|
+
opt.value = deviceType;
|
|
2111
|
+
opt.text = deviceType;
|
|
2112
|
+
const currentType = device.configDeviceType || device.deviceType || device.type || "";
|
|
2113
|
+
opt.selected = currentType === deviceType;
|
|
2114
|
+
optgroup.appendChild(opt);
|
|
2115
|
+
});
|
|
2116
|
+
typeSelect.appendChild(optgroup);
|
|
2117
|
+
});
|
|
2118
|
+
const windowCoveringTypes = ["Roller Shade", "Curtain", "Curtain3", "Blind Tilt"];
|
|
2119
|
+
const showMatterType = windowCoveringTypes.includes(device.configDeviceType || device.deviceType || device.type || "");
|
|
2120
|
+
const matterTypeLabel = document.createElement("label");
|
|
2121
|
+
matterTypeLabel.textContent = "Matter Window Covering Type (Advanced)";
|
|
2122
|
+
matterTypeLabel.style.display = showMatterType ? "block" : "none";
|
|
2123
|
+
matterTypeLabel.style.marginBottom = "6px";
|
|
2124
|
+
matterTypeLabel.style.fontWeight = "500";
|
|
2125
|
+
matterTypeLabel.style.fontSize = "12px";
|
|
2126
|
+
matterTypeLabel.style.color = "#6b7280";
|
|
2127
|
+
matterTypeLabel.style.marginTop = "2px";
|
|
2128
|
+
const matterTypes = [
|
|
2129
|
+
{ value: "", label: "Auto-detect (recommended)" },
|
|
2130
|
+
{ value: 0, label: "Roller Shade (0)" },
|
|
2131
|
+
{ value: 1, label: "Roman Shade (1)" },
|
|
2132
|
+
{ value: 2, label: "Balloon Shade (2)" },
|
|
2133
|
+
{ value: 3, label: "Woven Wood (3)" },
|
|
2134
|
+
{ value: 4, label: "Drapery (4)" },
|
|
2135
|
+
{ value: 5, label: "Awning (5)" },
|
|
2136
|
+
{ value: 6, label: "Shutter (6)" },
|
|
2137
|
+
{ value: 7, label: "Tilt Blind (7)" },
|
|
2138
|
+
{ value: 8, label: "Blind Tilt (8)" },
|
|
2139
|
+
{ value: 9, label: "Projector Screen (9)" },
|
|
2140
|
+
{ value: 15, label: "Other (15)" }
|
|
2141
|
+
];
|
|
2142
|
+
const matterTypeSelect = document.createElement("select");
|
|
2143
|
+
matterTypeSelect.style.width = "100%";
|
|
2144
|
+
matterTypeSelect.style.marginBottom = "12px";
|
|
2145
|
+
matterTypeSelect.style.padding = "8px 10px";
|
|
2146
|
+
matterTypeSelect.style.borderRadius = "6px";
|
|
2147
|
+
matterTypeSelect.style.fontSize = "14px";
|
|
2148
|
+
matterTypeSelect.style.boxSizing = "border-box";
|
|
2149
|
+
matterTypes.forEach((opt) => {
|
|
2150
|
+
const option = document.createElement("option");
|
|
2151
|
+
option.value = String(opt.value);
|
|
2152
|
+
option.textContent = opt.label;
|
|
2153
|
+
if (device.matterType != null && String(opt.value) === String(device.matterType)) {
|
|
2154
|
+
option.selected = true;
|
|
2155
|
+
}
|
|
2156
|
+
matterTypeSelect.appendChild(option);
|
|
2157
|
+
});
|
|
2158
|
+
function updateMatterTypeVisibility() {
|
|
2159
|
+
if (windowCoveringTypes.includes(typeSelect.value)) {
|
|
2160
|
+
matterTypeLabel.style.display = "block";
|
|
2161
|
+
matterTypeSelect.style.display = "block";
|
|
2162
|
+
} else {
|
|
2163
|
+
matterTypeLabel.style.display = "none";
|
|
2164
|
+
matterTypeSelect.style.display = "none";
|
|
2165
|
+
}
|
|
2166
|
+
}
|
|
2167
|
+
typeSelect.addEventListener("change", updateMatterTypeVisibility);
|
|
2168
|
+
updateMatterTypeVisibility();
|
|
2029
2169
|
const div = document.createElement("div");
|
|
2030
2170
|
div.style.position = "fixed";
|
|
2031
2171
|
div.style.top = "0";
|
|
@@ -2095,25 +2235,6 @@ async function editDevice(device) {
|
|
|
2095
2235
|
apiTypeInput.style.cursor = "not-allowed";
|
|
2096
2236
|
apiTypeInput.style.boxSizing = "border-box";
|
|
2097
2237
|
apiTypeInput.style.backgroundColor = "#f9fafb";
|
|
2098
|
-
const typeLabel = document.createElement("label");
|
|
2099
|
-
typeLabel.textContent = "Config Device Type (Override)";
|
|
2100
|
-
typeLabel.style.display = "block";
|
|
2101
|
-
typeLabel.style.marginBottom = "6px";
|
|
2102
|
-
typeLabel.style.fontWeight = "500";
|
|
2103
|
-
typeLabel.style.fontSize = "12px";
|
|
2104
|
-
typeLabel.style.color = "#6b7280";
|
|
2105
|
-
const typeSelect = document.createElement("select");
|
|
2106
|
-
typeSelect.style.width = "100%";
|
|
2107
|
-
typeSelect.style.padding = "8px 10px";
|
|
2108
|
-
typeSelect.style.marginBottom = "12px";
|
|
2109
|
-
typeSelect.style.borderRadius = "6px";
|
|
2110
|
-
typeSelect.style.fontSize = "14px";
|
|
2111
|
-
typeSelect.style.background = getComputedStyle(nameInput).background;
|
|
2112
|
-
typeSelect.style.color = getComputedStyle(nameInput).color;
|
|
2113
|
-
typeSelect.style.border = getComputedStyle(nameInput).border;
|
|
2114
|
-
typeSelect.style.boxSizing = "border-box";
|
|
2115
|
-
typeSelect.style.cursor = "pointer";
|
|
2116
|
-
typeSelect.style.transition = "border-color 0.2s ease";
|
|
2117
2238
|
Object.keys(DEVICE_TYPES).forEach((categoryName) => {
|
|
2118
2239
|
const optgroup = document.createElement("optgroup");
|
|
2119
2240
|
optgroup.label = categoryName;
|
|
@@ -2162,9 +2283,10 @@ async function editDevice(device) {
|
|
|
2162
2283
|
const params = {
|
|
2163
2284
|
deviceId: device.id,
|
|
2164
2285
|
configDeviceName: nameInput.value || void 0,
|
|
2165
|
-
configDeviceType: typeSelect.value
|
|
2286
|
+
configDeviceType: typeSelect.value,
|
|
2287
|
+
matterType: windowCoveringTypes.includes(typeSelect.value) && matterTypeSelect.value !== "" ? Number(matterTypeSelect.value) : void 0
|
|
2166
2288
|
};
|
|
2167
|
-
await updateDevice2(params.deviceId, params.configDeviceName, params.configDeviceType);
|
|
2289
|
+
await updateDevice2(params.deviceId, params.configDeviceName, params.configDeviceType, { matterType: params.matterType });
|
|
2168
2290
|
await syncParentPluginConfigFromDisk2();
|
|
2169
2291
|
uiLog.info("[Edit Device] Refreshing device list after update");
|
|
2170
2292
|
const list = await fetchDevices2();
|
|
@@ -2184,6 +2306,8 @@ async function editDevice(device) {
|
|
|
2184
2306
|
contentDiv.appendChild(apiTypeInput);
|
|
2185
2307
|
contentDiv.appendChild(typeLabel);
|
|
2186
2308
|
contentDiv.appendChild(typeSelect);
|
|
2309
|
+
contentDiv.appendChild(matterTypeLabel);
|
|
2310
|
+
contentDiv.appendChild(matterTypeSelect);
|
|
2187
2311
|
contentDiv.appendChild(errorMessage);
|
|
2188
2312
|
contentDiv.appendChild(buttons);
|
|
2189
2313
|
modal.appendChild(title);
|
|
@@ -3294,7 +3418,8 @@ async function addDeviceToConfig2(device, options = {}) {
|
|
|
3294
3418
|
model: device.model,
|
|
3295
3419
|
rssi: device.rssi,
|
|
3296
3420
|
encryptionKey: importValues.encryptionKey,
|
|
3297
|
-
keyId: importValues.keyId
|
|
3421
|
+
keyId: importValues.keyId,
|
|
3422
|
+
matterType: importValues.matterType
|
|
3298
3423
|
});
|
|
3299
3424
|
uiLog.info("Add device response:", resp);
|
|
3300
3425
|
if (!resp || resp.success === false) {
|