Skip to content

OpenADR implementation in TypeScript for Node.js

License

Notifications You must be signed in to change notification settings

robogeek/nodeadr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nodeadr

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 start method sets up a job scheduler, which is meant to be the means for scheduling report execution.
  • The start method initializes a Poll job, to send OadrPoll requests to the VTN.
  • The poll method 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 using on_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:

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 * as VEN from './dist/client.js';

const VEN_NAME = process.env['VEN_NAME'];
const VEN_ID   = process.env['VEN_ID'];
const VTN_URL  = process.env['VTN_URL'];

const ven = new VEN.OpenADRClient(VEN_NAME, VEN_ID, VTN_URL);

ven.on_event(event => {
    console.log(`on_event `, event);
    return 'optIn';
});

await ven.start()

This sets up the VEN, and starts the scheduler. The only job, as said above, is OadrPoll.

About

OpenADR implementation in TypeScript for Node.js

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published