20.10.2022, 12:37
This way you can filter events by a single tag:
Code:
<?
require('apps')
objs = grp.tag('TAGNAME')
tagobjs = {}
for _, obj in ipairs(objs) do
tagobjs[ #tagobjs + 1 ] = obj.address
end
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Localbus</title>
<script src="/apps/js/jquery.js.gz"></script>
<script src="/scada/vis/busdecode.js.gz"></script>
<script src="/apps/js/localbus.js.gz"></script>
</head>
<body>
<script>
$(function() {
var tagobjs = <?=json.encode(tagobjs)?>;
localbus.init();
localbus.listen('groupwrite', function(event) {
if (tagobjs.indexOf(event.dst) >= 0) {
console.log(event.dst, event.value);
}
});
});
</script>
</body>
</html>