RESTful sensor data from DSMR reader

Hi,

I have setup DSMR-reader from : GitHub - dsmrreader/dsmr-reader: DSMR-telegram reader & data visualizer for hobbyists. Free for non-commercial use.
This is working fine. Has a nice gui and seperate database.
I would like to just display the current meter readings in HA as a sensor, without recording it.
I can offcourse exlude the sensors from recording it, but i cannot get the right data in HA.

I have the following configuration:

sensor:

  • platform: rest
    name: DSMR_Meter_Standen
    json_attributes:
    # Huidig elektriciteitsverbruik in kW
    - electricity_currently_delivered
    # Huidige teruglevering elektriciteit in kW
    - electricity_currently_returned
    # Meterstand van verbruikte elektriciteit (laagtarief) in kWh
    - electricity_delivered_1
    # Meterstand van verbruikte elektriciteit (piektarief) in kWh
    - electricity_delivered_2
    # Meterstand van teruggeleverde elektriciteit (laagtarief) in kWh
    - electricity_returned_1
    # Meterstand van teruggeleverde elektriciteit (laagtarief) in kWh
    - electricity_returned_2
    # Meterstand van de externe (gas)meter
    - extra_device_delivered
    resource: http://localhost/api/v2/datalogger/dsmrreading?ordering=-timestamp&limit=1
    value_template: ‘{{ value_json.state }}’
    headers:
    X-AUTHKEY: XXXXXXXXXXXXXXXXXXXXX
  • platform: template
    sensors:
    electricity_currently_delivered:
    friendly_name: ‘electricity_currently_delivered’
    value_template: ‘{{ states.sensor.json_state.attributes[“electricity_currently_delivered”] }}’
    unit_of_measurement: “kW”
    electricity_currently_returned:
    friendly_name: ‘electricity_currently_returned’
    value_template: ‘{{ states.sensor.json_state.attributes[“electricity_currently_returned”] }}’
    unit_of_measurement: “kW”
    electricity_delivered_1:
    friendly_name: ‘electricity_delivered_1’
    value_template: ‘{{ states.sensor.json_state.attributes[“electricity_delivered_1”] }}’
    unit_of_measurement: “kWh”
    electricity_delivered_2:
    friendly_name: ‘electricity_delivered_2’
    value_template: ‘{{ states.sensor.json_state.attributes[“electricity_delivered_2”] }}’
    unit_of_measurement: “kWh”
    electricity_returned_1:
    friendly_name: ‘electricity_returned_1’
    value_template: ‘{{ states.sensor.json_state.attributes[“electricity_returned_1”] }}’
    unit_of_measurement: “kWh”
    electricity_returned_2:
    friendly_name: ‘electricity_returned_2’
    value_template: ‘{{ states.sensor.json_state.attributes[“electricity_returned_2”] }}’
    unit_of_measurement: “kWh”
    extra_device_delivered:
    friendly_name: ‘extra_device_delivered’
    value_template: ‘{{ states.sensor.json_state.attributes[“extra_device_delivered”] }}’
    unit_of_measurement: “m3”

More infomation about the Restful api:
http://dsmr-reader.readthedocs.io/nl/latest/api.html#api-v2-restful-api

Could it be the {} in the output witch having issues in HA?

Thanks

1 Like

Hi Martin,

Did you solve the issue?

KR,
Ceriel

Yep, Just went with the Mqtt sensors

Then its a work-arround and not a fix :wink:
Thanks for the tip, will try it.

Little bit off-topic, could you point me a direction for the water meter you created (saw your reply on tweakers) would love to have one as well.

Hi a bit off-topic indead; but i am using this docker project from Alex: https://github.com/ualex73/docker-s0pcm-reader

In conbination with a S0pcm usb Pulse counter and a Cyble Itron sensor on my Aquadis watermeter.

Could you please share what to do where to get that working? I’m running HA on a Rpi3. I think i have activated the MQTT broker in HA, and DSMR is publishing MQTT Telegrams. But i can’t get values displayed in HA. Current configuration.yaml entries:

####DSMR
  • platform: mqtt
    name: DSMR electricity_currently_delivered
    unit_of_measurement: “kWh”
    state_topic: “dsmr/json”
    value_template: “{{value_json.electricity_currently_delivered}}”

If i use HA to publish the topic and value as DSMR is doing (which i can see in DSMR), the sensor picks up the value i publish from within HA. But it’s not picking up the values DSMR is publishing…

Hi Raoul,

I have enabled the MQTT broker in DSMR and published the daily information.
In HA:

sensor dsmr:

  • platform: mqtt
    name: “DSMR Power daltarief”
    state_topic: “dsmr/day-consumption”
    unit_of_measurement: ‘kWh’
    value_template: “{{ value_json.electricity1 }}”
  • platform: mqtt
    name: “DSMR Power piektarief”
    state_topic: “dsmr/day-consumption”
    unit_of_measurement: ‘kWh’
    value_template: “{{ value_json.electricity2 }}”

[edit:] you can always use the MQTT Lens addin in chrome to check if DSMR is publishing to the desired topics in MQTT.

Thanks for the reply. As a MQTT n00b, i had some trouble getting all parts to work. Found out embedded HBMQTT threw an error in logs. A previous attempt to install Mosquitto failed; but gave it another try, this time with success. Did not know i had to also install a mosquitto client to test mqtt pub sub from command line. Than did not know what to enter in :/admin/dsmr_mqtt/mqttbrokersettings/. Took lots of tries and reboots, but i now have a value in HA. Thanks again.

Hi @Martinvdm, can you explain what you did to get the water pulse meter working? I had one installed (elster PR6) when I got a new smaller watermeter, but I have not been able to connect the wires to my pgio of the rpi, and receiving data from the puls meter.

Hi , Please check my post a couple posts earlier:

1 Like

somehow I completely overlooked that link. thanks!

Hi, sorry for hijacking this topic but I have a similar question.

I have DSMR-reader running on a raspberry pi.
The settings that I have made within DSMR-reader are as follows:

Hostname: https://ip_of_hassio
Port: 1883
Security: none
ClientID: hassio (didn’t know what to put here)
username: empty
password: empty
QoS: 0

mqtt data is published as a separate topic:

[mapping]
id = dsmr/reading/id
timestamp = dsmr/reading/timestamp
electricity_delivered_1 = dsmr/reading/electricity_delivered_1
electricity_returned_1 = dsmr/reading/electricity_returned_1
electricity_delivered_2 = dsmr/reading/electricity_delivered_2
electricity_returned_2 = dsmr/reading/electricity_returned_2

In my configuration.yaml file I have the following code:

mqtt:
  broker: 192.168.178.17
  port: 1883


# Sensors
sensor:
  - platform: mqtt
    name: "DSMR Power daltarief"
    state_topic: "dsmr/reading/electricity_delivered_1"
    unit_of_measurement: 'W'

Maybe you can tell it already but I’m a complete noob at this, I have search the web but I cannot make any sense of it wat so ever. Im hoping somebody on this forum is willing to help me out.

Regards Jordy

For API, I configured it like this in the past: https://github.com/xirixiz/my-hass-config-obsolete/blob/301d334804860503b4d6502eec22ce441643e729/packages/dsmr.yaml