Transfer P1 energy reading through raspberry Pi (MQTT not registrering correctly)

Hello everyone,

I got a P1-USB (uart) cable to get readings from our energy meter (Landis+gyr E350) in preparation for getting some solar panels. There is a Raspberry Pi 3B+ next to the metering cupboard that has enough spare capacity to transfer this data to my NAS (elsewhere) running home assistant.

I have trouble with getting to register as an energy source. There are no statistics on the energy dashboard.

What I’ve tried
On Sunday I spent about 8 hours on this challenge to get the GitHub - svrooij/smartmeter2mqtt: Publish data from your Smart meter with a P1 interface to you MQTT server. smartmeter2mqqt node.js script working. (I had to reinstall the Pi 3 times. Python, PM2 and Docker problems). It is exporting data now and running as a systemd service. There is now a (secured) Mosquitto MQTT broker running too on the NAS.

This script doesn’t appear to pass state_class so home assistant doesn’t see it as an energy source? I can’t set it manually tho. Every time it updates (10 sec. interval) it gets reset?

I think the problem lies somewhere in here: smartmeter2mqtt/mqtt-output.ts at 022134797a1ba273f7fd28821f8baa8ad1de1713 · svrooij/smartmeter2mqtt · GitHub
Adding state_class: 'measurement' under the publishAutoDiscovery between unit_of_measurement and value_template doesn’t work. I’m afraid my programming knowledge is way too basic to troubleshoot this.

** Version information**

Today I did a complete clean install of home assistant (It was a glorified timer and remote switch for a lamp before this) 2022.09.1 in a HaOS VM. This because the TrueNAS plugin is discontinued and updating the plugin from a 2021 version to 2022.8 breaks the install completely. I also see the customize function in home assistant has been removed.

TLDR:
Can anyone help me to get this script working correctly?
or
Know of another program that can run on the Pi that does register correctly as an energy source with statistics?

Note: I can not install Docker on the Pi. It messes with ip-tables in a way that breaks the Pi’s primary function. The recommend fix doesn’t work and gets reset on reboot.

Thank you in advance for your time and help
Rick

I took a couple of days break to clear my head and started a new search (because all my search results were about running HA on a Rpi or this topic ironically). Ended up going through the whole dsmr tag on github and trying a few things. A script that works is:

I now have a working energy dashboard and can tell that the washing machine was turned on about 2 hours ago:

Hi,
Do you know if this will work with an IR Optical reader? I have a E350 but the only port i can access is the IR port.

To people arriving here from Google, there’s now an alternative to hansij66/dsmr2mqtt which is easier to configure and supports MQTT over TLS (MQTTS). It relies on a widely-used pre-existing DSMR P1 parser - the same one that the built-in “DSMR Slimme Meter” integration uses. Consequently it supports not only Dutch Smart Meters (versions 2.2 up to 5) but also Austrian, Swedish, Belgian and Hungarian DSMR variants, among others.

Here’s what shows up in Home Assistant (it has auto-discovery):