How to return Cloud Scheduler properties, such as Hour or Minute as Int, other than isActive() as bool?

if Scheduler.isActive() returns true or false, where is the documentation on arduino or github does it show to return, for example, the Hour is becomes active as an Int, so that it can be used as variable for display?

Moreover, are there are tips on printing updated scheduler properties in onSchedulerChange()? It would be good to debug in serial the new properties of the scheduler once updated.

Other properties of the scheduler that would be useful are:

  • Starting time
  • duration of scheduler active period

Cheers

Hi @darrellchan,
as of now isActive() is the only custom public method available for the scheduler property. To be able to print the internal values of your schedule you can do something like this:

Assuming mySchedule is your property declared in thingProperties.h file
Schedule localSchedule = mySchedule.getValue();

the Schedule object has 4 fields:
frm: unix timestamp of the start date
to: unix timestamp of the end date
len: length of the schedule in seconds
msk: bitfield containing schedule type, repetition interval or masks

At this point you can use TimeLib to process frm and to fields

Serial.print("mySchedule starts: ");
Serial.print(hour(localSchedule.frm));
Serial.print(":");
Serial.print(minute(localSchedule.frm));
Serial.print(":");
Serial.print(second(localSchedule.frm));
Serial.println("");

Is there any other internal value you are interested to get? I think the more obscure part is the msk bitfield so maybe we can think to add some helper funciotn to get alsothe scheduler type (OneShot, FixedDelta, Weekly) and the Interval/Mask if needed.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.