Posts: 120
Threads: 24
Joined: Sep 2021
Reputation:
2
Hi @all,
I want to connect my Waterkotte Ecotouch heatpump to LM/W4k. I have a working .php script what is running on my Raspberry. This script I want to transfer to LM.
To start with: My goal is to read "TEMPERATURE_OUTSIDE" and write it to a group address and write "ENABLE_HEATING" from a group address.
Is this possible? Has anybody an idea how to start?
Many thanks for your help!
Best Regards
Steffen
Attached Files
Posts: 8110
Threads: 43
Joined: Jun 2015
Reputation:
471
Try running this code and post what you get in Logs. Change ip, user and pwd variables as needed.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
http =
require (
'socket.http' )
ip =
'192.168.178.100'
user =
'XXX'
pwd =
'XXX'
url =
'http://' ..
ip ..
'/cgi/login?username=' ..
user ..
'&password=' ..
pwd
res ,
code =
http.request (
url )
log (
'login request' ,
res ,
code )
if res and code ==
200 then
token =
res :
match (
'%x+' )
log (
'token' ,
token )
if type (
token ) ==
'string' and #
token ==
32 then
storage.set (
'ecotouch-token' ,
token )
end
end
if token then
url =
'http://' ..
ip ..
'/cgi/readTags?n=1&t1=A1'
res ,
code =
http.request ({
url =
url ,
headers = {
[
'Cookie' ] =
'IDALToken=' ..
token
}
})
log (
'read request' ,
res ,
code )
end
Posts: 120
Threads: 24
Joined: Sep 2021
Reputation:
2
07.03.2022, 15:33
(This post was last modified: 07.03.2022, 16:12 by pioneersteffen .)
@admin: Many thanks for your help.
I getting a login failure, here is the log:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
Waterkotte 07.03.2022 16 :
22 :
21
*
arg :
1
*
string :
login request
*
arg :
2
*
string :
1
#
S_OK
IDALToken =
d98d4aa1b188273a90c0440da3f3f9d0
*
arg :
3
*
number :
200
Waterkotte 07.03.2022 16 :
22 :
21
*
arg :
1
*
string :
token
*
arg :
2
*
string :
1
Waterkotte 07.03.2022 16 :
22 :
21
*
arg :
1
*
string :
read request
*
arg :
2
*
string : #
E_NEED_LOGIN
*
arg :
3
*
number :
500
If I do the steps manual via Firefox browser:
1.)
Code:
1
http ://
192.168.XXX.XX /
cgi /
login ?
username =
XXX &
password =
XXX [url=http://192.168.178.35/cgi/readTags?n=1&t1=A1][/url]
2.)
Code:
1
http ://
192.168.XXX.XX /
cgi /
readTags ?
n =
1 &
t1 =
A1
the return is:
The failure "E_NEED_LOGIN" I getting also in the browser when I don't do step 1 before step 2.
Posts: 8110
Threads: 43
Joined: Jun 2015
Reputation:
471
Change line 14 to this and try again:
Code:
1
token =
res :
match (
'IDALToken=(%x+)' )
Posts: 120
Threads: 24
Joined: Sep 2021
Reputation:
2
08.03.2022, 09:08
(This post was last modified: 08.03.2022, 09:43 by pioneersteffen .)
@admin: Many thanks, now the login works successful!
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
Waterkotte 08.03.2022 10 :
01 :
43
*
arg :
1
*
string :
login request
*
arg :
2
*
string :
1
#
S_OK
IDALToken =
d09570725af35fbaf13ba699ed6c2a0e
*
arg :
3
*
number :
200
Waterkotte 08.03.2022 10 :
01 :
43
*
arg :
1
*
string :
token
*
arg :
2
*
string :
d09570725af35fbaf13ba699ed6c2a0e
Waterkotte 08.03.2022 10 :
01 :
43
*
arg :
1
*
string :
read request
*
arg :
2
*
string : #
A19 S_OK
192 363
*
arg :
3
*
number :
200
„363“ is the value I want to parse and write it to a group address.
@admin: Do you have an idea how to do that?
Posts: 8110
Threads: 43
Joined: Jun 2015
Reputation:
471
Add after
log('read request', res, code) , if it works then you can replace
log(value) with grp.checkwrite or grp.checkupdate.
Code:
1 2 3 4 5
value =
res :
match (
'S_OK%s+%d+%s+(%d+)' )
if value then
value =
tonumber (
value )
log (
value )
end
Posts: 120
Threads: 24
Joined: Sep 2021
Reputation:
2
@admin: Many thanks again for your big help! Highly appreciated!
I made two script sets out of it.
The first one is to
read the actual values I'm interested in:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304
http =
require (
'socket.http' )
ip =
'xxx'
user =
'xxx'
pwd =
'xxx'
url =
'http://' ..
ip ..
'/cgi/login?username=' ..
user ..
'&password=' ..
pwd
res ,
code =
http.request (
url )
log (
'login request' ,
res ,
code )
if res and code ==
200 then
token =
res :
match (
'IDALToken=(%x+)' )
log (
'token' ,
token )
if type (
token ) ==
'string' and #
token ==
32 then
storage.set (
'ecotouch-token' ,
token )
end
end
if token then
url =
'http://' ..
ip ..
'/cgi/readTags?n=1&t1=A19'
res ,
code =
http.request ({
url =
url ,
headers = {
[
'Cookie' ] =
'IDALToken=' ..
token
}
})
log (
'read request' ,
res ,
code )
value =
res :
match (
'S_OK%s+%d+%s+(%d+)' )
if value then
value =
tonumber (
value )
grp.checkupdate (
'46/1/1' ,
value /
10 )
end
end
os.sleep (
1 )
if token then
url =
'http://' ..
ip ..
'/cgi/readTags?n=1&t1=A4'
res ,
code =
http.request ({
url =
url ,
headers = {
[
'Cookie' ] =
'IDALToken=' ..
token
}
})
log (
'read request' ,
res ,
code )
value =
res :
match (
'S_OK%s+%d+%s+(%d+)' )
if value then
value =
tonumber (
value )
grp.checkupdate (
'46/1/2' ,
value /
10 )
end
end
os.sleep (
1 )
if token then
url =
'http://' ..
ip ..
'/cgi/readTags?n=1&t1=A5'
res ,
code =
http.request ({
url =
url ,
headers = {
[
'Cookie' ] =
'IDALToken=' ..
token
}
})
log (
'read request' ,
res ,
code )
value =
res :
match (
'S_OK%s+%d+%s+(%d+)' )
if value then
value =
tonumber (
value )
grp.checkupdate (
'46/1/3' ,
value /
10 )
end
end
os.sleep (
1 )
if token then
url =
'http://' ..
ip ..
'/cgi/readTags?n=1&t1=A11'
res ,
code =
http.request ({
url =
url ,
headers = {
[
'Cookie' ] =
'IDALToken=' ..
token
}
})
log (
'read request' ,
res ,
code )
value =
res :
match (
'S_OK%s+%d+%s+(%d+)' )
if value then
value =
tonumber (
value )
grp.checkupdate (
'46/1/4' ,
value /
10 )
end
end
os.sleep (
1 )
if token then
url =
'http://' ..
ip ..
'/cgi/readTags?n=1&t1=A12'
res ,
code =
http.request ({
url =
url ,
headers = {
[
'Cookie' ] =
'IDALToken=' ..
token
}
})
log (
'read request' ,
res ,
code )
value =
res :
match (
'S_OK%s+%d+%s+(%d+)' )
if value then
value =
tonumber (
value )
grp.checkupdate (
'46/1/5' ,
value /
10 )
end
end
os.sleep (
1 )
if token then
url =
'http://' ..
ip ..
'/cgi/readTags?n=1&t1=A25'
res ,
code =
http.request ({
url =
url ,
headers = {
[
'Cookie' ] =
'IDALToken=' ..
token
}
})
log (
'read request' ,
res ,
code )
value =
res :
match (
'S_OK%s+%d+%s+(%d+)' )
if value then
value =
tonumber (
value )
grp.checkupdate (
'46/1/6' ,
value /
10 )
end
end
os.sleep (
1 )
if token then
url =
'http://' ..
ip ..
'/cgi/readTags?n=1&t1=A26'
res ,
code =
http.request ({
url =
url ,
headers = {
[
'Cookie' ] =
'IDALToken=' ..
token
}
})
log (
'read request' ,
res ,
code )
value =
res :
match (
'S_OK%s+%d+%s+(%d+)' )
if value then
value =
tonumber (
value )
grp.checkupdate (
'46/1/7' ,
value /
10 )
end
end
os.sleep (
1 )
if token then
url =
'http://' ..
ip ..
'/cgi/readTags?n=1&t1=A28'
res ,
code =
http.request ({
url =
url ,
headers = {
[
'Cookie' ] =
'IDALToken=' ..
token
}
})
log (
'read request' ,
res ,
code )
value =
res :
match (
'S_OK%s+%d+%s+(%d+)' )
if value then
value =
tonumber (
value )
grp.checkupdate (
'46/1/8' ,
value /
10 )
end
end
if token then
url =
'http://' ..
ip ..
'/cgi/readTags?n=1&t1=A37'
res ,
code =
http.request ({
url =
url ,
headers = {
[
'Cookie' ] =
'IDALToken=' ..
token
}
})
log (
'read request' ,
res ,
code )
value =
res :
match (
'S_OK%s+%d+%s+(%d+)' )
if value then
value =
tonumber (
value )
grp.checkupdate (
'46/3/1' ,
value /
10 )
end
end
os.sleep (
1 )
if token then
url =
'http://' ..
ip ..
'/cgi/readTags?n=1&t1=I30'
res ,
code =
http.request ({
url =
url ,
headers = {
[
'Cookie' ] =
'IDALToken=' ..
token
}
})
log (
'read request' ,
res ,
code )
value =
res :
match (
'S_OK%s+%d+%s+(%d+)' )
if value then
value =
tonumber (
value )
if value ==
1
then
value =
true
elseif
value ==
0
then
value =
false
end
grp.checkupdate (
'46/3/2' ,
value )
end
end
os.sleep (
1 )
if token then
url =
'http://' ..
ip ..
'/cgi/readTags?n=1&t1=I31'
res ,
code =
http.request ({
url =
url ,
headers = {
[
'Cookie' ] =
'IDALToken=' ..
token
}
})
log (
'read request' ,
res ,
code )
value =
res :
match (
'S_OK%s+%d+%s+(%d+)' )
if value then
value =
tonumber (
value )
if value ==
1
then
value =
true
elseif
value ==
0
then
value =
false
end
grp.checkupdate (
'46/3/3' ,
value )
end
end
os.sleep (
1 )
And the second one to
write the desired values:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
http =
require (
'socket.http' )
ip =
'xxx'
user =
'xxx'
pwd =
'xxx'
url =
'http://' ..
ip ..
'/cgi/login?username=' ..
user ..
'&password=' ..
pwd
res ,
code =
http.request (
url )
log (
'login request' ,
res ,
code )
if res and code ==
200 then
token =
res :
match (
'IDALToken=(%x+)' )
log (
'token' ,
token )
if type (
token ) ==
'string' and #
token ==
32 then
storage.set (
'ecotouch-token' ,
token )
end
end
os.sleep (
1 )
setvalue =
grp.getvalue (
'46/2/2' )
if setvalue ==
true
then setvalue =
1
else setvalue =
0
end
if token then
url =
'http://' ..
ip ..
'/cgi/writeTags?returnValue=true&n=1&t1=I30&v1=' ..
setvalue
res ,
code =
http.request ({
url =
url ,
headers = {
[
'Cookie' ] =
'IDALToken=' ..
token
}
})
log (
'read request' ,
res ,
code )
end
os.sleep (
1 )
setvalue =
grp.getvalue (
'46/2/3' )
if setvalue ==
true
then setvalue =
1
else setvalue =
0
end
if token then
url =
'http://' ..
ip ..
'/cgi/writeTags?returnValue=true&n=1&t1=I31&v1=' ..
setvalue
res ,
code =
http.request ({
url =
url ,
headers = {
[
'Cookie' ] =
'IDALToken=' ..
token
}
})
log (
'read request' ,
res ,
code )
end
os.sleep (
1 )
setvalue =
grp.getvalue (
'46/2/1' )
setvalue =
setvalue *
10
if token then
url =
'http://' ..
ip ..
'/cgi/writeTags?returnValue=true&n=1&t1=A38&v1=' ..
setvalue
res ,
code =
http.request ({
url =
url ,
headers = {
[
'Cookie' ] =
'IDALToken=' ..
token
}
})
log (
'read request' ,
res ,
code )
end
Generally it works fine EXCEPT when the time between two request is to short I getting the following return in the log and the values are not written to the heatpump:
Code:
1 2 3 4 5 6 7 8
Waterkotte_Sollwerte 10.03.2022 20 :
23 :
55
*
arg :
1
*
string :
login request
*
arg :
2
*
string : -
37
#
E_TOO_MANY_USERS
*
arg :
3
*
number :
200
@admin: Do you have an idea how to control the situation? Do I need to detect: "#E_TOO_MANY_USERS" and then wait some second and resend? How would this look like? Many thanks for your help!
Posts: 8110
Threads: 43
Joined: Jun 2015
Reputation:
471
The login procedure should not be performed for each request. The token is already saved into storage so it should be used in read/write requests. If the request fails with an error then the token should be refreshed.