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.

    Schedule | Shelly Technical Documentation
    This service allows execution of RPC methods at defined instances in time, using Mongoose's cron library. Basic CRUD interface is exposed for manipulating…
    shelly-api-docs.shelly.cloud

    This can start a script;

    Script | Shelly Technical Documentation
    Since version 0.9.0
    shelly-api-docs.shelly.cloud

    And this can stop a script;

    Script | Shelly Technical Documentation
    Since version 0.9.0
    shelly-api-docs.shelly.cloud

    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();

    Shelly Script Language Features | Shelly Technical Documentation
    Since version 0.9.0
    shelly-api-docs.shelly.cloud

    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.

    Screenshot 2023-10-16 22.15.28.png

    pasted-from-clipboard.png

    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, bitte registrieren Sie sich oder melden Sie sich an um diese lesen zu können.