test and usage of KVS

  • Hi,

    I test the last beta (0.11beta3) on shelly 1 plus.

    For one of my project I test the new KVS and I don't understand why my var "out_the_call" is undefined in my log:

    My code:

    If you have one idea please :)

    Thank you.

  • Shelly.Call is asynchron, so the print at the end is executed before the kvsGet() has finished.

    you can validate this by adding a delay (Timer).

    >100 Shellies, darunter so gut wie alles was der Hersteller produziert hat. ;)
    :!: ich beantworte grundsätzlich keine Fragen per persönlicher Nachricht:!:

  • Do you know if there is plan to make this call synchron like some other call ?

    IIRC it was synchronous at the beginning but was changed. If you'd like to control a bunch of rempote shellies via loop it is important that network latency and response for each device doesn't delay the script execution. So I doubt this will be changed back.

    and there are still "workarounds" like adding a timer (my example above) or moving the related code to the response function:

    >100 Shellies, darunter so gut wie alles was der Hersteller produziert hat. ;)
    :!: ich beantworte grundsätzlich keine Fragen per persönlicher Nachricht:!:

  • Ok thanks for your reply, I understand the need about async result.

    I will think about it, because timer seems to be a "crapy fix". perhaps move the code into response, but I wouldlike get the value to use it into another function.. so I will think about.

    if a function require many KVS values, is very complicated to make clean code into response function....

    there is a solution to be notify when response is done ?

  • Dieses Thema enthält 2 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.