AutoTools WebScreens UpdateValues automatically with setInterval ?

Discussion in 'AutoApps' started by AgP42, Aug 28, 2019.

  1. AgP42

    AgP42 New Member

    Joined:
    Aug 24, 2019
    Messages:
    15
    Likes Received:
    0
    Hello,

    I am building a web screen to manage my thermostats, I will use 8 of them and each will have to dynamically display 4 infos (actual mode, actual temperature, state of the heater and actual target temperature).

    I already receive all thoses informations to update widgets (with Zooper) and that's works great for years !

    I am able to display them on my web screen and I can refresh them by calling the refresh with a new task.
    But I don't want to set a listener for each info that will trigger an update (32 !) of the webscreen and then to test if the corresponding webscreen is displayed to then trigger a refresh, it seams really over complicated !

    So I tried to add on my web screen a function setInterval that will trigger itself its own refresh every 5 seconds when it is displayed.
    But for some reason, it doesn't work...

    Is it mandatory for the update that it is "pushed" from Tasker ? Isn't it any way for the web screen to refresh itself ?

    I hope my question was clear enough, thank you very much for anyone that can help !:)

    (PS : sure I have read https://github.com/joaomgcd/AutoToolsWebScreens and this : https://github.com/joaomgcd/AutoToolsWebScreens/blob/master/demos/updating/page.html, both were very usefull !)

    Thanks !

    AgP
     
  2. joaomgcd

    joaomgcd Administrator Staff Member

    Joined:
    Feb 3, 2015
    Messages:
    8,721
    Likes Received:
    737
    Hi :) Hope you're doing well. Were you able to overcome this issue?
     
  3. AgP42

    AgP42 New Member

    Joined:
    Aug 24, 2019
    Messages:
    15
    Likes Received:
    0
    Hi,

    infortunatelly no, I didn't success and for now I even forget about it. But if you could give me some clues I will appreciate it anyway for my next version ;-)
     
  4. joaomgcd

    joaomgcd Administrator Staff Member

    Joined:
    Feb 3, 2015
    Messages:
    8,721
    Likes Received:
    737
    Ok, to answer your question, yeah, the webscreen should be able to update itself without the need of Tasker :) How exactly are you trying to do that?
     
  5. AgP42

    AgP42 New Member

    Joined:
    Aug 24, 2019
    Messages:
    15
    Likes Received:
    0
    I added a "setInterval" javascript function that call a refresh of "updateValue(values);" every 5s.

    Here is the code of this updateValue(values) function :

    ```
    var updateValue = function(values){
    slider_title.innerHTML = title_text;
    sub_title.innerHTML = values.subtitle_text;
    val = +values.initial_value; //notre valeur de départ, vient des config AutoTools
    _O.textContent = values.val;
    _L.textContent = values.slider_label;
    }
    //Because this function is present the "Update" option will appear in the Tasker configuration screen. All the values used as inputs there will be set in the "values" parameter here
    var autoToolsUpdateValues = function(values){ // values represent all the datas from Tasker defined on the configuration
    updateValue(values);
    }
    /* Allow tasker to update the screen with thoses variables without full reload */

    ```
     
  6. joaomgcd

    joaomgcd Administrator Staff Member

    Joined:
    Feb 3, 2015
    Messages:
    8,721
    Likes Received:
    737
    Ah, if you want to use setInterval you have to get all the values from javascript itself. Tasker won't send any updated values that way. :)
     
  7. AgP42

    AgP42 New Member

    Joined:
    Aug 24, 2019
    Messages:
    15
    Likes Received:
    0
    ok, it was my question, so it is not possible...

    Thanks for your answers and help anyway !
     
  8. joaomgcd

    joaomgcd Administrator Staff Member

    Joined:
    Feb 3, 2015
    Messages:
    8,721
    Likes Received:
    737
    Oh I see. You could always send a command to Tasker at that interval which makes Tasker run the task to update the values again :)
     

Share This Page