Support for reading Dutch Smart Meter (electricity/gas) (P1 port)

All Dutch electricity/gas meters are beiing replaced by digitale smart meters with P1 support. The P1 port is effectively a serial interface (RS232) which send statistical data every 10 seconds. (DSMR protocol)

Domoticz and OpenHAB already both support the system. Lack of support is for me the only reason not to switch to home assistant.

Specifications:
http://files.domoticaforum.eu/uploads/Smartmetering/DSMR%20v4.0%20final%20P1.pdf

OpenHAB: https://github.com/openhab/openhab/wiki/DSMR-binding

Hey Henk. Klasse manier van vragen om support. ā€œEnige reden dat ik niet switch is omdat jullie het niet supportenā€ met wat linkjes erbij.
Zitten veel cool gasten op deze bbs die hun vrije tijd opofferen omdat platform nog beter en uitgebreidere qua ondersteunde protocollen te maken.

What Henk is asking here is if we would be so kind and look into incorporating this feature into HA.
I have dabbled with P1 in the past for a smart router solution so might anyone need writeups PM me.

3 Likes

Iā€™m also interested in dutch smartmeter support (DSMR 4.* via P1 port) for Home Assistant.
I just switched from domoticz to HA and this is one of the things iā€™m missing.

I searched for a python implementation of the DSMR 4. standard via serial and found these https://github.com/CurlyMoo/RaspberryPi-P1-port/tree/master/server (untested)
http://gejanssen.com/howto/Slimme-meter-uitlezen/P1uitlezer.py (tested but crashes on some sort of type conversion).

Iā€™m no code wizard and new to Home Assistant so iā€™m probably not going to come up with something that worksā€¦ hope that someone with more experience looks into this.
Iā€™m willing to test though.

1 Like

same here, would be nice to have.

1 Like

Im using this for now:

After some thinking I started wondering what the use case will be for this in home assistant?
Trigger automations on energy or gas usage ?
For now I graph everything in grafana.

True, not much use for automation indeed, but would be nice to an overview of my energy consumption in HA.

I think this is incredible usefully to have in HA. I use it a lot in my current vera setup and would love to see if in HA

Is there anyone that can create a component for This?

What do you actually do with it? What kind of automations do you trigger based on your P1 readings?

For me the most important one I use now when it comes down to automation is notification when there is unexpected usage. Actually just saved me as we are on holiday and my gas consumption suddenly jumped to 300 l/h. Turned out there was something wrong with the hvac system and I had someone fix it while I was gone. Based on the usage I can even see if my hottub is on or other high usage appliances as p1 is almost real-time (10 sec intervals)

Next to automation itā€™s just super usefull to have all energy consumption in your home automation system.

for graphing iā€™m using grafana at the moment with an influx db.
Home - Assistant is for automation >> i get the use case where you get notified when you have excessive energy usage etc. but for insights i use grafana
(comparing outside temperature to gas usage or under floor heating temps v.s. central heating burner on /off usage )

2 Likes

Looks nice!

However disagree with your statement about ā€˜automationā€™ versus insights.

HASS already has a lot of components that are about insights and/or are not focussed on automation (cameraā€™s & history components just to name a few). And what about the existing energy components that roughly do the same (show current energy consumption). Furthermore where is the ā€˜borderā€™ between the two? Why is showing that someone is at work on a dashboard different then for instance current consumption? Itā€™s in insight that makes me more consious of the energy Iā€™m using (beside the triggers talked about earlier).

FYI; all major HA systems have P1 support; Homeseer, Vera, OpenHab, Domoticz, Fibaro homecenter just to name a few.

Ha I arrived here just in time! I love HA, and just ordered the ā€˜smart meterā€™ P1 cable, and intend to use it on my Raspberry Pi. I do some coding but am a noob in Python ans having very little free time, yet i would see If I can get something started.

Iā€™m not really looking to use the metric as a trigger, but just for insights.

It looks this would be a typical sensor, but with multiple outputs:

I donā€™t know about where to store the historical data yet, nor how to create an (interactive graph) but I guess the HA database should suffice for storage, and looking at the CPU graphs I guess some custom graphs should be achievable.

Just to show itā€™s not all talk, I started a new branch from the dev branch of my fork, named ā€˜smartmeterā€™ and added a new highly untested sensor:
https://github.com/Atrejoe/home-assistant/commit/ae08cf15393ad023e1393d18e19cd91a7bcc86b0

1 Like

Home Automation is more than only creating events. Its about getting access on whats going on in your home and of course garden :wink:

That means getting acces to your energy consumption. Main goal next to comfort is getting your energy bill low but not willing to let you lose some comfort. So if using x amount of energy in a month or day, but the a month later your using twice the amount of energy you should investigate what happend.

So my main goal of automation is getting a view of what energy i am using and getting the electricity bill lower and getting a comfort home in a automatic wayā€¦

So yes getting a insight of my energy consumption is an part of my home automation.

1 Like

@Atreyu Great work and many thanks so far!

Ready to try this. As Iā€™m fairly new to HASS, how can I test this?

So for I have just gotten the basic readout to work (outside of the HASS ecosystem), there are some meter-specific connection settings Iā€™d have to incorporate in the HASS config.
For now I intend to use smeterd for reading the data, but I have a connection issue I have to resolve first (https://github.com/nrocco/smeterd/issues/7)

Iā€™m too very new to HASS development or even Python, but I think this is a nice introductory project.

My code hase not been tested yet in any way. This is just a draft of the data model, inspired by the HASS development tutorial and some other components.

This an evening project fo me, so my work on it might be a bit sporadic.

@Tyfoon do you have any coding experience and wish to contribute?

@Atreyu
change line 78 in meter.py to this:

if ā€˜!ā€™ in line and len(lines) > max_lines:

then the meter.py will work with your baud rate setting.
I think it has to do with the DSMR 4.* versus 2.2 telegrams.

i also changed line 56 to 30 instead of 13 because DSMR 4.0 consists of 30 lines instead of 13.
Looking at the output iā€™m getting it look like the gas totals donā€™t work ā€¦

@koen01 I do get some output from the gas meter (reading your telegram, I think you do too, why do you think yours donā€™t work?:

0-1:24.2.1(160905220000S)(00323.619*m3)

Maybe itā€™s better to continue the discussuion regarding this component over at Github. When we get back to integrating into HASS, return here.

(My telegram has 33 lines)

Small progress report: I managed to get a development environment (Windows, Visual Studio) set up and familiarized myself with the basics of configuration and reporting data through entities.

The component used as an abstraction layer to read the meter has just been updated to incorporate my meter, so I hope to get this setup running on my Pi soon (as my dev machine is nowhere near my meter), in order to actually read the meter.

Next steps:

  1. Actually read the meter
  2. Either detect reportable values (not every home has the same reportable data), make them configurable or both
  3. Could an interactive graph be achievable? I would like to report for various periods (now, last x weeks, months years)
1 Like

@Atreyu
In your github I see you are making good progress. Hope the smeterd update will help you further in developing this component.

I have also been working on an implementation, can be found here: https://github.com/home-assistant/home-assistant/pull/4309

1 Like