Support for Dutch Smart Meter

Hello,

Since this week I own a Intel Nuc for Home Asssistant.
And I can’t get P1 to Work!

After some years using (micasaverde) GetVera, I decided to leave the Vera and started with Home Assistant. First I have tested it on a Rpi3.
And I realy love it!

Since this week I am migrating devices to my Home Assistent. It is installed on a (Docker) Intel Nuc.
But right now I can’t get the P1 to show up in Home Assistant.

What I did ?
Read this forum :wink:
And this is what I got right now:

In my configuration:

sensor:
-platform: dsmr
host: /dev/ttyUSB0
dsmr_version: 2.2

I have checked that the P1 is connected:

ls /dev/tty
/dev/ttyACM0 (Z-wave stick)
/dev/ttyUSB0 (USB)

So I know I have the P1 connected to P1.

When I use the Dsmr console as mentioned before I see the output from P1
So I have a connection! Why does Home Assistant display anything?

I have checked in portainer that my USB is forwarded.
At least I think so. This is my first experience with Docker :sweat_smile:
I try to get my why trought this in Portainer.

I realy would like to know how to debug my problem?

In my log I found this:

CitaatLog Details (ERROR)
Mon Sep 30 2019 20:14:53 GMT+0200 (Midden-Europese zomertijd)
Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/components/dsmr/sensor.py”, line 138, in connect_and_reconnect
transport, protocol = await hass.loop.create_task(reader_factory())
File “/usr/local/lib/python3.7/asyncio/base_events.py”, line 905, in create_connection
type=socket.SOCK_STREAM, proto=proto, flags=flags, loop=self)
File “/usr/local/lib/python3.7/asyncio/base_events.py”, line 1275, in _ensure_resolved
proto=proto, flags=flags)
File “/usr/local/lib/python3.7/asyncio/base_events.py”, line 784, in getaddrinfo
None, getaddr_func, host, port, family, type, proto, flags)
File “/usr/local/lib/python3.7/concurrent/futures/thread.py”, line 57, in run
result = self.fn(*self.args, **self.kwargs)
File “/usr/local/lib/python3.7/socket.py”, line 748, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -8] Unrecognized service

What am I missing and what is the best way to find out what’s going on?

@A.Ardon can you share your docker (-compose) lines that starts HA in a container?
Are you running from Windows or do you have a specific Linux distro running?

Edit: your host line in configuration.yaml is wrong. Can you remove it? Comment it out and restart HA?

@RezzZ i have commented it out, ,and now its works!
I thought I had to specify the host. (I still have a lot to learn about HA)
Thank you.

happy to help. Now that that is working you probably need to ask yourself why you want your dsmr reader attached to HA. HA is terrible at keeping history and the only reason I can think of of reading out your smart meter is to keep track of your power and gas usage over time and compare months/years etc.

For that reason you might consider moving the reading of your p1 port to a better alternative like dsmr-reader or domoticz

these programs are way better at keeping and displaying history and the can always publish the stats it reads via MQTT so that you can still see the values in Homeassistant.

You can run any of these tools in a different docker container on your Nuc.

… or for a solution which is not specific to only your energy data, you can install influx and grafana which are very easy to set up with HA and then you get the history and graphing of any data you want in HA.
Concerning domoticz, you still have the problem of data retention since it will not keep the data more than a year (i.e. you can compare this year with the previous year and no more) so if you want data for several years it s not a solution. I’ve never used dsmr-reader so cannot say for that one.

true, influx grafana works as well. dsmr-reader is a more out of the box solution. no need (or possibility) to create reports and dashboard. You can also do both :). Use dsmr-reader, publish telegrams via mqtt to homeassistant, store data in influxdb and create additional reports. For now I’m very happy with the move of the p1 meter outside of HA (did the same with my zwave controller).

until last week I had 2 VeraPlus controllers and 3 Raspberry Pi’s. But GetVera’s UI many times react’s to slow. I have found out that H.A. reacts much faster.

For now my goal was to keep 1 Rpi3 for Domotics to collect data from my Remeha Boiler and a Netatmo Script. I want to keep one VeraPlus for collecting data from my Powermax+. In the future when I understand H.A. better I want to store every thing in H.A. on my Intel NUC.with Ubuntu 19.04 and remove all Vera’s.

I am using influxdb and Grafana to store all the data in a seperate container.
It stores data from the Remeha Tzerra, P1 (dsrm) Netatmo and now Home Assistant.
My NUC is standing in front of the smart meter so it is simple for me to connect trough USB with H.A.
I want the actual P1 data tot be visble in Home Assisttant,and store them in influxdb. Thats why I thought this would be a correct way to connect the P1 to H.A.

