npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@1st-setup/openthermgateway

v0.0.18

Published

Nodejs module for communicating with an OpenThermGateway

Downloads

54

Readme

This is a NodeJS modules to be able to connect to an Opentherm Gateway (OTGW).

How to use: See openthermgw_example.js

Install

npm install @1st-setup/openthermgateway

Usage:

Listening to traffic coming from OTGW:

const openthermGatway = require('@1st-setup/openthermgateway');

var myOTGW = new openthermGatway("/dev/ttyUSB0",null, {debug:true});
myOTGW.on("error", (err) => {
    console.error(err.toString());
});

myOTGW.on("exception", (err) => {
    console.error(err.toString());
});

myOTGW.on("inError", (err) => {
    console.error(err.toString());
});

myOTGW.on("otgwError", (err) => {
    console.error(JSON.stringify(err,null,"\t"));
});

myOTGW.on("initialized",() => {
    console.log("Initialized");
    myOTGW.sendCommand("PS=0",(err, response) => {

    });
})

myOTGW.on("connected",() => {
    console.log("Connected");
})

myOTGW.on("otgwData",(data) => {
    console.log("otgw >> "+JSON.stringify(data,null,"\t"));
    console.log("otgw.data >> "+JSON.stringify(myOTGW.data,null,"\t"));
})

myOTGW.on("printSummary",(data) => {
    console.log("printSummary >> "+JSON.stringify(data,null,"\t"));
})

Sending commands to OTGW (see: OTGW Serial commands):

const openthermGatway = require('@1st-setup/openthermgateway');

var myOTGW = new openthermGatway("/dev/ttyUSB0",null, {debug:true});

// To get About opentherm gateway (prints the welcome message) 
myOTGW.sendCommand("PR=A", (err, response) => {
    if (err) {
        console.error(`Error sending command: Error:${err}`);
    }
    else {
        console.log(`Response to command PR=A: ${response}`);
    }
})

Class openthermGatway

Methods:

Constructor(serialDevice, serialOptions, otgwOptions)

Called when you use new to create a new openthermGateway object

Input:

  • serialDevice: String containing ful path to serial device. E.g.: "/dev/ttyUSB0"

  • serialOptions: Object containing openOptions for the 'serialport' module.

  • otgwOptions: Object with following properties:

    • debug: Boolean. When 'true' all incoming and outgoing trafic on serial interface will be logged to console.

sendCommand(data, cb)

With this method you can send a command to the OTGW

Input:

  • data: String with valid OTGW Serial command. E.g.: "PR=A"

  • cb: Callback function which will be called when response is received on send command. Callback function is called with following arguments:

    • err: Object containing the error encountered.
    • response: The response from the OTGW on the send command.

decode(data)

With this method you can decode data, messages, received from the OTGW.

Input:

  • data: String with the message received from the OTGW.

Output:

  • Object with decoded message or null on error. Object will have following properties:

    • status: Character specifying what genereated the message.

      • "R": "Gateway to boiler"
      • "B": "From boiler"
      • "T": "From thermostat"
      • "A": "Gateway to thermostat"
    • direction: String telling what generated the message.

    • msgType: Hex code specifying the type of message.

    • msgTypeStr: String for msgType. Currently only: "Read-Ack" or "Read-Data".

    • id: Hex code specifying from which opentherm id the values are.

    • idStr: String with explanation of id. When id is not known this will be set to "UNKNOWN".

    • val1: Hex code for value part 1.

    • val2: Hex code for value part 2.

    • Status: Object. Only when id == "00" (OTGW_ID_STATUS). Each bit in val1 and val2 tells the status of different opentherm status fields. The properties in this object have the name of the field and the boolean value for the bit. True for set (1) and false when not set (0).

    • StatusStr: Object. Human readable version of Status object.

    • <idStr>: Depending on the id this is a Number (float), Number (integer), String ("<val1> <val2>")

Events:

Following event are emitted by the class:

  • error: This is emitted when there is an error anywhere.
  • exception: This is emitted when we receive a response for a command which was already answered.
  • connected: When succesfully connected to OTGW.
  • initialized: When succesfully communicated with the OTGW and received the response to following commands: PR=A (Get about), PR=M (Get mode)) and PR=W (Get if domestic hot water is enabled).
  • inError: When a message is received from OTGW but we cannot decode it.
  • otgwData: When data is received and decoded from OTGW.
  • otgwError: When the OTGW reported and error. This happens when a wrong command was given, a wrong formatted command value was specified or something in the opentherm communication for the gateway went wrong.
  • printSummary: When the Print Summary mode command "PS=1" is send this event will follow it.