P1 smartmeter (API)

Thanks for the reply Robert.

See the screenshot below.

The top output is with the 9600 7 none settings the bottom one is with 9600 7 even which should be the correct settings.

The strange thing is that with the correct serial settings its not getting any data. Even though when using minicom the correct data is received.

@robertklep
See hereby the outcome when using minicom with the correct 9600 7 even settings:
Screenshot 2020-07-13 at 16.05.13

This suggest me that the data from the reader is correct.

It looks like the script can’t parse the output of your meter. I have the same meter, so I know it’s DSMR 2.2. When I use the parser from node-dsmr, it can parse the telegrams just fine, so it’s not that.

However, I just noticed that the p1.js script will post incomplete data to Homey, which is why it looks like it’s working, but it probably isn’t.

Can you also add this after this line:

console.log(telegram)

That should show that the script has actually read from the P1 port.

1 Like

Nothing seems to happen when adding the line.

Screenshot 2020-07-13 at 16.13.15

Screenshot 2020-07-13 at 16.13.26

That doesn’t make sense, because then it would never reach the “posted successfully to” lines that were being logged.

By the way, what type of reader are you using for the P1 port?

1 Like

Strange isn’t it. I can’t make any sense of it and with the wrong serial settings it is posting data even tough its incomplete.

I am using this cable at the moment:
https://www.robbshop.nl/slimme-meter-kabel?sqr=p1%20kabel&
Already tried a new one but that was exactly the same. Before switching to home reading the meter with homebridge was working fine btw.

Thanks for your help. Very much appreciated.

I was interested in seeing the telegram data in that situation :slight_smile: Because apparently the parser is able to parse a telegram, and I’m interested to know what it contains.

The cable seems okay, it explicitly supports your type of meter.

p1Meter.on('telegram', telegram => {
console.log(telegram)
if (telegram.hasOwnProperty('gas')) {
    logger.info('p1 smartmeter update gas')
    publishToHomey(telegram)
}
if (telegram.hasOwnProperty('power')) {
    logger.info('p1 smartmeter update power')
    publishToHomey(telegram)
}

})

Is this setting correct to check the telegram data?

When adding the console.log(telegram) this is the output:

Yeah, it may say it posted successfully, but in fact it posted empty data because that’s what the parser returns. I think you need to fiddle with the serial configuration and hope there’s some magic combination that works (I use 9600 baud, 7 bits even, 1 stop bit, but I’m using a software serial library on an ESP8266, not a dedicated p1-to-serial cable).

1 Like

Will do some more trial and error with the serial settings.

Do you by any change have and example config for an ESP8266 I have a nodeMCU laying around I don’t use at the moment. I couldn’t find an example for an ESP board otherwise I would have tried that before.

Thanks again

I wrote some very hacky ESP8266 code to publish just enough data over MQTT so the DSMR Reader component of Home Assistant is able to process the data: https://gist.github.com/robertklep/b94f6a48d46d9f8c633a6a5b5bf10123

It uses the SoftwareSerial library which is able to perform the required signal inversion, so the P1 pins are directly connected to the ESP8266, no special cable or anything. I can’t exactly remember which pin connects to what, but it should be easy to find out.

2 Likes

This is going to be fun. I will tell my girl friend I am not coming down for the weekend :smiley:

Hello @Koktail ,

First of all thanks for the app! :slight_smile:
I’m successfully getting (almost all) of my meter readings into homey.
There are however some readings not coming in, while I do post them successfully.

Below is an example of the telegram being posted.

{ power:
   { equipmentId: 'E0031003294099116',
     totalConsumed1: 2035.457,
     totalConsumed2: 1135.81,
     totalProduced1: 1440.818,
     totalProduced2: 3522.485,
     activeTariff: 2,
     actualConsumed: 0.071,
     actualProduced: 0,
     failures: 7,
     failuresLong: 6,
     failureLog:
      [ [Object], [Object], [Object], [Object], [Object], [Object] ],
     voltageSagsL1: 0,
     voltageSwellsL1: 0,
     instantaneousCurrentL1: 1,
     instantaneousProducedElectricityL1: 0.071,
     instantaneousConsumedElectricityL1: 0 },
  gas:
   { equipmentId: 'G0019340304850616',
     timestamp: 1596481200,
     totalConsumed: 2753.522,
     reportedPeriod: 60 },
  meterModel: 'XMX5LGBBFG1012651747',
  dsmrVersion: 4.2,
  timestamp: 1596483040 }

As you can see, there is a value for ActualConsumed and ActualProduced.
However in the app, there is no value for ActualConsumed, ActualProduced and ActualConsumed-Produced.

Can you help figuring out why this is? Is it because the values are just too low?

Thanks already for you help :slight_smile:

That is strange. I think the app and pusher script aren’t compatibel. Or you telegraph isn’t supported yet. Unfortunatly i do not have the time to look into every single case.

Maby you can find someone that can narrow it down to an specific issue.

My original bash script is borking after the recents updates. I’m having problems with getting the correct json data to Homey. Does somebody have a working example of an update json post to the new version?

