21.03.2017, 23:25
(This post was last modified: 22.03.2017, 08:56 by Erwin van der Zwart.)
Hi,
You can use the localbus like this:
1) First you need to include the JS lib
2) You need to start (init) the localbus
3) Now you can listen to all or a single KNX events like this
4) Or update / write to a object like this
5) You can also listen to storage change events like this
Don't know if we can also simply write to the storage by using this, maybe admin can say something about that
Edit: Tested yesterday evening the above option to write to storage and is not possible as far as i can tell...
BR,
Erwin
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