Schedule to run script

  • Hello,

    It would be nice to have the ability to run a script on a schedule. Right now from the UI we can only control the output.

    I have a use case that needs to run a script on specific times of a day. Particularly the device needs to control some bells in a production facility for shift start, shift end, lunch break start and lunch break end. All those have different timings and number of "rings". So the best solution would be to enable the end user to control which script will run on different scheduled times.

  • There is already a feature for this.

    https://shelly-api-docs.shelly.cloud/gen2/Component…rvices/Schedule

    This can start a script;

    https://shelly-api-docs.shelly.cloud/gen2/Component…ipt#scriptstart

    And this can stop a script;

    https://shelly-api-docs.shelly.cloud/gen2/Component…ript#scriptstop

    To create Schedule jobs, all you have to do is to put the Schedule Create method with your start/stop calls as a parameter into a Shelly.call();

    https://shelly-api-docs.shelly.cloud/gen2/0.14/Scri…ures#shellycall

    And you can get your script ids with this script line.

    print('Your Script ID is: ',Shelly.getCurrentScriptId());

    Here is an Exampel how to create a Schedule job inside a Script:

    Just remember that you also need to delete them by scripting or using the Schedule option inside your Shelly webinterface.

    Der Inhalt kann nicht angezeigt werden, da Sie keine Berechtigung haben, diesen Inhalt zu sehen.

    Der Inhalt kann nicht angezeigt werden, da Sie keine Berechtigung haben, diesen Inhalt zu sehen.

    6 Mal editiert, zuletzt von _[Deleted]_ (16. Oktober 2023 um 22:18)

  • Yes and No, the scheduled job can be edited or deleted through the UI once you have created it by executing a script at least once.

    But it is important to run your job creation script only once and not set it to auto-start to avoid creating a new scheduled job with each start.

    Also to create a stop Script job, change the method in my example script to 'Script.Stop'. Additionally, ensure you enter the correct Script ID into the example Script.

    To obtain the correct ID, execute the above referenced code line within your target script.

    This line here:

    print('Your Script ID is: ',Shelly.getCurrentScriptId());

    6 Mal editiert, zuletzt von _[Deleted]_ (19. Oktober 2023 um 22:53)

  • Thats the problem, I dont want the user to call me to add the schedule if he/she accidentally deletes it. It would much better if we could have the ability to choose the script from a dropdown in the schedule UI

  • Dieses Thema enthält 16 weitere Beiträge, die nur für registrierte Benutzer sichtbar sind.