Let me add to this conundrum. My json post is accepted, but I seem to be having the wrong layout, since it only gives me 0 W Electricity Current Usage, 0 W Electricity Usage-Generated and 0 W Electricity Current Delivery in the P1 smartmeter overview screen. Here is my json post (redacted the readings to 1234):

Contents of json post

{
“meterType”: “Iskra ME382”,
“version”: “DSMR 2.2”,
“timestamp”: 200825131512,
“data.electricity”: {
“received”: {
“tariff1”: {
“reading”: 1234.323,
“unit”: “kWh”
},
“tariff2”: {
“reading”: 1234.696,
“unit”: “kWh”
},
“actual”: {
“reading”: 0.10,
“unit”: “kW”
}
},
“delivered”: {
“tariff1”: {
“reading”: 1234.689,
“unit”: “kWh”
},
“tariff2”: {
“reading”: 1234.372,
“unit”: “kWh”
},
“actual”: {
“reading”: 0.00,
“unit”: “kW”
}
},
“tariffIndicator”: 2,
“switchPosition”: 0,
“voltageSags”: {
“L1”: 0,
“L2”: 0,
“L3”: 0
},
“voltageSwells”: {
“L1”: 0,
“L2”: 0,
“L3”: 0
}
},
“gas”: {
“reading”: 0,
“unit”: “m3”
}
}

I’ve just released an update for SDK 3.0 to test:

I’ve just released an update 4.0.1 to test:

@Koktail, I’m trying to get your plugin up and running on my Homey Pro and Raspberry Pi.

Unfortunately without any success. :frowning_face:

I have:

  • Iskra MT382 ( DSMR 2.2)
  • Raspberry Pi 4
  • Homey Pro

Steps taken:

  • Connected the P1 cable to the Rpi

  • Cloned the git archive ‘GitHub - koktaildotcom/com.p1.smartmeter-dsmr.reader’ to /home/pi

  • cd /home/pi/com.p1.smartmeter-dsmr.reader

  • npm install node-dsmr (failed because npm 5.x didn’t match with NodeJS 10.x

  • curl https://www.npmjs.com/install.sh | sudo sh

  • Now on version 6.14.10

  • npm install node-dsmr

  • npm install

  • nano src/p1.js

  • Updated Homey id

  • Configured serial port settings to 9600, 7, even

  • node src/p1/js
    root@raspberrypi:/home/pi/com.p1.smartmeter-dsmr.reader# node src/p1.js
    {“message”:“p1 smartmeter is connected!”,“level”:“info”}

  • Installed the app on my Homey (P1 Smartmeter | Homey)

  • Added the device

  • No info showing in the app…

  • Added ‘console.log(telegram);’ after ‘p1Meter.on(‘telegram’, telegram => {’

    • No logging
  • Started playing with communication settings. When I change ‘even’ to ‘none’ I receive a telegram and I get logging:

    • {“message”:“p1 smartmeter is connected!”,“level”:“info”}
      { power: {}, gas: {} }
      {“message”:“p1 smartmeter update gas or power”,“level”:“info”}
      {“message”:“posted successfully to: https://************.connect.athom.com/api/app/com.p1/update”,“level”:“info”}

But it looks like it doesn’t contain any data…
To verify the setup I downloaded the image for Ztatz P1 Monitor to another sd-card and that is working fine out of the box. (COM settings: 9600, 7, even)

Manual verification if the port is receiving data:
root@raspberry:/home/pi# cu -l /dev/ttyUSB0 -s 9600 --parity=none
Connected.
/ISk5\2MT382-1003

0-0:96.1.1(5A424556303035303933373337313132)
1-0:1.8.1(11219.782kWh)
1-0:1.8.2(11318.303
kWh)
1-0:2.8.1(00998.707kWh)
1-0:2.8.2(02222.371
kWh)
0-0:96.14.0(0002)
1-0:1.7.0(0000.00kW)
1-0:2.7.0(0000.08
kW)
0-0:17.0.0(0999.00*kW)
0-0:96.3.10(1)
0-0:96.13.1()
0-0:96.13.0()
!

root@raspberry:/home/pi# cu -l /dev/ttyUSB0 -s 9600 --parity=even
Connected.
/ISk5\2MT382-1003

0-0:96.1.1(5A424556303035303933373337313132)
1-0:1.8.1(11219.782kWh)
1-0:1.8.2(11318.303
kWh)
1-0:2.8.1(00998.707kWh)
1-0:2.8.2(02222.390
kWh)
0-0:96.14.0(0002)
1-0:1.7.0(0000.00kW)
1-0:2.7.0(0000.19
kW)
0-0:17.0.0(0999.00*kW)
0-0:96.3.10(1)
0-0:96.13.1()
0-0:96.13.0()
!

Any suggestions how I can get this up and running?
I prefer this plugin as I don’t want to use it on a Raspberry Pi (in the end) but on another server I already own.

Hi Silvia, I have this exact same issue and from the looks of it, we have the same reader. Gas readings are accurate, Power readings aren’t. I’m not sure where to start troubleshooting this, but I’ll dive into this. (Unless you already found a solution)