xirixiz / dsmr-reader-docker

DSMR Reader in Docker.
https://hub.docker.com/r/xirixiz/dsmr-reader-docker
113 stars 33 forks source link

Container can only start if serial device is on ttyUSB* #310

Closed golles closed 1 year ago

golles commented 1 year ago

Support guidelines

I've found an issue and checked that ...

Description

Since the latest release, the serial port needs to be on a ttyUSB* port, commit: de0cec303a71445efe505f9b2549b90db0cf97a1

Getting this error: https://github.com/xirixiz/dsmr-reader-docker/blob/master/rootfs/etc/cont-init.d/20-set-app-defaults#L84

Expected behaviour

The container deals with serial devices on other locations than ttyUSB

Actual behaviour

The container can only start when I set the serial device on a ttyUSB*

Steps to reproduce

See docker-compose below

Docker info

NA.

Version

Docker compose

dsmr:
    container_name: dsmr
    image: xirixiz/dsmr-reader-docker:latest
    restart: unless-stopped
    depends_on:
      - postgres
    volumes:
      - /etc/localtime:/etc/localtime:ro
    environment:
      - DJANGO_TIME_ZONE=${TZ}
      - VIRTUAL_HOST=localhost
      - DSMRREADER_ADMIN_USER=${DSMRREADER_ADMIN_USER}
      - DSMRREADER_ADMIN_PASSWORD=${DSMRREADER_ADMIN_PASSWORD}
      - DJANGO_DATABASE_HOST=${DJANGO_DATABASE_HOST}
    ports:
      - 7777:80
    devices:
      - /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_AQ4KS8IA-if00-port0:/dev/dsmr

Container logs

Haven't stored any logs

Additional info

No response

xirixiz commented 1 year ago

More info: https://github.com/xirixiz/dsmr-reader-docker/issues/309

xirixiz commented 1 year ago

Ah ok, sorry. What you could do is map to /dev/ttyUSB0 instead of /dev/dsmr. I'll fix it in a new release. Odd thing is that it already was in past releases actually...

https://github.com/xirixiz/dsmr-reader-docker/blob/73530e2039e263425594ca99accd8a54b02b40e7/rootfs/etc/cont-init.d/20-set-app-defaults#L133

Quick fix:

    devices:
      - /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_AQ4KS8IA-if00-port0:/dev/ttyUSB0
golles commented 1 year ago

That is indeed what I did (and why I no longer had the error logs :-) )

I haven't seen this before, and I have the latest version and update usually a few times per week.

Thanks

xirixiz commented 1 year ago

New release is coming: https://github.com/xirixiz/dsmr-reader-docker/actions/runs/3686579928

It now validates whatever you specify for:

${DSMRREADER_REMOTE_DATALOGGER_SERIAL_PORT}

So in your case you should provide this env var with /dev/dsmr

pyrocumulus commented 1 year ago

I have set my container to be a DSMR receiver with:

DSMRREADER_REMOTE_DATALOGGER_MODE=receiver

However with this new version I am unable to start the container. It keeps looking for USB devices, even if I set the aforementioned env var. It get this in the logs:

[ INFO ] Checking for CLIENT CERTIFICATE AUTHENTICATION configuration...
[ INFO ] ENABLE_CLIENTCERT_AUTH is disabled, nothing to see here. Continuing...
[ INFO ] Checking for NGINX SSL configuration...
[ INFO ] ENABLE_NGINX_SSL is disabled, nothing to see here. Continuing...
[ INFO ] Checking for HTTP AUTHENTICATION configuration...
[ INFO ] ENABLE_HTTP_AUTH is disabled, nothing to see here. Continuing...
[ INFO ] Configuring DSMR Reader to run all processes in a single container with a serial or ipv4 datalogger...
[ INFO ] Using a serial connection for the DSMR Reader remote datalogger...
[ INFO ] Fixing /dev/ttyUSB* security...
[ FAIL ] Device /dev/ttyUSB* not found. Exiting...

It's clearly saying "using serial connection" but that's not what I want, as I've set it to receiver. It will never find a serial device on the system DSMR is hosted on. The serial data is coming from a different place in my network.


I see this issue now https://github.com/xirixiz/dsmr-reader-docker/issues/303. However I cannot reach those mentioned settings, because my container is in an infinite reboot loop. I always used the receiver mode, because I have a different device with a datalogger script that uses the API to push telegrams in this container. I do not use network sockets or something like that. I just want to disable the datalogger in this container.

How do I do that?

xirixiz commented 1 year ago

Hi, if you look at the readme on the main page it should become clear. You need to use api_server now instead of receiver as there we're a lot of questions and unclarities with the previous setup(s) (sender, receiver...)

