How do I find the date and time in the script

  • Have a nice day,

    please, how can I find out the current time with the help of the 4PM PRO shell script.

    this doesn't work:

    let currentTime = Date.now();

    print("Current time: " + currentTime);

    not this either:

    let now = new Date();

    print(now);

    can you advise... thanks

    Best regards

    Pavel Prochazka.zde.cz

  • I have already realized that I have to grant it via the method:

    Sys.GetStatus and there is a time entry

    I just don't know how to write it in the code...

    this doesn't work for me:

    let rr = Sys.GetStatus.time;

    it says that SYS is not defined...

    what include files should I add to the code...

    I don't know mJS, but only C and ASM... so then I swim in programming.

    System | Shelly Technical Documentation
    The system component provides information about general device status, resource usage, availability of firmware updates, etc.
    shelly-api-docs.shelly.cloud
  • I already figured it out, I took the help of artificial intelligence, although it didn't tell me the exact code, it kept spinning in circles, but it managed to tell me where to go. I ended up compiling this code:

    Shelly.call("Sys.GetStatus",{},

    function(result, err_code, err_message, user_data) {

    if (err_code === 0) {

    // processing successful result

    console.log("Result:", result.time);

    } else {

    // error handling

    console.log("Error:", err_message);

    }

    },

    null);

    Which, after running, writes the current time in the device to the console. And as you can see, with the help of this construction, you can find out any value that is given on the link, see the contribution above....

    Hopefully this will help someone else in writing a script for SHELLY 4PM PRO.