bugfix for rule fetch, feat: device info and trying to fix dimmer
Build Images and Deploy / Update-PROD-Stack (push) Successful in 18s
Build Images and Deploy / Update-PROD-Stack (push) Successful in 18s
This commit is contained in:
@@ -154,17 +154,23 @@ async function setBrightness(host, port, brightness) {
|
||||
// Brightness should be 0-100
|
||||
const level = Math.max(0, Math.min(100, Math.round(brightness)));
|
||||
|
||||
console.log(`[DWM] Setting brightness for ${host}:${port} to ${level}%`);
|
||||
|
||||
if (level === 0) {
|
||||
// Turn off the device
|
||||
console.log(`[DWM] Brightness 0, turning device off`);
|
||||
await setBinaryState(host, port, false);
|
||||
} else {
|
||||
// For dimmers, use the brightness format: "brightness|0"
|
||||
// For non-dimmers, just turn on
|
||||
try {
|
||||
console.log(`[DWM] Trying dimmer brightness format: ${level}|0`);
|
||||
await soapWithFallback(host, port, BE_URL, BE_SVC, 'SetBinaryState', {
|
||||
BinaryState: `${level}|0`
|
||||
});
|
||||
console.log(`[DWM] Dimmer brightness set successfully`);
|
||||
} catch (err) {
|
||||
console.log(`[DWM] Dimmer format failed: ${err.message}, falling back to on/off`);
|
||||
// Fallback for non-dimmer devices - just turn on
|
||||
await setBinaryState(host, port, true);
|
||||
}
|
||||
@@ -174,16 +180,30 @@ async function setBrightness(host, port, brightness) {
|
||||
function isDimmerDevice(deviceInfo) {
|
||||
if (!deviceInfo) return false;
|
||||
|
||||
const { productModel, modelDescription, udn } = deviceInfo;
|
||||
const { productModel, modelDescription, udn, deviceType } = deviceInfo;
|
||||
|
||||
console.log(`[DWM] Checking if device is dimmer:`, {
|
||||
productModel,
|
||||
modelDescription,
|
||||
udn,
|
||||
deviceType
|
||||
});
|
||||
|
||||
// Check various indicators that this is a dimmer
|
||||
return (
|
||||
const isDimmer = (
|
||||
(productModel && productModel.toLowerCase().includes('dimmer')) ||
|
||||
(modelDescription && modelDescription.toLowerCase().includes('dimmer')) ||
|
||||
(udn && udn.toLowerCase().includes('dimmer')) ||
|
||||
(deviceType && deviceType.toLowerCase().includes('dimmer')) ||
|
||||
(productModel && productModel.includes('WDS060')) ||
|
||||
(modelDescription && modelDescription.includes('Dimmer'))
|
||||
(modelDescription && modelDescription.includes('Dimmer')) ||
|
||||
(udn && udn.includes('Dimmer-1_0')) ||
|
||||
(productModel && productModel.includes('WDS')) ||
|
||||
(modelDescription && modelDescription.toLowerCase().includes('light') && modelDescription.toLowerCase().includes('dim'))
|
||||
);
|
||||
|
||||
console.log(`[DWM] Dimmer detection result: ${isDimmer}`);
|
||||
return isDimmer;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user