How to get Homewizard P1 meter telegrams into DSMR Reader using automations

This post describes how you can get Homewizard P1 meter telegrams from your DSMR smart meter into DSMR Reader using Home Assistant automations and scripts.
Until now I have been using a Raspberry Pi and a P1 USB cable to retrieve the smart meter telegrams.
In 2025 I hope to install a Homewizard plug-in battery. A Homewizard P1 meter is then necessary.

(I have also instructions how to send Homewizard P1 telegrams to xirixiz/dsmr-reader-docker using DSMR Reader plugins. See DSMR Reader Docker and Homewizard P1 meter integration)

Introduction

Homewizard P1 telegrams can be sent to DSMR Reader as follows:

We will use only Home Assistant REST commands to do the integration.

What you need

  • working instances of
    • Home Assistant
    • DSMR Reader
  • a Homewizard P1 meter
    • plugged into your smart meter
    • already configured and visible in the Homewizard Energy app
    • local API enabled
  • IP address Homewizard P1 meter
  • IP address DSMR reader
  • API key DSMR Reader

REST commands

In your Home Assistant configuration.yaml file create the following REST commands

rest_command:
  get_hw_p1_telegram:
    url: "http://{{ip}}/api/v1/telegram"
    method: get

  dsmr_push_telegram:
    url: "http://{{ip}}/api/v1/datalogger/dsmrreading"
    method: post
    payload: "telegram={{telegram}}"
    headers:
      "Authorization": "Token {{ api_key }}"
      "Content-Type": "application/x-www-form-urlencoded"

Script to get a Homewizard raw P1 telegram

Create the following script

alias: Get Homewizard P1 telegram
sequence:
  - service: rest_command.get_hw_p1_telegram
    data:
      ip: "{{ip}}"
    response_variable: response
  - stop: rest command executed
    response_variable: response
fields:
  ip:
    selector:
      text: null
    name: ip
    description: IP address Homewizard P1 meter
    required: true
mode: queued
max: 100

You can use this script in Developer Tools / Services to check if you can get a telegram successfully.

Script to poll and process a P1 telegram

Create a Home Asssistant script
In the code below:

  • replace 1.2.3.4 with the IP address of your Homewizard P1 meter
  • replace 6.7.8.9:7777 with the correct IP and port of your DSMR Reader
  • replace your_api_key with the DSMR Reader API key
alias: Process P1 telegram
sequence:
  - service: script.get_homewizard_p1_telegram
    data:
      ip: 1.2.3.4
    response_variable: result
  - choose:
      - conditions:
          - condition: template
            value_template: "{{ result.status == 200 }}"
        sequence:
          - service: rest_command.dsmr_push_telegram
            data:
              ip: 6.7.8.9:7777
              telegram: "{{ result.content }}"
              api_key: your_api_key
            response_variable: ret
            enabled: true
  - stop: end of script
    response_variable: result
mode: queued
max: 100

Automate the process

Create an automation to fetch a telegram.
DSMR v4 meters publish a new telegram (with electricity information) every 10 seconds (use a trigger of /10).
DSMR v5 meter update every second (use a trigger of /1).

alias: Process Homewizard P1 Telegrams
description: ""
trigger:
  - platform: time_pattern
    seconds: /10
condition: []
action:
  - service: script.process_p1_telegram
    response_variable: response
mode: queued
max: 100

3 Likes

Would this work without HA? I would prefer a standalone solution.

@elRadix the Docker solution uses a Python script which is called inside DSMR Reader. The solution is scattered around various pages. I will try to write a post next week which summarizes everything

Here is the page that helped me. Part of the instructions is in Dutch HomeWizard P1 As Remote for DSRM-Reader · Issue #301 · xirixiz/dsmr-reader-docker · GitHub

@elRadix please try the instructions on this page. Let me know if it works out DSMR Reader Docker and Homewizard P1 meter integration

Love the idea of the scripts/automations here. But i’m running into an issue on this;

The issue is that i have the DSMR Reader installed as an add-on, so it runs on the same host as home assistant does! Does anyone know how to connect to the correct adress?

I tried:

  • 127.0.0.1:7777 → FAILS
  • 127.0.0.1 → FAILS (no port, this will go to port 80 that is in use by another add-on)
  • 172.30.33.9 → FAILS (ip address of add-in container)
  • 0826754b-dsmr-reader.local.hass.io → FAILS (dns name of the add-on?)
  • 0826754b-dsmr-reader:7777 → FAILS

Does anyone know how to connect a rest-command to a add-on running in the same host?

Please try the IP address of your Home Assistant configuration

Modified the script and automation so that they run in queued mode. This way you will not get an error that the script/automation is already running

Forgot to mention that! Also the ip adress (192.168.1.3 in my case) was tested, no go :frowning:

If you type in a browser http://192.168.1.3:7777
do you get the DSMR Reader graphs?

Well, it does load something (addon is running):

Isn’t that because ingress is enabled? If i open via ingress it displays fine.

Perhaps you can try the first “section” of your Ingress URL as the IP address for your Home Assistant configuration?

And please try 192.168.1.3:7777

Did try that but no go. After some fiddeling with it now it seems to work with 192.168.1.3:7777 and:

rest_command:
  dsmr_get_hw_p1_telegram:
    url: "http://{{ip}}/api/v1/telegram"
    timeout: 30
    method: get

  dsmr_push_telegram:
    url: "http://{{ip}}/api/v1/datalogger/dsmrreading"
    method: post
    payload: "telegram={{telegram}}"
    timeout: 30
    headers:
      "Authorization": "Token {{ api_key }}"
      "Content-Type": "application/x-www-form-urlencoded"

The timeout bit is added there, it seems as if the DSMR reader addon is not fast enough to respond?? Well, it works now… :rofl:

The mode: queued bit is not working for me btw. For the automation it is fine, but as soon as i add it to the scripts it stops working. The ‘choose’ option in the process script always returns false.

Which script is giving problems with the queued mode?

The ‘Get Homewizard P1 telegram’ script gave me issues when changing that to queued mode.