Seeking help for reading my Ecowater softener with my Homey

Dear community,

I’m seeking help to scrape a website to read values from my water softener. I found a python script that does the trick. I actually got it up and running on my laptop, giving me the results I’m looking for. My next challenge is to get it integrated in my Homey. I was thinking of doing this via a JavaScript fetch functions and POST and GET methods. Unfortunately, I am not able to get it up and running, hence seeking help!
What I learned so far is that I am able to connect to the website, but then I struggle to get further. The website returns a hidden token that you somehow need to pass on to really get to your values. The python script does this, but I don’t understand how. I’m not experienced with python and not seasoned with fetching data from websites using JavaScript.
This is (part of) the python script I found, which uses a couple of libraries. Hope someone can give me some hints to get it further.

import requests
import json
import re
import paho.mqtt.client as mqtt
import paho.mqtt.publish as publish

Regex to match the hidden input on the initial log in page

request_validation_re = re.compile(r’')

The serial number of your ecowater device

dsn = { “dsn”: ‘serialnumber’ }

The initial form data

payload = {
“Email” : “emailaddress”,
“Password” : “password”,
“Remember” : ‘false’
}

The headers needed for the JSON request

headers = {
‘Accept’: ‘/’,
‘Accept-Encoding’: ‘gzip, deflate, br’,
‘Accept-Language’ : ‘en-US,en;q=0.5’,
‘X-Requested-With’: ‘XMLHttpRequest’,
‘Content-Type’: ‘application/x-www-form-urlencoded; charset=UTF-8’,
‘User-Agent’: ‘Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:73.0) Gecko/20100101 Firefox/73.0’
}

with requests.Session() as s:
# Initial GET request
g = s.get(‘https://www.wifi.ecowater.com/Site/Login’)

# Grab the token from the hidden input
tokens = request_validation_re.findall(g.text)

# Add the token to the form data payload
payload['__RequestVerificationToken'] = tokens[0]

# Log in to the site
login = s.post('https://www.wifi.ecowater.com/Site/Login', data=payload)

# Add the correct Referer header
headers['Referer'] = login.url + '/' + dsn['dsn']

# Query the JSON endpoint for the data that we actually want
data = s.post('https://www.wifi.ecowater.com/Dashboard/UpdateFrequentData', data=dsn, headers=headers)

Once I am able to get the results in this “data” variable or object, I think I will be able to get further.
Thanks for at least reading my post and hopefully give me some hints!

Hello Bert,

do you have been able to make any progress?

I’m also looking for a methode to read the values of my ecowater (amysoft) device. I know there is no Homey app for this, there is a HomeAssistant app on github.

I was hoping someone could take this HomeAssistant code and convert it to a Homey app.

more info, homeassistant app:

I have not been able to get it working yet. There is a python library used to properly log in to the website using a secret code that the website sends back after the first login. I have not been able to deduct this and get it running with Javascript. :frowning:

1 Like

Hi Bert,

this one should do the trick for you

Kind regards,
Tim

1 Like

WOW Tim, this is really great! Thanks a ton!

Hi Tim, I have now been using this app for a couple of days. Unfortunately, the water consumption value does not seem to update. Only after I login via the Ecowater App on my phone and look at the values for my water softener, I also get an updated value in your Homey App. Are there some settings I need to change?
I am using version 1.01 with the request interval change.

Hey Bert,

It indeed looks like there is some kind of internal pauze button within Ecowater which is removing the iot updates when ur not using the console specifically for the water usage.
I’ll look into it and give you an update

Kind regards,
Tim

Hi Bert,

I’ve pushed a fix which you can already find on a test version.
Can you let me know this fixes your issue?

Kind regards,
Tim

Thanks Tim. Got the update automatically. And, yes, it’s working now, getting regular updates since 7 AM this morning!

Hi Tim, I reported an issue this evening. You replied that my password might not be correct. Actually, it was a different issue. I had an airco engineer over some 2 weeks ago. He created a power shortcut (…). Resulting in a lot of issues with my smart devices. It now seemed my Ecowater softener lost Wifi connection since then. Needed to reconnect it to my Wifi router and now I’m getting updates again. Thanks for your hint!