Gruenbeck Soft Water sensor Durchfluss

Hello, i have a Gruenbeck Soft water machine and i want to read the actual water flow in a sensor.

The Request is

http://192.168.2.9/mux_http/id=622&show=D_A_1_1~ this must be as POST

The Response is

ok<D_A_1_1>0.00</D_A_1_1>

i need the 0.00

the curl is

curl -X POST -i ‘http://192.168.2.9/mux_http’ --data ‘id=622&show=D_A_1_1~’

please help

I think the RESTful Sensor should do it.

Not sure how to deal with the response, but in Dev Tools/Templates, this:

{% set response = 'ok<D_A_1_1>0.00</D_A_1_1>' %}
{{ response.split('<')[1].split('>')[1] }}

returns 0.00

Hi,

with

sensor wasserdurchfluss:
  - platform: rest
    resource: http://192.168.2.9/mux_http/id=622&show=D_A_1_1~
    method: POST
    name: wasserdurchfluss
    value_template: {% set response = 'ok<D_A_1_1>0.00</D_A_1_1>' %}, 
    {{ response.split('<')[1].split('>')[1] }}

in the configuration i get this error :

missed comma between flow collection entries at line 138, column 22:
value_template: {% set response = 'ok<D_A_1_1>0.0 …
^

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.

sensor:
  - platform: command_line
    name: Durchfluss
    command: "curl -X POST -i 'http://192.168.2.9/mux_http' --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 'http://192.168.1.99/mux_http' --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 'http://10.0.0.120/mux_http' --data 'id=8997&show=D_Y_2_1~'"
    value_template: >
      {{ value.split('<')[4].split('>')[1] }}

My result for D_Y_2_1 is:
<data><code>ok</code><D_Y_2_1>141</D_Y_2_1></data>%
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.
/Michel

Yes, it helped - Thank you very much!

Hello,

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 :

#!/usr/bin/python3

import json
import requests
# curl -X POST -i 'http://192.168.24.80/mux_http' --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 = "http://192.168.24.80/mux_http"
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~"

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>"
try:
   resp = requests.get(url,data=data)
   #print(resp.status_code)
   #print(resp.text)
   #print(resp)
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>"
else:
   content=resp.text

import re
#print("resp=",resp.text)
#print("content=",content)
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(code,da11,da12,da22,da31,da32,dy1,da13,da23,dy5,da21)
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 :

template:
  - 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

5 Likes

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/gruenbeck.py"
  name: gruenbeck
  json_attributes:
          - code
          - durchfluss
          - restkapazitaet
          - restdauer_wartungsintervall
          - seit_regeneration
          - regeneration_progress
          - wasserverbrauch
          - anlagenkapazitaet
          - salzreichweite
          - aktueller_regenerationsschritt
          - restdauer_regeneration
  value_template: "{{ value_json.code}}"
  scan_interval: 1800
2 Likes

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 ?