//https://roomos.cisco.com/doc/TechDocs/MacroTutorial#scheduling import xapi from "xapi"; var On = "On"; xapi.Config.Macros.AutoStart .set(On); function schedule(time, action) { let [alarmH, alarmM] = time.split(':'); let now = new Date(); now = now.getHours() * 3600 + now.getMinutes() * 60 + now.getSeconds(); let difference = parseInt(alarmH) * 3600 + parseInt(alarmM) * 60 - now; if (difference <= 0) difference += 24 * 3600; return setTimeout(action, difference * 1000); } //https://github.com/CiscoDevNet/roomdevices-macros-samples/blob/master/Library%20-%20Send%20Webex%20Message/README.md const webexMsgUrl = "https://webexapis.com/v1/messages"; function sendMessage(token, toPersonEmail, roomId, markdown) { const headers = [ "Content-Type: application/json", "Authorization: Bearer " + token, ]; const body = Object.assign({ markdown }, toPersonEmail ? { toPersonEmail } : { roomId }); return xapi.Command.HttpClient.Post({ Header: headers, Url: webexMsgUrl }, JSON.stringify(body)); } const token = //yourToken; const Friday = 5; const afterReboot = '21:05'; function notifyReboot() { const weekDay = new Date().getDay(); if (weekDay == Friday) { sendMessage(token, "matteo.battista@eventitelematici.com", null, "[Cisco] OK2 | Scheduled-Reboot"); schedule(afterReboot, notifyReboot); } } schedule(afterReboot, notifyReboot);