pyrocumulus commented 1 year ago

As you replied I just found that info in the readme indeed. It's getting hard to keep up with these kinds of changes :) I will try it when I get home from work.

Just for future reference, is there somewhere I can read these kinds of backwards incompatible changes before updating? Because it's quite some work going through all the commits and figuring out if something will break when I update the container. This is the second time that the way of telling the container it should not try to run the datalogger itself, has changed in an incompatible way.

Or perhaps it would be wise to also have backwards compatible mappings for these kinds of situations (like mapping the old value of "receiver" to "API_SERVER"). I know it's difficult because you are only wrapping another package (DSMR Reader) but I feel it could be a bit more smooth.

xirixiz commented 1 year ago

Yes, working on it. I will create releases in GH in the future, so release notes are visible there.

It's api_server btw... lowercase ;). Updated the README

pyrocumulus commented 1 year ago

Excellent! I'll update my docker-compose tonight and let you know if it works. But I think this is the thing that's causing issues so I think it'll be all right.

megapearl commented 1 year ago

I'm having the same problem, changed the env to 'api_server' but it is still in a reboot loop.

Updating password of superuser "admin"
Deactivating any other existing superusers

[ INFO ] Checking for CLIENT CERTIFICATE AUTHENTICATION configuration...

[ INFO ] ENABLE_CLIENTCERT_AUTH is disabled, nothing to see here. Continuing...

[ INFO ] Checking for NGINX SSL configuration...

[ INFO ] Required files /etc/ssl/private/fullchain.pem and /etc/ssl/private/privkey.pem exists.

[ INFO ] SSL has already been enabled...

[ INFO ] NGINX SSL configured and enabled

[ INFO ] Checking for HTTP AUTHENTICATION configuration...

[ INFO ] ENABLE_HTTP_AUTH is disabled, nothing to see here. Continuing...

[ INFO ] Configuring DSMR Reader to run all processes in a single container with a serial or ipv4 datalogger...

[ INFO ] Using a serial connection for the DSMR Reader remote datalogger...

[ INFO ] Fixing /dev/ttyUSB0 security...

[ FAIL ] Device /dev/ttyUSB0 not found. Exiting...
[cont-init.d] 20-set-app-defaults: exited 1.
[cont-finish.d] executing container finish scripts...
[cont-finish.d] done.
[s6-finish] waiting for services.
[s6-finish] sending all processes the TERM signal.
[s6-finish] sending all processes the KILL signal and exiting.
[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 10-adduser: executing... 
usermod: no changes
-------------------------
User UID: 1019
User GID: 104
-------------------------
[cont-init.d] 10-adduser: exited 0.
[cont-init.d] 20-set-app-defaults: executing... 

[ INFO ] DSMR Reader Reader release: 5.9.0

[ INFO ] DSMR Reader Reader Docker release: 2022.12.02

[ INFO ] Ensure permissions...

[ INFO ] Setting architecture requirements...

[ INFO ] X64 Architecture

[ INFO ] Verifying if the DSMR Reader web credential variables have been set...

[ INFO ] Verifying database connectivity to host: postgresql.flissinger.com with port: 5432...

[ INFO ] Database connectivity successfully verified!

[ INFO ] Running post configuration...
Operations to perform:
  Apply all migrations: admin, auth, contenttypes, dsmr_api, dsmr_backend, dsmr_backup, dsmr_consumption, dsmr_datalogger, dsmr_dropbox, dsmr_frontend, dsmr_influxdb, dsmr_mindergas, dsmr_mqtt, dsmr_notification, dsmr_pvoutput, dsmr_stats, dsmr_weather, sessions
Running migrations:
  No migrations to apply.
0 static files copied to '/var/www/dsmrreader/static', 559 unmodified.
puijken commented 1 year ago

PEBKAC here .. it works fine as documented.

xirixiz commented 1 year ago

DSMRREADER_REMOTE_DATALOGGER_MODE=receiver

The env name has also changed:

DSMRREADER_OPERATION_MODE=api_server
megapearl commented 1 year ago

The documentation is unclear for me. I had set the DSMRREADER_REMOTE_DATALOGGER_MODE to api_server but that didn't work out. I removed that line and added:

DSMRREADER_REMOTE_DATALOGGER_MODE=api_server

And that is working, but I can't find it in the documentation.

puijken commented 1 year ago

Like xirixiz said, you have to replace the environment variable: So replace DSMRREADER_REMOTE_DATALOGGER_MODE=receiver with DSMRREADER_OPERATION_MODE=api_server

I had the same "issue" so PEBKAC :)

pyrocumulus commented 1 year ago

Container is running again. Problem is solved now.