I have a device - Stiebel Eltron heat pump - home and I can track it with a web interface.
I can only access the previous month and the current month. But I would like to keep the all the data, in a numeric way rather than having it like images.
I have a device - Stiebel Eltron heat pump - home and I can track it with a web interface.
I can only access the previous month and the current month. But I would like to keep the all the data, in a numeric way rather than having it like images.
In the first place I must get the raw data. I know how to do it with Firefox and Firebug addin to copy/paste the data to a file... manually. It uses angularjs.1.0.6
, and I get the raw data from one of the GETs displayed thanks to Firebug:
GET https://thesite/api/data/1036493/heatEnergy/today?noCacheDummyValue=1459148624909
GET https://thesite/api/data/1036493/outTemp/today?noCacheDummyValue=1459148624905
GET https://thesite/api/data/1036493/heatEnergy/lastMonth?noCacheDummyValue=1459148708330
GET https://thesite/api/data/1036493/outTemp/lastMonth?noCacheDummyValue=1459148708321
It yould be better if I could do it
- by hacking directly into the LAB.min.js data?
- by calling curl
with my usual login post, then collect data with the GET
s above
Here is how my curl
login POST
call looks like:
curl -o myraw.data --data-urlencode "userName=tutu&password=xx" 'https://thesite/api/login?noCacheDummyValue=1458825357449' \
-H 'Host: thesite' -H 'User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Firefox/45.0' \
-H 'Accept: application/json, text/plain, */*' -H 'Accept-Language: en-US,en;q=0.5' -H 'Accept-Encoding: gzip, deflate, br' \
-H 'X-Requested-With: XMLHttpRequest' \
-H 'Content-Type: application/json;charset=utf-8' \
-H 'Referer: https://thesite/mobile/app/app.html' \
-H 'Content-Length: 44' -H 'Cookie: JSESSIONID=1m5aputqimremdk95fgbtmgo9' \
-H 'Proxy-Authorization: Basic ??' -H 'DNT: 1' \
-H 'Connection: keep-alive'
But I get nothing. For now, I am happy with the Firebug
Copy Response Body / Paste
functionality.
Now I get my raw data looking like some JSON thing I guess:
[{"values":
[{"options":null,"webId":null,"value":"8.9","date":1458842750000,"writeValue":null,"unit":null}
,"options":null,"webId":null,"value":"9.1","date":1458842451000,"writeValue":null,"unit":null}
,{"options":null,
...
,{"options":null,"webId":null,"value":"5.5","date":1458774051000,"writeValue":null,"unit":null}],"unit":"°C"}]
Now I got my data, I thought it would be easy. But I am getting headache trying to do something with this JSON data... I know some did try already: Does LibreOffice Calc support JSON file importing/sorting?
I just have regular pattern in my JSON, and recently (re)discovered sed
. So I use my new power (and how difficult it was to find I had to add a real line break in my substitute value):
cat rawdata.txt | tr -d '\n' | sed 's/},{/\
/g' | sed 's/"options":null,"webId":null,"value"://' |\
sed 's/,"writeValue":null,"unit":null//' |sed 's/,"date":/;/' |\
sed 's/\[{"values":\[{//' |sed 's/}\],"unit":"°C"}\]/\
/' | sed 's/}\],"unit":"kWh"}\]/\
/' > pureData.csv
And get my data like "temperature"
/ "timestamp"
:
ju@ju-HP-Compaq-dc7900-Small-Form-Factor:~/INSTALL/myproj$ cat pureData.csv
"8.9";1458842750000
"9.1";1458842451000
"9.3";1458842150000
"9.4";1458841851000
"9.7";1458841550000
"9.9";1458841251000
"10.0";1458840950000
...
... so happy at this point! When I plot it, it looks like what I have in my Firefox window!
NB: I calculate that my time axis is based on a number of milliseconds since 01.01.1970.
If anyone interested, I wrote something to retrieve data with curl
there: How to use linux curl to login and retrieve data once logged?