Hi,
I have a simple function (that another fellow helped put together) that disables a number of schedules on a Shelly mini G3. The function itself is saved on the Shelly.
function switchSchedules(value) {
let schedules = [2, 5, 8]; // <-- example: change only the 1st, 3rd, 6th and 7th schedule
Shelly.call("Schedule.List", {}, function (result) {
for (let job of result.jobs) {
if (schedules.indexOf(job.id) !== -1) {
job.enable = value;
Shelly.call("Schedule.Update", job);
}
}
});
}
I know the IDs of the schedules using
which gets you the Schedule IDs. I can only get 4 due to limitations of js on the Shelly, apparently, but 3 is OK for me.
Using a browser, I can manually call the function using ONE of these, which either disable (false) or (true). At the moment I am not using authentication (that’s a separate issue, but if it can be fixed quickly here I would be grateful).
'http://192.168.47.127/rpc/Script.Eval?id=3&code=switchSchedules(false)'
'http://192.168.47.127/rpc/Script.Eval?id=3&code=switchSchedules(true)'
I get the SCRIPT ID (id=3) from the shelly script console, with the “Script only” logs checkbox off.
So, what I am trying to do is write a Rest Command in HA, which I can then add to automation (one ofr each of enable, disable). So far I have put this together (below), but (i) I am not sure how I can run it to test it and (b) whether the parts after the first part of the URL (e.g. id?, code?) should be passed to the URL as paramters (and how to do that) please?
‘http://192.168.47.127/rpc/Script.Eval’
id=3
code=switchSchedules(false)
# Rest Entry by KM
rest_command:
method: post
headers:
username: admin
password: password
disable_autoch_schedule:
url: "http://192.168.47.127/rpc/Script.Eval?id=3&code=switchSchedules(false)"
enable_autoch_schedule:
url: "http://192.168.47.127/rpc/Script.Eval?id=3&code=switchSchedules(true)"