0.1.6 • Published 4 years ago

node-actions v0.1.6

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

Test & Publish Coverage Status

npm version

DSMR (Dutch Smart Meter Requirements) Parser

The parser supports telegrams compliant to DSMR version 2.x, 3.x, 4.x and 5.x.

Installation

$ npm install node-dsmr

API

const SmartMeter = require('node-dsmr')

var options = {
    port: '/dev/ttyUSB0',
    baudrate: 9600,
    bits: 7,
    parity: 'even'
}

var smartmeter = new SmartMeter(options)

SmartMeter

Instantiate a new SmartMeter object by specifying the characteristics of the P1 port.

var smartMeter = new SmartMeter(options)

The arguments are:

  • port, serial port to which the P1 port is connected
  • baudrate, the rate at which the P1 port communicates, for DSMR 2.2 and 3.0 meters this is 9600 and for 4.x this is 115200.
  • bits, the number of bits used, for DSMR 2.2 and 3.0 meters this is 7 and for 4.x this is 8.
  • parity, the parity used, for DSMR 2.2 and 3.0 this is even and for 4.x this is none.

SmartMeter.connect

The connect method is used to connect and open the serial port.

smartMeter.connect()

Events

When an event happens, e.g. successful connection or a telegram has been received, the event will be emitted. By creating listeners for these events, the event can be processed in your code.

  • connected, a successful connection to the serial port has been made.
  • telegram, a new telegram has been received, the data of the event is the complete telegram as a JSON.

    Example:

    {
        power: {
            equipmentId: 'K8EG004046395507',
            totalConsumed1: 12345.678,
            totalConsumed2: 12345.678,
            totalProduced1: 12345.678,
            totalProduced2: 12345.678,
            activeTariff: 2,
            actualConsumed: 1.19,
            actualProduced: 0,
            switchPosition: 1
        },
        gas: {
            equipmentId: '2222ABCD12345678A',
            totalConsumed: 0,
            timestamp: 1234450800,
            valvePosition: 1
        },
        meterModel: 'ISk5\\2MT382-1000'
    }
  • update, a new telegram has been received with updated metrics, the data of the event contains the updated metrics as JSON. The power metrics presenting the actual consumption and/or production are continuously measured and for that reason always included in the update event, even when the actual value is the same as the previous measurement. The gas metrics presenting the total consumption is measured periodically as indicated with the included timestamp. When the timestamp indicates a new measurement has been performed, the value is included in the update event even when the measurement is the same as the previous measurement.

    Example:

    {
        "power": {
            "totalConsumed1": 123456.789,
            "activeTariff": 1,
            "actualConsumed": 1.193,
            "actualProduced": 0
        }
    }

Reported metrics

The following metrics are reported when they are included in the telegram received from the P1 port:

CategoryMetricDescription
meterModel
dsmrVersiononly report for DSMR version 4.x and 5.x
timestamptimestamp of the telegram
powerequipmentId
totalConsumed1total consumption in tariff 1 (off-peak)
totalConsumed2total consumption in tariff 2 (peak)
totalProduced1total production in tariff 1 (off-peak)
totalProduced2total production in tariff 2 (peak)
actualConsumed
actualProduced
actualTariffactive tariff (1=off-peak or 2=peak)
failureLogpower failure event log (see below)
failuresnumber of power failures
failuresLongnumber of long power failures
voltageSagsL1
voltageSagsL2
voltageSagsL3
voltageSwellsL1
voltageSwellsL2
voltageSwellsL3
instantaneousCurrentL1
instantaneousCurrentL2
instantaneousCurrentL3
instantaneousVoltageL1
instantaneousVoltageL2
instantaneousVoltageL3
instantaneousConsumedElectricityL1
instantaneousConsumedElectricityL2
instantaneousConsumedElectricityL3
instantaneousProducedElectricityL1
instantaneousProducedElectricityL2
instantaneousProducedElectricityL3
switchPosition
gasequipmentId
timestamptimestamp of the last measurement
totalConsumedmeasured total consumption
reportedPeriodperiod in minutes over which the total consumption is reported
valvePosition

Failures

DSMR version 4.x and 5.x might contain a failure event log which is reported as an array. Example:

[
    {
        "timestampEnd": 1291818255,
        "duration": 240
    },
    {
        "timestampEnd": 1291817404,
        "duration": 301
    }
]

Parser

It is also possible to only use the parser without the connectivity logic:

const parser = require('node-dsmr/lib/parser');

const telegram = [
  '/ISk5\\2MT382-1000',
  '0-0:96.1.1(4B384547303034303436333935353037)',
  '1-0:1.8.1(12345.678*kWh)',
  '1-0:1.8.2(12345.678*kWh)',
  '1-0:2.8.1(12345.678*kWh)',
  '1-0:2.8.2(12345.678*kWh)',
  '0-0:96.14.0(0002)',
  '1-0:1.7.0(001.19*kW)',
  '1-0:2.7.0(000.00*kW)',
  '0-0:17.0.0(016*A)',
  '0-0:96.3.10(1)',
  '0-0:96.13.1(303132333435363738)',
  '0-0:96.13.0(303132333435363738393A3B3C3D3E3F303132333435363738393A3B3C3D3E3F 303132333435363738393A3B3C3D3E3F303132333435363738393A3B3C3D3E3F 303132333435363738393A3B3C3D3E3F)',
  '0-1:96.1.0(3232323241424344313233343536373839)',
  '0-1:24.1.0(03)',
  '0-1:24.3.0(090212160000)(00)(60)(1)(0-1:24.2.1)(m3)',
  '(00000.000)',
  '0-1:24.4.0(1)',
  '!'
]

console.log(parser(telegram))
0.1.7

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago