NAC Touchscreen Timeout and User Timeout Query/Scripting.

Discussion in 'C-Bus Automation Controllers' started by cbuslegend, Mar 4, 2020.

  1. cbuslegend

    cbuslegend

    Joined:
    Feb 24, 2020
    Messages:
    4
    Likes Received:
    0
    Hey guys,

    I was wondering if anyone could possibly throw some light on how on how to have the touchscreen timeout to a standby page after a certain number of seconds, say 60 of inactivity.

    Also the user would then have to enter their pin code on awakening the screen. Does anyone have sample lua scripting or is there a in-built function/feature that I've missed?

    Thanks in advance.
     
    cbuslegend, Mar 4, 2020
    #1
  2. cbuslegend

    Spooky

    Joined:
    Aug 28, 2006
    Messages:
    15
    Likes Received:
    1
    Hi,

    You need to do it in "edit custom javascript" as it needs to be performed by the browser loading the page.

    This is found under tools on the scripting tab.

    Code:
    function defaultplan(){
        return function(){
        
          showPlan(Globals.defaultPlan || planids[ 0 ]);  // times out to plan id 0
        }
    }
    
    var t;
    
    $(document).on('click touchend', function(){ 
      clearTimeout(t);
    t =   setTimeout(defaultplan(),30000);     // 30000 ms time out
    });
    
     
    Spooky, Mar 5, 2020
    #2
  3. cbuslegend

    Proto84

    Joined:
    Aug 31, 2020
    Messages:
    3
    Likes Received:
    0
    Hi Spooky
    Based on your script do you know what the variables are that need to be changed? How do you find the page ID?
     
    Proto84, Aug 11, 2021
    #3
  4. cbuslegend

    Adam McLeod

    Joined:
    Sep 16, 2009
    Messages:
    9
    Likes Received:
    0
    Location:
    Adelaide
    Hi Guys,

    I've been using this code for awhile but have just noticed that on a C-Bus ethernet touch panel 5000ETP that every time the timeout completes, the page refreshes even if it's already on the timeout page. When it refreshes sometimes you get a white background for 1-2 seconds and it resets the dimming level of the screen for another 1 minute.

    This is a continual cycle of waking and sleeping and is rather annoying.

    Is there a way to adjust this code so once it reaches the default plan page, the code pauses until another page is selected?

    Thanks in advance!
     
    Adam McLeod, Mar 24, 2022
    #4
  5. cbuslegend

    lcrowhurst

    Joined:
    Dec 2, 2004
    Messages:
    271
    Likes Received:
    97
    Location:
    Sydney, NSW, Australia
    Try this

    Code:
    
    $(function() {
     
      // Back to Start after x seconds (in miliseconds)
      var SE_Timeout = 90000; // adjust this timer value if needed (90 seconds in miliseconds)
      var SE_Startpage = 0; // 0 for default page otherwise enter a page number
      var eventlist = 'vclick vmousedown vmouseout touchend';
     
      // Timer function no usage detected
      function No_Usage_Detected(callback, timeout, _this) {
        var timer;
       return function(e) {
            var _that = this;
            if (timer)
                clearTimeout(timer);
            timer = setTimeout(function() {
                callback.call(_this || _that, e);
            }, timeout);
       }
     }
    
      // Back to start function when timer elapsed
        var SE_Goto_Startpage = No_Usage_Detected(function(e) {
       if ( currentPlanId != SE_Startpage ) {
       showPlan(SE_Startpage);
       // window.location.reload();
        }
        }, SE_Timeout);
     
      // Add event listener to document to detect user input
      $(document)
      .on(eventlist, function() {
        SE_Goto_Startpage();
     });
     
      // Add event listener to all iframes to detect user input inside iframes
      $('iframe').load(function() {
        var iframe = $('iframe').contents().find('html');
        iframe.on(eventlist, function(event) {
         SE_Goto_Startpage();
        });
      });
    
    }); 
    
    //=============================================================
    //
    // CODE END
    //
    //=============================================================
    
     
    lcrowhurst, Mar 25, 2022
    #5
  6. cbuslegend

    lcrowhurst

    Joined:
    Dec 2, 2004
    Messages:
    271
    Likes Received:
    97
    Location:
    Sydney, NSW, Australia
    A clock SVG you can put on your home page (edit: Sorry SVG icons are not being displayed, if you go to the links you can down load from there.

    [​IMG]

    link : crowhurst.com.au/icons/CTC-Clock-Black.svg

    [​IMG]
    link : crowhurst.com.au/icons/CTC-Clock-White.svg
     
    Last edited: Mar 25, 2022
    lcrowhurst, Mar 25, 2022
    #6
  7. cbuslegend

    Adam McLeod

    Joined:
    Sep 16, 2009
    Messages:
    9
    Likes Received:
    0
    Location:
    Adelaide
    Great, thanks so much! Works a treat.

    Much appreciated.
     
    Adam McLeod, Mar 29, 2022
    #7
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.