🔌 ${device.name} (${deviceZone.name}): ${newState.on ? 'On' : 'Off'}
`); - device.setCapabilityValue('onoff', newState.on) - .catch(err => console.error(err)); + if (delay) { + logMessage(`⏳ ${device.name} (${deviceZone.name}): ${newState.on ? 'On' : 'Off'} in ${delay} seconds
`); + } else { + logMessage(`⏩ ${device.name} (${deviceZone.name}): ${newState.on ? 'On' : 'Off'}
`); + } + + setTimeout(() => { + device.setCapabilityValue('onoff', newState.on) + .catch(err => console.error(err)); + }, delay * 1000); } if (newState.brightness !== undefined) { - logMessage(`💡 ${device.name} (${deviceZone.name}): ${newState.brightness}%
`); - device.setCapabilityValue('dim', newState.brightness / 100) - .catch(err => console.error(err)); + if (delay) { + logMessage(`⏳ ${device.name} (${deviceZone.name}): ${newState.brightness}% in ${delay} seconds
`); + } else { + logMessage(`⏩ ${device.name} (${deviceZone.name}): ${newState.brightness}%
`); + } + + setTimeout(() => { + device.setCapabilityValue('dim', newState.brightness / 100) + .catch(err => console.error(err)); + }, delay * 1000); } } }