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 that you accept these cookies being set.

Js variables & Lua variables
#5
Hi,

You can use the localbus like this:

1) First you need to include the JS lib

Code:
<head>
 <script src="/apps/js/localbus.js.gz"></script>
</head>

2) You need to start (init) the localbus

Code:
<script>
    (function() {
        if (typeof localbus !== 'undefined') {
            localbus.init();
        }
    });
</script>

3) Now you can listen to all or a single KNX events like this

Code:
<script>
 $(function() {
    // listen to all groupwrite telegrams
    localbus.listen('groupwrite', function(event) {
      console.log(event);
    });

    // listen to a single object
      localbus.listen('object', '1/1/1', function(value) {
      console.log(value);
    });
 });
</script>

4) Or update / write to a object like this

Code:
<script>
 $(function() {  
   localbus.write('1/1/1', true);  // same as grp.write('1/1/1', true)
   // or
  localbus.update('1/1/2', 42); // same as grp.update('1/1/2', 42)
 });
</script>

5) You can also listen to storage change events like this

Code:
<script>
 $(function() {  
   localbus.listen('storage', 'YourStorageName', function(value){
   console.log(value);
   });
 });
</script>

Don't know if we can also simply write to the storage by using this, maybe admin can say something about that

Code:
<script>
 $(function() {
   localbus.write('storage', 'YourStorageName', "your string"); // can we write to storage?
   // or
   localbus.write('storage', 'YourStorageFolder:YourStorageName', "your string"); // can we use the storage folders to read write to?
   // or
   localbus.write('storage', 'YourStorageName', {value1:10, value2:20, value3:30}); // can we write a json object or must this be a LUA table string?
 });
</script>

Edit: Tested yesterday evening the above option to write to storage and is not possible as far as i can tell... 

BR,

Erwin
Reply


Messages In This Thread
Js variables & Lua variables - by Jonathan - 17.03.2017, 16:12
RE: Js variables & Lua variables - by Erwin van der Zwart - 21.03.2017, 23:25
RE: Js variables & Lua variables - by admin - 23.03.2017, 06:59

Forum Jump: