Rest Command Syntax for calling a Schedule Disable Function (script) on a Shelly Mini Gen3?

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

http://192.168.47.127/rpc/Schedule.List

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)"

High-level course of action:

  1. Be sure to check the doc. Your YAML (as in this post) is not properly aligned, nor is it valid (“disable…” and “enable…” are invalid) : RESTful Command - Home Assistant
  2. If it worked in a browser, the method should be “GET”
  3. Use a parameter for false/true (again, see doc)
  4. Create a template switch that will call your action with the appropriate parameter

Thank you for the note.

YAML shows a green tick, so I do not believe that is an issue.
The disable and enable designations are just titles; they are recognised as such in teh automations menu when I tru to add these commands; so I do not believe that is an issue.

OK, thank you.

TBH, the docs are quite confusing and even the examples are more high level than I can fathom.

Look, I have not just come here having done nothing to see if I could make it work, I am genuinely asking for help, after some attempts. HA is so powerful, but so complex, that it seems to have got to a point that an ordinary user can’t get close to making it workable.

I am sure there will be others who would benefit from my example setup and a solution, if one was able to be found after a reasonable amount of trial and error.