Gruenbeck Soft Water sensor Durchfluss

Well, this was just an example how the value could be extracted from the response.

So if your sensor works and shows the ok<D_A_1_1>0.00</D_A_1_1> without the value_template, then the value_template could be:

value_template: "{{ value.split('<')[1].split('>')[1] }}"

the sensor display unknown.

In the manual from Grunbeck is display that the machine response is in xml format.

With rest client that is a response. Direct in the Browser is nothing.

What can i do ?

Soory im an noob.

If the rest sensor without the value_template returns ‘unknown’, then maybe give the Command line Sensor a try.

  - platform: command_line
    name: Durchfluss
    command: "curl -X POST -i '' --data 'id=622&show=D_A_1_1~'"

If this returns the desired value: ok<D_A_1_1>0.00</D_A_1_1> then try it with the value_template from my last post.

If that doesn’t work, i’m out of ideas, sorry.

BTW: Give this topic a category (Configuration or something) so more people will see it in the latest section.

Here comes a response :

HTTP/1.1 200 OK Content-Type: text/html; charset=UTF-8 Accept-Ranges: bytes Connection: close ok<D_A_1_1>0.00</D_A_1_1>

Please create me the value template.
With your template in the last post theres nothing.

This example is working fine:

- platform: command_line
  scan_interval: 3600
  name: gruenbeck_restkapazitaet
  command: "curl -X POST -i '' --data 'id=622&show=D_A_1_2~'"
  value_template: >
    {{ value.split('<')[4].split('>')[1] }}

Is this working for an SD21 too or just for the SC series?
I cannot get this working with my SD21, it seems there is just a cloud connection

Thanks a lot, worked like a charm. Could you help me out with another value? I get the correct water usage out of the following line (three digit “number”) but the output is not formattet as a number.

I think I have to alter value_template but I could not figure out which statement I should use.

  - platform: command_line
    scan_interval: 3600
    name: gruenbeck_wassermenge
    command: "curl -X POST -i '' --data 'id=8997&show=D_Y_2_1~'"
    value_template: >
      {{ value.split('<')[4].split('>')[1] }}

My result for D_Y_2_1 is:
This can also be parsed with the same way using
{{ value.split('<')[4].split('>')[1] }}
and returns 141. If you want you can have a real number, just modify the template like this:
{{ value.split('<')[4].split('>')[1] | float }}

Hope this helps.

Yes, it helped - Thank you very much!


I use that code for some time now.
But with the new HA versions it is not working anymore.
Dose someone else has the same topic?

Works fine for me with the command line sensor, running a small python code that makes only 1 query and returns all properties as JSON.
BUT from time to time the connection is aborted by the SC device. no idea what’s actually going on, it recovers after some time though.
Currently it is timing out, and the app shows that regeneration is running → related ?

1 Like

Hi, would you mind sharing your python script? I own a GrĂŒnbeck SC18 and would like to integrate their data into Home Assistant.

Hi @Eber , sure I can do :


import json
import requests
# curl -X POST -i '' --data 'id=670&show=D_A_1_1|D_A_1_2|D_A_2_2|D_A_3_1|D_A_3_2|D_Y_1|D_A_1_3|D_A_2_3|D_Y_5|D_A_2_1~'
url = ""

content="<data><code>nok</code><D_A_1_1>0.00</D_A_1_1><D_A_1_2>0.00</D_A_1_2><D_A_2_2>000</D_A_2_2><D_A_3_1>  0</D_A_3_1><D_A_3_2>000</D_A_3_2><D_Y_1>000</D_Y_1><D_A_1_3>0.0</D_A_1_3><D_A_2_3>00</D_A_2_3><D_Y_5>0</D_Y_5><D_A_2_1>0.0</D_A_2_1></data>"
   resp = requests.get(url,data=data)
except BaseException as err:
   # Log out the error to the openHAB console for better investigation
   print("GrĂŒnbeck:", "POST request failed: {0}".format(err))
   #content="<data><code>ok</code><D_A_1_1>0.00</D_A_1_1><D_A_1_2>0.28</D_A_1_2><D_A_2_2>000</D_A_2_2><D_A_3_1>  8</D_A_3_1><D_A_3_2>100</D_A_3_2><D_Y_1>309</D_Y_1><D_A_1_3>6.1</D_A_1_3><D_A_2_3>99</D_A_2_3><D_Y_5>0</D_Y_5><D_A_2_1>0.0</D_A_2_1></data>"

