DSMR Reader Add-on for Home Assistant

Was Home Assistant rebooted because of the fuse blow? Most likely the USB port has changed then so try to configure this again. See DSMR Reader Add-on for Home Assistant - #326 by gcoupe as an example.

Yeah, checked that already. Configured the usb adapter by ID, so that didn’t 2022-12-27 09:35:08,515 ERROR mixins run_once 107 | dsmr_datalogger.management.commands.dsmr_datalogger: [!] Exception raised. Traceback (most recent call last):
File “/app/dsmr_backend/mixins.py”, line 96, 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 51, in read_telegram
raise RuntimeError(
RuntimeError: It took too long to detect a telegram. Check connection params. Bytes currently in buffer: 12
Starting DSMR Reader - datalogger…
127.0.0.1 - - [27/Dec/2022:09:35:15 +0100] “GET /about HTTP/1.1” 200 15871 “-” “curl/7.83.1” “-”
Current logging level set to “ERROR”. More information can be found here: Troubleshooting: Enable DEBUG logging — DSMR-reader v5 documentation’’’

Mmm, block quotes from iphone are not ideal…:smiley:

Yes using an id normally should prevent these kind of issues but try to unplug, reboot, plug it again anyway and use the raw usb port to see if it helps.

Hi,

I am new to HA and need some advise.
I want to gain insight in my energy consumption (gas + electricity) by using HA.
I am looking into two possible solutions:

  1. DMSR Reader add-on + DSMR Reader integration
  2. DSMR Slimme Meter integration

Can someone explain me the difference between the two options and give a recommendation?
Is the first option not duplicating the amount of data from the DSMR Reader db to the HA db?
Can both options be used by the HA energy dashboard?

I am thinking about buying an ODROID N2+ device with 128GB eMMC storage for it.
Would that setup work, or is an Intel NUC + SSD needed? The latter would use more power, so is not my initial choice.

Thanks for your help.

Yes with both options you can use the itegrated HA energy dasboard.

With option 1 - DMSR Reader add-on you have all the extra functionality of About DSMR-reader — DSMR-reader v5 documentation such as cost insights by adding your energy contract(s).
With option 2 you are limited to the functionality of the HA energy dashboard.

As for hardware, eMMC storage is sufficient for both options.

Sander,

Thanks for your effort, got it back working again. Did not change anything in the setup, but several reboots made it pop up again…

One other question: recently moved to another new energy companies in NL: Tibber. I dont think there is support for hourly changing tariff in DSMR right now, am i right?? Any ways to get accurate data for daily costs that you know of??

Thanks in advance,
D

Hi,

is there a way to provide non Admin Ha users access to dsmr reader?
thanks in advance

Hi Sander,

I want to change the default password in the DSMR-reader configuration UI (link in top right corner).
After I changed my password then the login works with the new password.
However after a reboot then the new password doesn’t work anymore and I have to use the default one again.
Is this normal? Or can it be fixed?
Thanks,
Jeroen

Yes, to make it persistent just change it in the addon configuration page.

Hi Sander,

Is there a possibility to update the add-on from DSMR-reader version 5.9 to 5.10.3 ?
Thanks in advance!

Have a small delay releasing the new version due to some CI/CD issues. Hopefully in a day or two.

2023-02-15: DSMR Reader Add-on v 1.10.1, DSMR-reader v5.10.3
Changelog here

2 Likes

Thanx a lot Sander!

For me the latest update seems to not work properly and throws some errors:


Server Error
Sorry, something unexpected happened.
Exception:

ProgrammingError: column dsmr_datalogger_dataloggersettings.dsmr_extra_device_channel does not exist
LINE 1: ...mr_datalogger_dataloggersettings"."dsmr_version", "dsmr_data...
                                                             ^

Traceback:

  File "/usr/local/lib/python3.11/site-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/usr/local/lib/python3.11/site-packages/django/views/generic/base.py", line 70, in view
    return self.dispatch(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/app/dsmr_frontend/mixins.py", line 11, in dispatch
    return super().dispatch(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/usr/local/lib/python3.11/site-packages/django/views/generic/base.py", line 98, in dispatch
    return handler(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/usr/local/lib/python3.11/site-packages/django/views/generic/base.py", line 159, in get
    context = self.get_context_data(**kwargs)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/app/dsmr_frontend/views/dashboard.py", line 17, in get_context_data
    context_data["datalogger_settings"] = DataloggerSettings.get_solo()
                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/usr/local/lib/python3.11/site-packages/solo/models.py", line 55, in get_solo
    obj, created = cls.objects.get_or_create(pk=cls.singleton_instance_id)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/usr/local/lib/python3.11/site-packages/django/db/models/manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/usr/local/lib/python3.11/site-packages/django/db/models/query.py", line 581, in get_or_create
    return self.get(**kwargs), False
           ^^^^^^^^^^^^^^^^^^

  File "/usr/local/lib/python3.11/site-packages/django/db/models/query.py", line 431, in get
    num = len(clone)
          ^^^^^^^^^^

  File "/usr/local/lib/python3.11/site-packages/django/db/models/query.py", line 262, in __len__
    self._fetch_all()

  File "/usr/local/lib/python3.11/site-packages/django/db/models/query.py", line 1324, in _fetch_all
    self._result_cache = list(self._iterable_class(self))
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/usr/local/lib/python3.11/site-packages/django/db/models/query.py", line 51, in __iter__
    results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/usr/local/lib/python3.11/site-packages/django/db/models/sql/compiler.py", line 1175, in execute_sql
    cursor.execute(sql, params)

  File "/usr/local/lib/python3.11/site-packages/django/db/backends/utils.py", line 66, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/usr/local/lib/python3.11/site-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers
    return executor(sql, params, many, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/usr/local/lib/python3.11/site-packages/django/db/backends/utils.py", line 79, in _execute
    with self.db.wrap_database_errors:

  File "/usr/local/lib/python3.11/site-packages/django/db/utils.py", line 90, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value

  File "/usr/local/lib/python3.11/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


python 3.11? Looks, like you are running miles in front of the crowd… :wink:

I think a migration script has not fully completed. What was the version you used before?

I think you need to perform a manual execution of this script.

The same issue happened to me as well. Restored the backup, so it is running again.

I’m comming from version 1.9.0. Can you put us in the right direction what script to run and how?

You can have a look at the note i made here: hassio-addons/dsmr_reader at master · sanderdw/hassio-addons · GitHub

Or here, a screenshot with the instructions:

I used the previous version before the update :stuck_out_tongue:
I always stay up-to-date, so 1.9.0 I believe was the previous version
Below the output from the commands you proposed.

I have checked the owner on the timescaleDB table, using pgadmin
The table has the same owner set, which is specified in the configuration of the dsmr addon

root@dsmr_reader_docker:/app# ./manage.py migrate
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:
  Applying dsmr_backup.0016_backup_interval_and_filename...Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
psycopg2.errors.InsufficientPrivilege: must be owner of table dsmr_backup_backupsettings


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/app/./manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.11/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.11/site-packages/django/core/management/__init__.py", line 413, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.11/site-packages/django/core/management/base.py", line 354, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python3.11/site-packages/django/core/management/base.py", line 398, in execute
    output = self.handle(*args, **options)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/core/management/base.py", line 89, in wrapped
    res = handle_func(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/core/management/commands/migrate.py", line 244, in handle
    post_migrate_state = executor.migrate(
                         ^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/db/migrations/executor.py", line 117, in migrate
    state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/db/migrations/executor.py", line 147, in _migrate_all_forwards
    state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/db/migrations/executor.py", line 227, in apply_migration
    state = migration.apply(state, schema_editor)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/db/migrations/migration.py", line 126, in apply
    operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
  File "/usr/local/lib/python3.11/site-packages/django/db/migrations/operations/fields.py", line 104, in database_forwards
    schema_editor.add_field(
  File "/usr/local/lib/python3.11/site-packages/django/db/backends/base/schema.py", line 522, in add_field
    self.execute(sql, params)
  File "/usr/local/lib/python3.11/site-packages/django/db/backends/base/schema.py", line 145, in execute
    cursor.execute(sql, params)
  File "/usr/local/lib/python3.11/site-packages/django/db/backends/utils.py", line 66, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers
    return executor(sql, params, many, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/db/backends/utils.py", line 79, in _execute
    with self.db.wrap_database_errors:
  File "/usr/local/lib/python3.11/site-packages/django/db/utils.py", line 90, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/usr/local/lib/python3.11/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
django.db.utils.ProgrammingError: must be owner of table dsmr_backup_backupsettings

And to add the output of the container startup:

[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] 01-set-hassio-vars: executing... 
Home Assistant DSMR Reader Add-on - Release: 1.10.1
Home Assistant DSMR Reader Add-on - This addon is the latest version
Home Assistant DSMR Reader Add-on - Configuring addon settings
Home Assistant DSMR Reader Add-on - Ingress enabled
[cont-init.d] 01-set-hassio-vars: exited 0.
[cont-init.d] 10-adduser: executing... 
-------------------------
User UID: 0
User GID: 0
-------------------------
[cont-init.d] 10-adduser: exited 0.
[cont-init.d] 20-set-app-defaults: executing... 

[ INFO ] DSMR Reader Reader release: 5.10.3

[ INFO ] DSMR Reader Reader Docker release: 2023.02.01

[ 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: addon_77b2833f_timescaledb with port: 5432...

[ INFO ] Database connectivity successfully verified!

[ INFO ] Enabling IFrame...

[ 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:
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
psycopg2.errors.InsufficientPrivilege: must be owner of table dsmr_backup_backupsettings