Rasmus7700
(Rasmus Balle)
November 11, 2016, 7:47am
1
Hello Guys…
I have a Danfoss Solar Inverter with integrated Web-interface, to see production performance… It can also be read out from RS485.
Is it possible to read out the data from the web-interface when it requires a log-in? The url for log-in is:
http://192.168.50.12/cgi-bin/login_page.tcl
but when i login i get redirected to this:
http://192.168.50.12/cgi-bin/frameset.tcl?sid=3693924495027270401
where the sid changes from each login… Is there any way to deal with this?
rswennen
(Rohnny Swennen)
November 12, 2016, 7:23am
3
Indeed, my HVAC webserver does the same, you authenticate and afterwards it uses the session iD.
This is where I ended up in my rules and it works like a charm.
You would need to tweak it a bit for your purpose but the principle of capturing the session ID and using it to build your URL’s works.
rule "temperatuur"
when
Time cron "0 0/5 * * * ?"
then
var String jsonauth= sendHttpGetRequest("http://x.x.x.x/api/auth/login.json?user=USER&pwd=PASSWORD")
var String sessionid = transform("JSONPATH","$.SessionId", jsonauth)
postUpdate("Session", sessionid)
var String jsonLiving = sendHttpGetRequest("http://10.0.1.130/api/menutree/read_datapoint.json?SessionId=" + sessionid + "&Id=1154")
var String strtempLiving = transform("JSONPATH","$.Data.Value", jsonLiving)
var String tempLiving = transform("REGEX", "\s*(.*)", strtempLiving)
postUpdate("TempLivingCurrent", tempLiving)
end
Rasmus7700
(Rasmus Balle)
November 18, 2016, 8:21pm
4
Looks awesome, exactly what I need…
is it only the http binding that’s needed for this?
rswennen
(Rohnny Swennen)
November 19, 2016, 7:15am
5
Not even, the code above is not relying on http binding, this is standard openhab functionality (at least in 2.0 which is what I’m using, assume it would be the same for the 1.8)
Rasmus7700
(Rasmus Balle)
November 19, 2016, 3:10pm
6
Trying to check what type of auth the web-interfaces uses… seems like it’s POST authorisation…
Just wondering how the format should be for the login URL - since it doesn’t work like @rswennen does it… I try test it in the Chrome browser with the actual url - shouldn’t that work?
The log in screen source code:
<html><head></head>
<body >
<script type="text/javascript">
if(top.window.location.href.indexOf("login_page") == -1)
{
top.window.location='/cgi-bin/login_page.tcl';
}
</script>
</body></html>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<link rel="stylesheet" href="/login.css" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript" src="/footer.js"></script>
<script language=javascript type="text/javascript">
<!--
if (parent.frames.length)
top.location.href= document.location;
// -->
</script>
<title>Login :: 30</title>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%" height="100%">
<tr>
<td width="100%" height="100%" valign="middle" align="center">
<table border="0" cellpadding="0" cellspacing="0" width="1000">
<tr>
<td height="138" id="headerLogin">
<div class="plantName">30</div>
</td>
</tr>
<tr>
<td id="loginForm" align="right" valign="middle">
<form action="/cgi-bin/handle_login.tcl" name="loginform" method="POST">
<table width="700" border="0" cellpadding="0" cellspacing="0">
<tr>
<td colspan="2" align="right" width="100%"><div class="heading">Welcome to
TLX Pro+</div></td>
</tr>
<tr>
<td align="right" width="100%"><label for="user">User:</label> </td>
<td align="right" width="1"><input type="text" id="user" name="user" size="40" maxlength="24"></td>
</tr>
<tr>
<td height="26" colspan="2" width="100%"> </td>
</tr>
<tr>
<td align="right" width="100%"><label for="pw">Password:</label> </td>
<td align="right" width="1"><input type="password" id="pw" name="pw" size="40" maxlength="24"></td>
</tr>
<tr>
<td height="26" colspan="2" align="right" width="100%">
</td>
</tr>
<tr>
<td colspan="2" align="right" width="100%"><input type="submit" class="button" style="text-align: center;" name="submit" id="login" value="Login"></td>
</tr>
<tr>
<td align="right" valign="bottom" colspan="2" class="disclaimer"><br><br><br>All shown values are based upon actual inverter data and are not legally binding.</td>
</tr>
</table>
<input type="hidden" name="sid" value="">
</form>
</td>
</tr>
<tr>
<td height="46" id="loginFooter" valign="middle">
<table id="footer" width="100%">
<tr>
<td class="vasak" width="720">
<ul>
<li><a href="#" target="dispContent" onclick="openLang(''); return false;">Language</a></li>
<li><a href="#" target="dispContent" onclick="openContact(''); return false;">Contact</a></li>
</ul>
</td>
<td class="parem" width="350"><a href="http://www.danfoss.com/solar" target="_blank">Danfoss Solar Inverters</a></td>
</tr>
</table>
</td>
</tr>
</table>
<div id="customerWrapper">
<div id="customerData1"></div>
<div id="customerData2"><img src='/images/login_image_1.jpg'></div>
</div>
</td>
</tr>
</table>
</body>
</html>
rswennen
(Rohnny Swennen)
November 19, 2016, 6:33pm
7
I’m not an expert but I think you should try along these lines
http://YOURURL/cgi-bin/handle_login.tcl?user=XXX&pw=YYY
with XXX your username and YYY your password. You are absolutely right you should be able to do test this in a browser, once you have the exact URL pointing to the login cgi bin script handle_login.tcl you can then try to do it in openhab
Rasmus7700
(Rasmus Balle)
November 19, 2016, 9:16pm
8
This doesn’t work… seems like I need some kind of script to do the login, you haven’t put anything else in a file or something - only the scrip you write here?