This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

Custom JavaScript examples
Small suggestion, replace this:
position_plus = Scada.encodeGroupAddress('6/0/54'); // Position
objectStore.addListener(position_plus, function(obj, type) {

With this:
grp.listen('6/0/54', function(obj, type) {
Another small suggestion:

Replace 'click' with 'vclick' to make it also work on touch devices (;


Good one, click works on touch devices but can have a nasty delay which makes UI feel slow.
What is the difference between:

"objectStore.addListener(position_plus, function(obj, type) {"
"grp.listen('6/0/54', function(obj, type) {"

And also how can I run function at every object update not only on change? Because of this I used 2 objects not 1 like would be easierWink
Yes, add a third parameter to grp.listen and set it to true. Then your callback will be executed for every value update.
Like here:
"grp.listen('6/0/54', function(obj, type, true) {"
grp.listen('6/0/54', function(obj, type) { ... }, true);
I've tested whole little project also on iPhone and click was working. But when I changed to 'vclick' it is not working. Are you sure that 'vclick' works also on svg?

Sory for a lot of questions but I am still learning a lot with this new tool(Custom javascript)Wink
Actually, no, because you are using native addEventListener call, vclick only works on jQuery objects. Don't bother if it's working properly for you already.
Can I replace js function 'addEventListener' with some other jQuery?

Maybe something like this?

I want to know the best solution(from clearness and effective) so your suggestions are very important for me. I also know that jQuery has less code so it is much clearerWink
Is there a way to replace layer background with some other e.g. background_day and background_night?

I have not the best solution but working. I've added on layout 1 image with additional class 'day' and without any background. I've also added to Custom javascript little code which change the path to night image when GA 0/0/20 has value == false.

// Day/Night background change
grp.listen('0/0/20', function(obj, type) {
var plans = $('.day')[0]
if (obj.value == true) {plans.innerHTML = '<img src="/scada/resources/img/Day.jpg?1465541682">';} else {plans.innerHTML = '<img src="/scada/resources/img/Night.jpg?1465541682">';}
}, true);
Maybe somebody know how solve this problem:

I have temperature on the widget. I am changing its color via custom javascript. On PC(firefox, safari) all is perfect.

The problem is on iOS(iPhone 5s, iPad Air 2) and Android(Samsung Galaxy S7 Edge). Temperature has default color.

There are no errors in the console.

Maybe you Admin, can check if custom javascript works also on controls which are on the widgets on such systems(iOS, Android). Please Shy
Hi is possible to open a specific page + play a mp3 file saved in the storage when a grp address is triggered...???  Huh

I want to use it for the alert page, in case of alarm the graphics changes to the alert page + play a alert mp3.   Big Grin
See this post for alert tone that should work across all platforms, playing an audio file might require extra activation step on certain devices:

Then you can call showPlan(planId) to show the required page.
The beep function doesn't work in my iphone... ( in the laptop yes )

This solution with mp3 works in both, iphone & laptop:

Is possible to play the sound when a grp address is triggered instead the click of the mouse...???
Hi Cekca,

There are restrictions build into iOS by Apple that require user input to play audio.

The audio must be called once by a user event like 'click', the sample i made you point out to has this event so that's why it works.

Here is a fix to bypass it but still not fully... You have to at least touch the screen once (anywhere) to be able to play audio during the rest of the session..

// Fix iOS Audio Context
(function() {
    var fixAudioContext = function (e) {
        if (ctx) {
            // Create empty buffer
            var buffer = ctx.createBuffer(1, 1, 22050);
            var source = ctx.createBufferSource();
            source.buffer = buffer;
            // Connect to output
            // Play sound
            if (source.start) {
            } else if ( {
            } else if (source.noteOn) {
        // Check if document is loaded in iframe
        if (window.frameElement){
            // Remove event listeners from parent
            var thisparent = window.parent;
            thisparent.document.removeEventListener('touchstart', fixAudioContext);
            thisparent.document.removeEventListener('touchend', fixAudioContext);
        // Remove events
        document.removeEventListener('touchstart', fixAudioContext);
        document.removeEventListener('touchend', fixAudioContext);
    // Check if document is loaded in iframe
    if (window.frameElement){
        // Add event listeners to parent
        var thisparent = window.parent;
        // Event listener for iOS 6-8 (was previous touchstart event)
        thisparent.document.addEventListener('touchstart', fixAudioContext);
        // Event listener for iOS 9+ (is now touchend event)
        thisparent.document.addEventListener('touchend', fixAudioContext);
    // Event listener for iOS 6-8 (was previous touchstart event)
    document.addEventListener('touchstart', fixAudioContext);
    // Event listener for iOS 9+ (is now touchend event)
    document.addEventListener('touchend', fixAudioContext);

And yes you can trigger audio by KNX object, check previous custom JavaScript samples, there a quite a lot scripts with this functionality..


Erwin van der Zwart
Hi Erwing,
I would like to realise a switch which send "1" when I push and send "0" when I release. What do you suggest?

Add this to Custom JavaScript and set Additional classes to bell-press for each element that requires this functionality. This will work both in Touch and User mode visualization.

  var el, els;
  if ($('html').hasClass('touch')) {
    els = $('.bell-press .control');
  else if ($('body').hasClass('usermode')) {
    els = $('.bell-press');
  else {
    .on('vmousedown.bpress', function() {
      el = $(this).closest('.bell-press');
      grp.write('object'), true);
    .on('dragstart', function() {
      return false;

  $('body').on('vmouseup.bpress vmousecancel.bpress', function() {
    if (el) {
      grp.write('object'), false);
      el = null;
Do you know how wake up the monitor via javascipt? E.g. when doorphone calls.
Not yet possible, there's a draft standard whicl allows to control standby:
And there are libraries that allow to prevent sleep on Android/iOS:

Forum Jump: