DSMR sensor Interval

Hello,

I’m using the SmartMeter add-on (DSMR) to parse data and present in Home-Assistant.

sensor

  • platform: dsmr
    port: /dev/ttyUSB0
    dsmr_version: 5

My smartmeter spits out data every single second. This gives a nice actual reading, however I’ve noticed my database is getting larger and larger. Graph loading takes about 1 minute, which is not very responsive…

Is it possible to reduce the amount of data stored to the database to 1 minute values?

I have tried scan_interval: 300 but that has no effect.

Additional, i would like to keep weekly, montly and yearly data for comparison purposes.

Thanks for any help.

Regards,
Peter

I would try excluding this sensor from the recorder. Then add a template sensor like this:

sensor:
  - platform: template
    sensors:
      dsmr_1min:
        entity_id: sensor.dummy
        value_template: "{{ states('sensor.dsmr') }}"

Using an entity_id that doesn’t exist should prevent this template sensor from updating automatically. Then use an automation to update it every minute:

automation:
  - alias: Update sensor.dsmr_1min
    trigger:
      platform: time_pattern
      minutes: '/1'
    action:
      service: homeassistant.update_entity
      entity_id: sensor.dsmr_1min

For the longer term data collection, I wouldn’t count on HA’s database. I don’t think it’s intended for that. Maybe use the File notification component (and an automation) to record values at the larger periods. Or maybe someone else has a better idea for that part.

1 Like

Thanks for your reply.
I will first try using the exclude, template and automation sequence.
Just an idea, I could make custom sensors like:

  • daily power usage
  • weekly power usage
  • montly power usage

Then use automation to store value’s in these custom sensors right?

What do you mean by “custom sensor”?

@peter_pdj I had the same issue with a huge database because of my smart meter spitting out data out at a high interval. I found this topic and followed the advice to create a filter sensor. Followed by a service call to recorder.purge which actually cleans up the database. Hope this helps for you.

1 Like