import re
code = re.findall(r'<code>(\w+)<\/code>',content)[0]
da11 = re.findall(r'<D_A_1_1>([0-9\.]+)<\/D_A_1_1>',content)[0] # aktueller Durchfluss (m3/h)
da12 = re.findall(r'<D_A_1_2>([0-9\.]+)<\/D_A_1_2>',content)[0] # RestkapazitÀt (m3)
da22 = 0#re.findall(r'<D_A_2_2>([0-9\.]+)<\/D_A_2_2>',content)[0] # Restdauer Wartungsintervall (d)
da31 = re.findall(r'<D_A_3_1> *([0-9\.]+)<\/D_A_3_1>',content)[0] # Zeit seit letzer Regeneration (h)
da32 = re.findall(r'<D_A_3_2>([0-9\.]+)<\/D_A_3_2>',content)[0] # Protzentsatz der laufenden Regeneration (%)
dy1 = re.findall(r'<D_Y_1>([0-9\.]+)<\/D_Y_1>',content)[0] # wasserverbrauch pro Tag (l)
da13 = re.findall(r'<D_A_1_3>([0-9\.]+)<\/D_A_1_3>',content)[0] # AnlagenkapazitÀt
da23 = re.findall(r'<D_A_2_3>([0-9\.]+)<\/D_A_2_3>',content)[0] # Salzreichweite (nur bei SC23)
dy5 = re.findall(r'<D_Y_5>([0-9\.]+)<\/D_Y_5>',content)[0] # Aktueller Regenerationsschritt (0,1-5)
da21 = re.findall(r'<D_A_2_1>([0-9\.]+)<\/D_A_2_1>',content)[0] # # Restdauer oder Restmenge aktueller Regenerationsschritt

print(f'{{"code":"{code}","durchfluss":{da11},"restkapazitaet":{da12},"restdauer_wartungsintervall":{da22},"seit_regeneration":{da31},"regeneration_progress":{da32},"wasserverbrauch":{dy1},"anlagenkapazitaet":{da13},"salzreichweite":{da23},"aktueller_regenerationsschritt":{dy5},"restdauer_regeneration":{da21} }}')

and then in configuration.yaml :

  - sensor:
      - name: "GrĂŒnbeck Durchfluss"
        unit_of_measurement: "l"
        state: "{{ state_attr('sensor.gruenbeck', 'durchfluss') }} "
      - name: "GrĂŒnbeck RestkapazitĂ€t"
        unit_of_measurement: "mÂł"
        state: "{{ state_attr('sensor.gruenbeck', 'restkapazitaet') }} "
      - name: "GrĂŒnbeck Zeit seit Regeneration"
        unit_of_measurement: "h"
        state: "{{ state_attr('sensor.gruenbeck', 'seit_regeneration') }} "
      - name: "GrĂŒnbeck Protzentsatz Regeneration"
        unit_of_measurement: "%"
        state: "{{ state_attr('sensor.gruenbeck', 'regeneration_progress') }} "
      - name: "GrĂŒnbeck Wasserverbrauch pro Tag"
        unit_of_measurement: "l/d"
        state: "{{ state_attr('sensor.gruenbeck', 'wasserverbrauch') }} "
      - name: "GrĂŒnbeck AnlagenkapazitĂ€t"
        unit_of_measurement: "mÂł"
        state: "{{ state_attr('sensor.gruenbeck', 'anlagenkapazitaet') }} "
      - name: "GrĂŒnbeck aktueller Regenerationsschritt"
        state: "{{ state_attr('sensor.gruenbeck', 'aktueller_regenerationsschritt') }} "
      - name: "GrĂŒnbeck Restdauer Regeneration"
        unit_of_measurement: "min"
        state: "{{ state_attr('sensor.gruenbeck', 'restdauer_regeneration') }} "

hope that helps, this is what it looks like in the GUI then


Awesome. Thank you so much. Can you give me a little hint where to place the python script?

OK, looks like I forgot to mention one part of the config.yaml (actually was hidden inside an include statement !), sorry for that !

the /config path is specific to the docker variant of hass, I assume you can just put the script anywhere and add the right path in the “command” line

- platform: command_line
  command: "/usr/local/bin/python3 /config/scripts/"
  name: gruenbeck
          - code
          - durchfluss
          - restkapazitaet
          - restdauer_wartungsintervall
          - seit_regeneration
          - regeneration_progress
          - wasserverbrauch
          - anlagenkapazitaet
          - salzreichweite
          - aktueller_regenerationsschritt
          - restdauer_regeneration
  value_template: "{{ value_json.code}}"
  scan_interval: 1800

I know this thread is a bit old. But I found the great instructions because I also want to connect Homeassistant with GrĂŒnbeck. The Python script also works perfectly. But I keep having the “Could not get response” problem mentioned. There is a corresponding log entry in HA for this. I get the same error when I address GrĂŒnbeck via Postman. It looks like the API is very sensitive and sporadically just doesn’t respond. Does anyone have an idea how to get this to work properly?

@Cavekeeper just checked my logs, no such error message, nor any other gruenbeck related message in the past 5 days
Could it be your wifi connection is unstable ?

Yes you are right. Maybe I had an unstable connection. But now it works. The script works very well and I get the data. The only pity is that the shortest sequence is the daily consumption. This means that an evaluation over the day is not possible. But at least a long-term evaluation works with it. I now add up the daily consumption to a total counter and compare this with the real water meter. I am curious whether these match or whether I have to calibrate the daily consumption sensor as a template sensor.

I’ve got an error if I put that in my configuration.yaml. Here’s how I avoided it:

    - sensor:
        name: gruenbeck
        command: "/usr/local/bin/python3 /config/"
          - code
          - durchfluss
          - restkapazitaet
          - restdauer_wartungsintervall
          - seit_regeneration
          - regeneration_progress
          - wasserverbrauch
          - anlagenkapazitaet
          - salzreichweite
          - aktueller_regenerationsschritt
          - restdauer_regeneration
        value_template: "{{ value_json.code}}"
        scan_interval: 1800

confirm. had also to change it (back in june ?). Home Assistant made some changes in the syntax :frowning: