OpenADR implementation in TypeScript for Node.js (partial)
This repository contains an initial stab at OpenADR for Node.js written in TypeScript. At the moment it only supports implementing a PULL-mode Virtual End Node (VEN). It has only been tested against the OpenLEADR Virtual Top Node (VTN).
At the moment it implements a small subset of OpenADR 2.0b:
- It can use oadrCreatePartyRegistration to connect with a VTN.
- The
startmethod sets up a job scheduler, which is meant to be the means for scheduling report execution. - The
startmethod initializes a Poll job, to send OadrPoll requests to the VTN. - The
pollmethod has the initial bones of dispatching Poll responses to handler functions. - DistributeEvent messages are handled in
handle_on_event. A VEN sets up a handler for this usingon_event.
This means it does not:
- Register reports with the VTN
- Handle other Registration tasks
- Support canceling Registration or Report operations
This library also does not contain enough to implement a VTN.
This library was created by studying the following OpenADR implementations:
- https://github.com/OpenLEADR/openleadr-python
- https://github.com/bbartling/openadrtester
- https://github.com/Argonne-National-Laboratory/node-red-contrib-oadr-ven
The latter is written in Node.js, but is also written for the NodeRED environment. NodeADR is meant to be used in generic Node.js, and not be limited to NodeRED.
A trivial example:
import*asVENfrom'./dist/client.js';constVEN_NAME=process.env['VEN_NAME'];constVEN_ID=process.env['VEN_ID'];constVTN_URL=process.env['VTN_URL'];constven=newVEN.OpenADRClient(VEN_NAME,VEN_ID,VTN_URL);ven.on_event(event=>{console.log(`on_event `,event);return'optIn';});awaitven.start()This sets up the VEN, and starts the scheduler. The only job, as said above, is OadrPoll.