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.
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 ?
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
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
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:
command_line:
- sensor:
name: gruenbeck
command: "/usr/local/bin/python3 /config/gruenbeck.py"
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
confirm. had also to change it (back in june ?). Home Assistant made some changes in the syntax
Hello Together,
I have also a SC18 running since 2017. I had quite a long journey integrating this in openhab then with scrape plugin in HA, and finally with this script. I had always issues with the stability, as Gruenbeck has his restrictions and drawbacks in the mux api. Now I found some time to create a custom HACS Integration.
I just started, adding my favorite sensors and all i found out there.
I added also some goodies like showing the last error message
Would love to add further thinks like switching the mode from ECO to Power.
Currently this is tested only with my SC18 would love to get some feedback if this works also for others.
Feel free to also add
Thanks for your work. That’s great. I have a SC18 and would be happy to test your integration.
Feel free, I tried to describe how to install it on the github repository. If you have any comments, improvements or issues, create an issue in the github, so I will get better notifications.