# P1 smartmeter (API)

**URL:** <https://community.homey.app/t/p1-smartmeter-api/6150>\
**Category:** Apps\
**Created:** [January 1, 2019, 12:22pm UTC](https://community.homey.app/t/p1-smartmeter-api/6150 "2019-01-01T12:22:22Z")\
**Posts on this page:** 20\
**Page:** 5

<div class="post-metadata">

**Author:** ![pssc92](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/pssc92/32/16562_2.png) [@pssc92](https://community.homey.app/u/pssc92)\
**Post date:** [July 13, 2020, 1:59pm UTC](https://community.homey.app/t/p1-smartmeter-api/6150/81 "2020-07-13T13:59:55Z")

</div>

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.

 ![Screenshot 2020-07-13 at 15.57.56](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/f/5/f546e0ae0f68b831d6e7f507d84707025eb53abe.png)

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.

---

<div class="post-metadata">

**Author:** ![pssc92](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/pssc92/32/16562_2.png) [@pssc92](https://community.homey.app/u/pssc92)\
**Post date:** [July 13, 2020, 2:06pm UTC](https://community.homey.app/t/p1-smartmeter-api/6150/82 "2020-07-13T14:06:15Z")

</div>

@robertklep  
See hereby the outcome when using minicom with the correct 9600 7 even settings:  
 ![Screenshot 2020-07-13 at 16.05.13](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/8/5/8544d1563b57f964be2651da82c95b9598bfcab5.png)

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

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [July 13, 2020, 2:09pm UTC](https://community.homey.app/t/p1-smartmeter-api/6150/83 "2020-07-13T14:09:41Z")

</div>

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](https://github.com/koktaildotcom/com.p1.smartmeter-dsmr.reader/blob/364e6c13c991e0e2c2307d9444413097414ca782/src/p1.js#L167):

```auto
console.log(telegram)

```

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

---

<div class="post-metadata">

**Author:** ![pssc92](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/pssc92/32/16562_2.png) [@pssc92](https://community.homey.app/u/pssc92)\
**Post date:** [July 13, 2020, 2:14pm UTC](https://community.homey.app/t/p1-smartmeter-api/6150/84 "2020-07-13T14:14:49Z")

</div>

Nothing seems to happen when adding the line.

![Screenshot 2020-07-13 at 16.13.15](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/8/b/8bceba0876c973ef4199748af51ddd4b25717fba.png)

![Screenshot 2020-07-13 at 16.13.26](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/d/0/d0517ef2f09a2a3e4974b9ada71152d60f78db95.png)

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [July 13, 2020, 2:19pm UTC](https://community.homey.app/t/p1-smartmeter-api/6150/85 "2020-07-13T14:19:06Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![pssc92](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/pssc92/32/16562_2.png) [@pssc92](https://community.homey.app/u/pssc92)\
**Post date:** [July 13, 2020, 2:22pm UTC](https://community.homey.app/t/p1-smartmeter-api/6150/86 "2020-07-13T14:22:26Z")

</div>

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&](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.

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [July 13, 2020, 2:24pm UTC](https://community.homey.app/t/p1-smartmeter-api/6150/87 "2020-07-13T14:24:41Z")

</div>

> [@pssc92](#):
>
> and with the wrong serial settings it is posting data even tough its incomplete.

I was interested in seeing the telegram data in _that_ situation 🙂 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.

---

<div class="post-metadata">

**Author:** ![pssc92](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/pssc92/32/16562_2.png) [@pssc92](https://community.homey.app/u/pssc92)\
**Post date:** [July 13, 2020, 2:30pm UTC](https://community.homey.app/t/p1-smartmeter-api/6150/88 "2020-07-13T14:30:06Z")

</div>

```
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:

 ![Screenshot 2020-07-13 at 16.29.18](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/3/0/3035f449828fb850ddb3f2047d3b5ea41f886a13.png)

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [July 13, 2020, 2:33pm UTC](https://community.homey.app/t/p1-smartmeter-api/6150/89 "2020-07-13T14:33:51Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![pssc92](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/pssc92/32/16562_2.png) [@pssc92](https://community.homey.app/u/pssc92)\
**Post date:** [July 13, 2020, 2:37pm UTC](https://community.homey.app/t/p1-smartmeter-api/6150/90 "2020-07-13T14:37:33Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [July 13, 2020, 2:44pm UTC](https://community.homey.app/t/p1-smartmeter-api/6150/91 "2020-07-13T14:44:43Z")

</div>

I wrote some very hacky ESP8266 code to publish just enough data over MQTT so the [DSMR Reader component of Home Assistant](https://www.home-assistant.io/integrations/dsmr_reader/) is able to process the data: [https://gist.github.com/robertklep/b94f6a48d46d9f8c633a6a5b5bf10123](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.

---

<div class="post-metadata">

**Author:** ![pssc92](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/pssc92/32/16562_2.png) [@pssc92](https://community.homey.app/u/pssc92)\
**Post date:** [July 13, 2020, 2:46pm UTC](https://community.homey.app/t/p1-smartmeter-api/6150/92 "2020-07-13T14:46:51Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Silvia](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/silvia/32/27970_2.png) [@Silvia](https://community.homey.app/u/Silvia)\
**Post date:** [August 3, 2020, 6:37pm UTC](https://community.homey.app/t/p1-smartmeter-api/6150/93 "2020-08-03T18:37:59Z")

</div>

Hello @Koktail ,

First of all thanks for the app! 🙂  
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.

 ![IMG_3172](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/d/e/de73303f39b261f7daefb9664962e485ab82b630.jpeg)

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

Thanks already for you help 🙂

---

<div class="post-metadata">

**Author:** ![Koktail](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/koktail/32/51498_2.png) [@Koktail](https://community.homey.app/u/Koktail)\
**Post date:** [August 4, 2020, 2:35pm UTC](https://community.homey.app/t/p1-smartmeter-api/6150/94 "2020-08-04T14:35:57Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Gerard](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/gerard/32/8846_2.png) [@Gerard](https://community.homey.app/u/Gerard)\
**Post date:** [August 24, 2020, 11:24am UTC](https://community.homey.app/t/p1-smartmeter-api/6150/95 "2020-08-24T11:24:08Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Gerard](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/gerard/32/8846_2.png) [@Gerard](https://community.homey.app/u/Gerard)\
**Post date:** [August 25, 2020, 11:29am UTC](https://community.homey.app/t/p1-smartmeter-api/6150/96 "2020-08-25T11:29:59Z")

</div>

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”  
> }  
> }

---

<div class="post-metadata">

**Author:** ![Koktail](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/koktail/32/51498_2.png) [@Koktail](https://community.homey.app/u/Koktail)\
**Post date:** [October 2, 2020, 7:57am UTC](https://community.homey.app/t/p1-smartmeter-api/6150/97 "2020-10-02T07:57:20Z")

</div>

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

> **[P1 Slimme meter](https://homey.app/nl-nl/app/com.p1/P1-Slimme-meter/)**
>
> P1 Slimme meter

---

<div class="post-metadata">

**Author:** ![Koktail](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/koktail/32/51498_2.png) [@Koktail](https://community.homey.app/u/Koktail)\
**Post date:** [October 30, 2020, 4:06pm UTC](https://community.homey.app/t/p1-smartmeter-api/6150/98 "2020-10-30T16:06:38Z")

</div>

I’ve just released an update 4.0.1 to test:

> **[P1 Slimme meter](https://homey.app/nl-nl/app/com.p1/P1-Slimme-meter/)**
>
> P1 Slimme meter

---

<div class="post-metadata">

**Author:** ![Sjoerd\_Boerhout](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/sjoerd_boerhout/32/32441_2.png) [@Sjoerd\_Boerhout](https://community.homey.app/u/Sjoerd_Boerhout)\
**Post date:** [December 28, 2020, 12:33am UTC](https://community.homey.app/t/p1-smartmeter-api/6150/99 "2020-12-28T00:33:03Z")

</div>

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

Unfortunately without any success. ☹

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](https://github.com/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](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 App for Homey | Homey](https://homey.app/en-au/app/com.p1/P1-Smartmeter/))

- Added the device

- No info showing in the app…

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

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

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.782_kWh)  
1-0:1.8.2(11318.303_kWh)  
1-0:2.8.1(00998.707_kWh)  
1-0:2.8.2(02222.371_kWh)  
0-0:96.14.0(0002)  
1-0:1.7.0(0000.00_kW)  
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.782_kWh)  
1-0:1.8.2(11318.303_kWh)  
1-0:2.8.1(00998.707_kWh)  
1-0:2.8.2(02222.390_kWh)  
0-0:96.14.0(0002)  
1-0:1.7.0(0000.00_kW)  
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.

---

<div class="post-metadata">

**Author:** ![Chillout](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/chillout/32/29997_2.png) [@Chillout](https://community.homey.app/u/Chillout)\
**Post date:** [December 28, 2020, 1:00pm UTC](https://community.homey.app/t/p1-smartmeter-api/6150/100 "2020-12-28T13:00:38Z")

</div>

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)

[Previous page](https://community.homey.app/t/p1-smartmeter-api/6150.md?page=4)

[Next page](https://community.homey.app/t/p1-smartmeter-api/6150.md?page=6)
