DSMR Reader Add-on for Home Assistant

what does ingress do?
if i have it turned on it is son steady text only think the web browser looks nicer or am i doing something wrong?

what does ingress add?
because everyone says it works great, I just don’t think it looks like it, but I have the idea that I’m doing something wrong.

Read back a few comments, DSMR Reader Add-on for Home Assistant - #252 by MrBlond and onward.

Just set the webserver to Ingress and see if you can open the app with the open the ui button.

2022-05-26: DSMR Reader Add-on v1.3.0, DSMR-reader v5.2
Changelog here

I got no new readings… the website is working but no actual data. I use a ip slimmemetergateway that I also have in Domoticz. with the same settings I see there new readings. but the addon gives me an error in the log. (this is after the update to 2022.06 i think (after the update dsmr reader got no new readings)

022-06-02 23:12:57,120 ERROR    mixins       run_once                        103 | dsmr_datalogger.management.commands.dsmr_datalogger: [!] Exception raised. Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/serial/urlhandler/protocol_socket.py", line 171, in read
    raise SerialException('socket disconnected')
serial.serialutil.SerialException: socket disconnected
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/app/dsmr_backend/mixins.py", line 92, in run_once
    self.run(data=self.data, **options)
  File "/app/dsmr_datalogger/management/commands/dsmr_datalogger.py", line 29, in run
    telegram = next(self.telegram_generator)
  File "/app/dsmr_datalogger/scripts/dsmr_datalogger_api_client.py", line 53, in read_telegram
    incoming_bytes = serial_handle.read(MAX_BYTES_PER_READ)
  File "/usr/local/lib/python3.10/site-packages/serial/urlhandler/protocol_socket.py", line 178, in read
    raise SerialException('read failed: {}'.format(e))
serial.serialutil.SerialException: read failed: socket disconnected

what can I do?

After months of flawless operation, my reader suddenly stopped working. I have tried re-installing the add-on, restarting the host, etc. But unfortunately that did not work out.

Config:

WEBSERVER: Ingress
DSMRREADER_ADMIN_USER: ****
DSMRREADER_ADMIN_PASSWORD: ****
DJANGO_DATABASE_NAME: dsmrreader
DJANGO_DATABASE_USER: postgres
DJANGO_DATABASE_PASSWORD: ****
DJANGO_DATABASE_HOST: 77b2833f-timescaledb
DJANGO_DATABASE_PORT: '5432'
DSMRREADER_REMOTE_DATALOGGER_MODE: standalone
DSMRREADER_REMOTE_DATALOGGER_API_HOSTS: http(s)://<YOUR_DSMR_HOST>:<PORT>
DSMRREADER_REMOTE_DATALOGGER_API_KEYS: <YOUR_API_KEY>
DSMRREADER_REMOTE_DATALOGGER_SERIAL_PORT: /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A13LNT9A-if00-port0
DSMRREADER_REMOTE_DATALOGGER_INPUT_METHOD: serial
DSMRREADER_REMOTE_DATALOGGER_SERIAL_BAUDRATE: '115200'
DSMRREADER_REMOTE_DATALOGGER_NETWORK_HOST: x.x.x.x
DSMRREADER_REMOTE_DATALOGGER_NETWORK_PORT: x
DSMRREADER_REMOTE_DATALOGGER_SLEEP: '3'
DSMRREADER_LOGLEVEL: ERROR
DJANGO_FORCE_SCRIPT_NAME: ''
DJANGO_STATIC_URL: static/
DATALOGGER_MODE: standalone
DATALOGGER_SERIAL_PORT: /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A13LNT9A-if00-port0
DATALOGGER_INPUT_METHOD: serial
DATALOGGER_SERIAL_BAUDRATE: '115200'
DATALOGGER_NETWORK_HOST: x.x.x.x
DATALOGGER_NETWORK_PORT: x
DATALOGGER_SLEEP: '0.5'

Error log:

RuntimeError: ('Failed to connect: {}', SerialException(12, "could not open port /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A13LNT9A-if00-port0: [Errno 12] Out of memory: '/dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A13LNT9A-if00-port0'"))
127.0.0.1 - - [04/Jun/2022:22:37:24 +0200] "GET /about HTTP/1.1" 200 19065 "-" "curl/7.80.0" "-"
127.0.0.1 - - [04/Jun/2022:22:37:29 +0200] "GET /about HTTP/1.1" 200 19065 "-" "curl/7.80.0" "-"
Starting DSMR Reader - datalogger...
Current logging level set to "ERROR". More information can be found here: https://dsmr-reader.readthedocs.io/en/latest/how-to/troubleshooting/enabling-debug-logging.html
127.0.0.1 - - [04/Jun/2022:22:37:35 +0200] "GET /about HTTP/1.1" 200 19065 "-" "curl/7.80.0" "-"
2022-06-04 22:37:35,334 ERROR    mixins       run_once                        103 | dsmr_datalogger.management.commands.dsmr_datalogger: [!] Exception raised. Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/serial/serialposix.py", line 322, in open
    self.fd = os.open(self.portstr, os.O_RDWR | os.O_NOCTTY | os.O_NONBLOCK)
OSError: [Errno 12] Out of memory: '/dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A13LNT9A-if00-port0'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/app/dsmr_datalogger/scripts/dsmr_datalogger_api_client.py", line 37, in read_telegram
    serial_handle = serial.serial_for_url(url=url_or_port, timeout=MAX_READ_TIMEOUT, **serial_kwargs)
  File "/usr/local/lib/python3.10/site-packages/serial/__init__.py", line 90, in serial_for_url
    instance.open()
  File "/usr/local/lib/python3.10/site-packages/serial/serialposix.py", line 325, in open
    raise SerialException(msg.errno, "could not open port {}: {}".format(self._port, msg))
serial.serialutil.SerialException: [Errno 12] could not open port /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A13LNT9A-if00-port0: [Errno 12] Out of memory: '/dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A13LNT9A-if00-port0'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/app/dsmr_backend/mixins.py", line 92, in run_once
    self.run(data=self.data, **options)
  File "/app/dsmr_datalogger/management/commands/dsmr_datalogger.py", line 29, in run
    telegram = next(self.telegram_generator)
  File "/app/dsmr_datalogger/scripts/dsmr_datalogger_api_client.py", line 39, in read_telegram
    raise RuntimeError('Failed to connect: {}', error)

Can you tell more about your setup? Did you try uninstalling and reinstalling the addon?

From the log it seems it can’t connect to the usb device, can you try the usb device directly instead (something like /dev/ttyUSB0) of it’s id?

I have uninstalled reinstalled. And tested with ingress and normal.
In my config there is a USB but I use ipv4 slimme metergateway. Maybe my config can help?
I can’t remember that I have changed something and because of that I don’t know the config from last month…

WEBSERVER: Standard
DSMRREADER_ADMIN_USER: admin
DSMRREADER_ADMIN_PASSWORD: admin
DJANGO_DATABASE_NAME: dsmrreader
DJANGO_DATABASE_USER: postgres
DJANGO_DATABASE_PASSWORD: homeassistant
DJANGO_DATABASE_HOST: 77b2833f-timescaledb
DJANGO_DATABASE_PORT: ‘5432’
DSMRREADER_REMOTE_DATALOGGER_MODE: standalone
DSMRREADER_REMOTE_DATALOGGER_API_HOSTS: http://192.168.0.9:7777
DSMRREADER_REMOTE_DATALOGGER_API_KEYS: 31M84RW1MCZDOFTVKU2GWPIS72H55G5TXQMGC2R8MM8DJ30OLOTP6INAZ2EZT6YI
DSMRREADER_REMOTE_DATALOGGER_SERIAL_PORT: /dev/ttyUSB1
DSMRREADER_REMOTE_DATALOGGER_INPUT_METHOD: ipv4
DSMRREADER_REMOTE_DATALOGGER_SERIAL_BAUDRATE: ‘115200’
DSMRREADER_REMOTE_DATALOGGER_NETWORK_HOST: 192.168.0.82
DSMRREADER_REMOTE_DATALOGGER_NETWORK_PORT: ‘23’
DSMRREADER_REMOTE_DATALOGGER_SLEEP: ‘0.5’
DSMRREADER_LOGLEVEL: ERROR
DJANGO_FORCE_SCRIPT_NAME: ‘’
DJANGO_STATIC_URL: static/

After some more research, in the host log I found:

[1354263.894274] xhci-hcd xhci-hcd.8.auto: Ring expansion failed
[1354263.898730] ch341-uart ttyUSB1: usb_serial_generic_submit_read_urb - usb_submit_urb failed: -12

So would this be a host issue?

Did you try /dev/ttyUSB0 or /dev/ttyUSB1? What is your setup? HA OS on hardware or in VM?

I see that you specified some settings like ‘DSMRREADER_REMOTE_DATALOGGER_API_HOSTS’ which you don’t need.

As you are using a remote datalogger which sends data over to this addon, please reset the settings of the addon, configure your db settings, set the mode to receiver and open up the port in the network settings of the addon.

In the admin ui, you need to activate the API and get the KEY.

Then in the ‘slimme metergateway’ you configure the correct HA ip + port you opened up (7777?) and the KEY.

I’m on vacation. But emptied the fields, you said. The website is working, but no new meters and same error.
The gateway is working on the 82 up and port 23.

Any other ideas?

Updated Dockers. Rebooted the host and removed USB in dsmrreader and configuration. Then I changed to dsmr 2.x instead of 4/5. Was the key!

Thanks for support, you are great.

Hi, I would like to recalculate the prices but I can’t get it to change.

When I try to do it with ssh I get the following error: django.db.utils.OperationalError: could not translate host name “dsmrdb” to address: Name does not resolve
I use this command: python manage.py dsmr_stats_recalculate_prices
When I do this using portainer I get the same error.

Can someone point me in the right direction.

For me it would be a lot easier to have a button in the webinterface.

Appeared to be an USB issue related to the host: Home Assistant OS Release 8 - #93 by Roekeloos

The issue persists after updating to the newest OS version. I found out that when I reboot the host (so not just HA), the reader is working again. That is also the reason why I thought that updating the OS solved the issue. But after some time (in this case a few days), the above error appears again and the DSMR reader stops working.

This does not seem to work anymore… Current version: 1.6.0

I see some errors running the . /etc/cont-init.d/01-set-hassio-vars command (but it runs to quickly and i cannot scroll the log).
When running the python manage.py dsmr_stats_recalculate_prices after that i get:

Can anyone give instructions how to re-calculate on the latest version?

hi S2nder

I managed to install Dsmr-reader docker on a remote synology , and just install the logger add-on on HA.
tx again, data is coming in ! :slight_smile:
note that where I am, Tarif 1 is high, and 2 is low… can I change this somewhere? (I found u can create contracts, but not change the daskbpard, daltarief, … ?)

tx !!!

1 Like

Should be fixed with 1.6.1, see hassio-addons/dsmr_reader at master · sanderdw/hassio-addons · GitHub for updated instuctions (use . /cli-helper.sh )

Not sure what you need to change but you can merge the high and low tarifs together by setting the option in the admin page (interface configuration).