Controlling the scheduler

Hello
I have a central heating system witch the controller send the user info (switch on /off set times etc.) over http. I can read this and interrater it using a c++ program but:

  1. Is there a way to set the scheduler from the c++?
  2. Is there a way to read the scheduler using the c++?
    Please can anyone help with programmatically controlling the scheduler?
    IanR

hello
Can any one help?
Will “(Scheduler.IsScheduling(“15 19 * * 1-7”)” work to program the scheduler or is it a separate system?
IanR

from testing the above code dose not work. Any ideas?
Ian R

Hi, @IanR.
What do you want to achieve? According to documentation Scheduler.IsScheduling(“15 19 * * 1-7”) will check if this very moment is 19:15 of any day of week.

Hello @Bounz.
I am trying to communicate with a central heating system it has its own web interface but I can use HG to communicate, in the same way as you communicate with a widget using http (eg like an arduino).
But I need to Read, Modify and Set the scheduler from this (from the c# program), so I can set, adjust and view the central heating times both on the contrail unit and on the schedule page. My understanding of “Scheduler.IsScheduling(“15 19 * * 1-7”)” may not be correct but,

  1. I don’t believe it sets the time in the schedule so it would not be visible on the schedule page.
  2. As did not think it set the time to schedule (on the schedule page) if the power was lost eg pc off then the schedule would be as well as it would be a dynamic variable.

so I am looking for some code to:
add the schedule item,
activate the schedule item,
de-activate the schedule item
update/modify the schedule item.

Thanks
IanR

Well, it seems that there is no API for that :slightly_frowning_face:
You can create scheduler item, but there is no way to bind modules to it.

The best you can do is to create scheduler item by hand, assign modules to it and script and then dynamically change its cron expression using SetSchedule() method (docs).
It will look like this

Scheduler.WithName("scheduleItemName").SetSchedule("15 19 * * *");

Also take a look at this post from the old forum.

@Bounz
Thanks that really did help but I am having problems with a time range. I am using:

Scheduler.WithName(“scheduleItemName”).SetSchedule((“15 19 * * *) >(18 10 * * *”));

It seams to be updating the corn info in the edit event but not the visual time line.

What am I don’t incorrect?
Thanks
IanR

Hm, just tried this on my own instance.
Created scheduling item with single occurrence at 19:54, then wrote program with one command:

Scheduler.WithName("testEvent1").SetSchedule("(15 19 * * *) > (18 10 * * *)");

After compiling and running the program visual appearance changes:

But in edit dialog I still see 19:54:

Looks like a bug in HG.

And on “Edit events” page it looks like following:
image

1 Like

Thank you for the help.
I have changed my code to match yours but I still don’t get the bar in the events display after the program has run. But like you It dose change the events Edit as you display. May be it is an error in HG.
IanR

What version of HG are you using. An update to the latest version https://github.com/genielabs/HomeGenie/releases/tag/v1.3-stable.5 might help if you haven’t already done so.

Hello
Currently using v1.3stable.4 so will have a look at updating.
Thank you
IanR

Hello
Tried updating to latest version v1.3stable.5 (on pi) but the same happens after programmatically changing the schedule times the schedule will not display as a bar.
IanR

Sounds like it might be a bug. Report it over on the HG GitHub.

Hello
I see there is a .get() in the helper (docs)
Could this be used to get the current corn job values out of a current scheduler.
eg
Variable = Scheduler.WithName(“scheduleItemName”).Get();

Any help would be appreciated as I am not understanding the docs well. without examples.
Thank you
IanR

To activate and deactivate the schedule item I use:

Net.WebService(“http://local_ip/api/HomeAutomation.HomeGenie/Automation/Scheduling.Enable/NAME_SCHEDULED_ITEM”).GetData();

Net.WebService(“http://local_ip/api/HomeAutomation.HomeGenie/Automation/Scheduling.Disable/NAME_SCHEDULED_ITEM”).GetData();

1 Like

@roberto1979
Thank you.
Is there a way to get out of the schedule the set times / date (even if its is in corn) of a scheduled item?
IanR

Yes,
List data for Singol Item:
Net.WebService(“local_ip/api/HomeAutomation.HomeGenie/Automation/Scheduling.Get/NAME_SCHEDULED_ITEM”).GetData();

Entire scheduled Items:
Net.WebService(“local_ip/api/HomeAutomation.HomeGenie/Automation/Scheduling.List/”).GetData();

1 Like

Thank you so much.
I can start building my web interface to my contrail heating system now.
Just in time for winter.

Ian R

Hello @roberto1979
I spoke too soon.
1)The output seams to be a JSON file is this correct?
2) I am having problems opening it, how do you open it I am trying to get the name and Corn info out.
I can display it in a browser ok but not in code.
Thank you
IanR

Hello
Found a good working example for JSON here:
YouLess

IanR