Fork me on GitHub

pimatic-smartmeter3 by Bert Gierveld (bertreb) | github | npm

pimatic-smartmeter3

Reading "Smartmeter" energy (electricity and gas) usage through P1 port. This plugin is a based on the smartmeter versions of saberone and rick00001. This plugin supports serialport version 6 (node v4 and v8) and gives the possibility to read ascii based Datagrams from Smartmeters (like the DSMR). You can change the regex formulas for the energy values in the device config. If this plugin doesn't fit, you could use the more advanced pimatic-smartmeter-obis plugin (https://github.com/bertreb/pimatic-smartmeter-obis).

Installation

To enable the smartmeter plugin add this to the plugins in the config.json file.

...
{
  "plugin": "Smartmeter3"
}
...

and add the following to the devices

{
  "id": "smartmeter3",
  "class": "Smartmeterdevice3",
  "name": "smartmeter3",
  "serialport": "/dev/ttyUSB0",
  "baudRate" : 115200,
  "dataBits" : 8,
  "parity" : "none",
  "stopBits" : 1,
  "flowControl" : true
}

Then install through the standard pimatic plugin install page.

Configuration

You can configure what serialport to use and the serialport settings.

The device provides the following 4 variables:

  • $\.actualusage (Actual usage in Watt)
  • $\.tariff1totalusage (Tariff 1 total usage in kWh)
  • $\.tariff2totalusage (Tariff 2 total usage in kWh)
  • $\.gastotalusage (Gas total usage in m3)

The number of decimals in de Gui can be changed via xAttributeOptions.

Different smartmeter versions

The current version has been tested with a DSMR5.0 smartmeter. If your smartmeter version uses different data field you can change the RegEx in de device config to meet your smartmeter.

A simple commandline tool can help to get your smartmeter data and build your RegExp. The tool is a node.js app/tool that dumps the P1 data straight to a file.

Run the following commands from the root of this plugin.

npm install
chmod +x logP1.js
./logP1.js

RegEx configuration

Below the 5 customizable Regular Expression (RegEx) fields in the config.json device section. The RegEx is used to filter out the specific data. A RegEx string need double backslashes (escape character in strings). If you edit the RegEx in the Gui Device page, you can use the normal single backslashes.

{
  "t1TotalUsage": "^1-0:1\\.8\\.1\\(0+(\\d+\\.\\d+)\\*kWh\\)",
  "t2TotalUsage": "^1-0:1\\.8\\.2\\(0+(\\d+\\.\\d+)\\*kWh\\)",
  "activeTariff": "^0-0:96.14.0\\(0+(.*?)\\)",
  "actualUsage": "^1-0:1.7.0\\((.*?)\\*",
  "gasTotalUsage" : "^0-1:24\\.2\\.1\\(\\d{12}.\\)\\(0+(\\d+\\.\\d+)\\*m3\\)"
}

If you have issues, please create an issue overe here : https://github.com/bertreb/pimatic-smartmeter3/issues

Plugin Config Options

Smartmeter3

Device Config Options

pimatic-smartmeter3 device config schemas

Smartmeter3Device

Smartmeter config options
OptionDescriptionDefault
serialPort
string
Serialport name (e.g. /dev/ttyUSB0)
"/dev/ttyUSB0"
baudRate
integer
Baudrate to use for communicating over serialport (e.g. 9600)
115200
dataBits
integer
Number of databits to use for communication over serialport (e.g. 7)
8
parity
string
Parity to use for communication over serialport (can be 'none', 'even', 'mark', 'odd', 'space')
"none"
stopBits
integer
Number of stopBits to use for communication over serialport (can be 1 or 2)
1
flowControl
boolean
Use flowControl for communication over serialport (can be true or false)
true
t1TotalUsage
string
RegEx for tariff 1 total usage (T1)
"^1-0:1\\.8\\.1\\(0+(\\d+\\.\\d+)\\*kWh\\)"
t2TotalUsage
string
RegEx for tariff 2 total usage (T2)
"^1-0:1\\.8\\.2\\(0+(\\d+\\.\\d+)\\*kWh\\)"
activeTariff
string
RegEx for active tariff
"^0-0:96.14.0\\(0+(.*?)\\)"
actualUsage
string
RegEx for actual usage
"^1-0:1.7.0\\((.*?)\\*"
gasTotalUsage
string
RegEx for gas total usage
"^0-1:24\\.2\\.1\\(\\d{12}.\\)\\(0+(\\d+\\.\\d+)\\*m3\\)"
pimatic-smartmeter3 is written by Bert Gierveld (bertreb)