node-bacstack icon indicating copy to clipboard operation
node-bacstack copied to clipboard

How to handle events coming from a notification object?

Open cemremengu opened this issue 7 years ago • 6 comments

As the title says, if I setup a bacnet server and set the notification object in my controller to forward the messages to my server, how do I handle those events?

I searched but couldnt see anything in the docs or code. Is it possible?

cemremengu avatar Dec 15 '17 12:12 cemremengu

Hi @cemremengu

I've just started recently to tackle the whole alarming and eventing topic (see here), as I don't have too much experience with it.

I'm not really sure, what BACNET service you mean with that, but I assume you either using eventNotifyConfirmed or eventNotifyUnconfirmed. If this is the case, it should (never tested outside of syntactical unit-tests) be supported (see here for confirmed and here for unconfirmed). It should looks something like this (for the unconfirmed type):

var bacnet = require('bacstack');

const client = new bacnet();

client.on('eventNotify', (package) => {
  console.log(`Received 'eventNotify' from device: ${package.address} - Payload:`);
  console.log(eventData);
});

Let me know if this helps.

Cheers

fh1ch avatar Dec 27 '17 11:12 fh1ch

Sorry for the late reply, I was on holidays

In order to be able to receive event notifications, I need to be able to assign a deviceId to my client, receive a whoIs request and reply with an iAm

How to do this is not very obvious from documentation and code (at least for me). Could you please provide some assistance if possible?

cemremengu avatar Jan 08 '18 09:01 cemremengu

Sorry for the late reply, I was on holidays

No worries, me too 😄

In order to be able to receive event notifications, I need to be able to assign a deviceId to my client, receive a whoIs request and reply with an iAm

This doesn't really sounds like "BACNET eventing" at all, but more like you try to implement a BACNET device, wich supports the whoIs / iAm service. Am I right with this assumption?

How to do this is not very obvious from documentation and code (at least for me). Could you please provide some assistance if possible?

There is currently no documentation for the service handling part of most functions (see https://github.com/fh1ch/node-bacstack#features), as there still marked as unstable. However, I've used those functions in one of my other projects (see https://github.com/fh1ch/node-bacstack-device/blob/master/index.js#L30), where I try to implement a BACNET device (server) in JavaScript.

fh1ch avatar Jan 08 '18 10:01 fh1ch

Yes, your assumption is correct. In order to receive event notifications, you need to register a device in automation server (controller). After that, you can select your device to receive events from a notification class. WhoIs/IAm is required at registration step for device discovery.

cemremengu avatar Jan 08 '18 10:01 cemremengu

@cemremengu Did you managed it? It would be awesome if you could share your code and also maybe check if it works with https://github.com/BiancoRoyal/node-bacstack (which is an updated fork of this library). We also started to provide some example scripts ... maybe we could add such an event notify receiver there as example?

Apollon77 avatar May 26 '20 23:05 Apollon77

Unfortunately, it has been a long time and I no longer work with the project :disappointed:

cemremengu avatar Jun 01 '20 18:06 cemremengu