cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
423
Views
0
Helpful
1
Replies

CE9 Schedule Macro to run at frequency set

asri.zainal
Level 1
Level 1

I'm trying to get a macro to run on a schedule every 30mins(for example) but couldn't figure out how to do it.

I saw an example: https://github.com/CiscoDevNet/roomdevices-macros-samples/blob/master/Scheduler/Scheduler.js

I can see that this will perform the action everyday, is it possible to modify this to meet our requirement?

 

I thought it was as easy as modifying this line:

if (difference <= 0) difference += 24 * 3600;

to

// 30minutes schedule
if (difference <= 0) difference += 30 * 60;

EDIT: so I see my approach using above example is overkill and could have achieve using setInterval?

 

Maybe i'll provide more details what i'm trying to achieve here.

I have a macro setup on the room kits in our office that will send a webhook when it detects an active call.

The webhook will then do a meeting room booking request to book the room for duration of 1 hour.

The only issue with this is, it only runs it one time for that particular call and if the call were to be extended longer than 1 hour, it will not trigger the webhook.

 

What I would like to achieve is to set macro to run every 30minutes to check if call is active, if yes send the webhook, if not do nothing.

 

Below is a portion of my code:

const Sunday = 0, Saturday = 6;
const ScheduleFrequency = '1'; // Set this to the time frequency you want to have the device do something(in minutes)

function checkPeoplePresence(peoplePresence) { if (peoplePresence == "Yes"){ systemInfo.peoplePresence = peoplePresence; if (systemInfo.inCall >= 1) { sendMonitoringUpdatePost(); } else { xapi.status.get('SystemUnit State NumberOfActiveCalls') .then(checkInCall) .catch(console.error); } } } function checkInCall(calls) { if (calls >= 1) { systemInfo.inCall = calls; if (systemInfo.peoplePresence == "Yes") { sendMonitoringUpdatePost(); } else { xapi.status.get('RoomAnalytics PeoplePresence') .then(checkPeoplePresence) .catch(console.error); } } } function repeatSchedule() { const weekDay = new Date().getDay(); if (weekDay !== Sunday && weekDay !== Saturday) { xapi.status.on('SystemUnit State NumberOfActiveCalls', checkInCall); } } repeatSchedule(); setInterval(repeatSchedule, ScheduleFrequency*60*1000);

For above, I have set the frequency to be 1 minute.

- so when i make a call, it sends the first webhook

- i remained on call for 2 minutes, but it didn't send the 2nd webook which i hope it should have done.

1 Reply 1

I know it's an old post and that you might have been able to solve this already, but if not this might be of help to you. https://github.com/CiscoDevNet/roomdevices-macros-samples/tree/master/Automatic%20Room%20Booking

Not exactly what you outlined, but might anyway serve the purpose that you want to achieve.



Response Signature