If I run into problems I always can think about using dsmr-reader or domoticz. I will keep it in mind.

Hi,

I copied the the original dsmr components and created a custom component. I did this to change some names and icons and also added some more information to read from the meter. The dsmr component use dsmr parser and the parser is reading more information like phase current and short power failure.

Now i like to change my current energy value from kwh to wh. So i have to multiply it by 1000 somewere in the component. But i dont know where. Is there anyone who knows this?

create a template sensor:

- platform: template
  sensors:
    power_consumption_w:
      value_template: "{{ ((states.sensor.power_consumption_current.state | float) * 1000) | round(0) }}"
      unit_of_measurement: 'W'
      friendly_name: "Power Consumption Current"

Following the steps described above by conradhConrad Hagemans I have translated almost everything in Dutch. Thanks Conrad!

Now I am struggling to translate the tariff status ‘normal’ and ‘low’ too. In Dutch it should be ‘normaal’ and ‘laag’. Anyone succeeded doing this and willing to advice me how?

ik denk zoiets:

stroom_tarief:
  friendly_name: Stroom Tarief
  value_template: '{% if is_state('sensor.power_tariff', 'normal') %}normaal{% else %}laag{% endif %}'
  icon_template: mdi:flash

Thanks for helping, bedankt! Can you be more specific? I have tried your solution and several variations but it did not work. And must such code be placed in configuration.yaml or customize.yaml?

you mentioned conradhConrad in your post so its just the same as there. Just add it like you did with those template sensors.
the full syntax is:

- platform: template
  sensors:
    stroom_tarief:
      friendly_name: Stroom Tarief
      value_template: '{% if is_state('sensor.power_tariff', 'normal') %}normaal{% else %}laag{% endif %}'
      icon_template: mdi:flash

edit: depending on your setup of your configuration.yaml file you either put it there with your other sensors, or if you keep your sensors in a separate yaml file add it there. It’s not a customization.
edit2: syntax might differ a bit for your configuration.
My setup is to use several yaml files for sensors in my sensors folder. configuration.yaml has the line:
sensor: !include_dir_merge_list sensors
and my files have above syntax

1 Like

Thanks Rene, would not be a problem to succeed this weekend with this information.

Hi, i recently got the Belgian smart meter from Fluvius, it’s a Sagemcom S211.
I hooked it up to my RPI3B+ running homeassistant in a docker container.

I mapped the /dev/ttyUSB0 to the container and configured the sensor. My electricity readings are coming in nicely. Only my gas consumption is currently unknown.

I guess this is related to a topic I found for Domoticz.
https://www.domoticz.com/forum/viewtopic.php?t=29255

Apparently in Belgium the implementation is a little bit different than the Netherlands.
I also found this document with some of the specs…

Any idea if it would be possible to support my DSMR as well?

Here (https://github.com/TradeFace/smmqtt) my small program to read a smartmeter with a cheap ttl to usb module. Maybe this solution is also useful to someone else.

Since DSMR-reader has builtin mqtt support, whats the advantage of using your mqtt script?
Eager to learn what i’m missing here.

Regards,
Passie

smmqtt is a small implementation which doesn’t require much resources of your Pi. (max 5mb, from what I have seen) Further processing of data can be done in HA. For instance comparing your electicity input/output to the numbers you get from your solar system. Moreover it can read a smart meter with a $2 usb module, instead of paying $20 for a cable.

I don’t know DSMR-reader, smmqtt is just my solution to the problem I had. It might come in handy for someone else.

3 Likes

Instead of connecting the smart meter directly to a PC/Raspberry Pi I’ve created a small program that
runs on a Wemos D1 ESP8266 module. The ESP module gets it’s power from the P1 port of the smart meter.

Every second the smart meter sends a telegram to the ESP module. This data is cached by the ESP module and is sent to my local MQTT server every 30 seconds (setting).

So it’s in fact a wireless P1 <-> MQTT module. The serial signal of the P1 smart meter is inverted so you either have to invert it using hardware (like I did) or use the SoftwareSerial library to do this in software.

If someone is interested I can share this code. I grabbed the decoding of the P1 telegram / CRC calculation from the internet so I’m not sure if it works for all kinds/versions of smart meters.

5 Likes

That looks nice. If you won’t mind please share your source-code and the hardware connections (soldering) you used.
Currently my DSMR isn’t able to connect to it via the tcp port and therefore i’m using a work-around.
I have multiple ESP8266 in house so i’m happy to test this.

Looking forward to it.

regards,
Passie