[gelöst] [HTTPMOD] Login mit ASP.NET und zusätzlichen login parametern?

Begonnen von roman1528, 17 Juli 2020, 10:46:10

Vorheriges Thema - Nächstes Thema

roman1528

Ergebnis: https://forum.fhem.de/index.php/topic,112942.msg1074500.html#msg1074500

Moin.
Um eine XML abzurufen muss ich mich einloggen. Bin den diversen Beispielen hier im Forum gefolgt. Die Login-Seite wird geholt, Cookies werden gelesen... ABER

es hat eine weile gedauert bis ich dahinter gekommen bin:

Im POST-Request eines Browsers (normaler Login) stehen zusätzliche versteckte Daten, die in den Request müssen (hidden input).

Wie kann ich diese auslesen und dem "sid02Data" voranstellen?

__VIEWSTATE
__VIEWSTATEGENERATOR
__EVENTVALIDATION

Login-Seite:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>
smart-me  - Smart-Energy Lösungen
</title><meta name="description" content="smart-me ist eine einfache Cloud-basierte Energiemonitoring Lösung." /><meta charset="utf-8" /><meta http-equiv="X-UA-Compatible" content="IE=edge" /><meta name="viewport" content="width=device-width, initial-scale=1" />

<link rel="stylesheet" href="Content/css/bootstrap/bootstrap.min.css" type="text/css" />
<link rel="stylesheet" href="Content/css/bootstrap/font-awesome.min.css" type="text/css" />
<link rel="stylesheet" href="Content/css/bootstrap/animate.min.css" type="text/css" />
<link rel="stylesheet" href="Content/css/bootstrap/prettyPhoto.css" type="text/css" />
<link rel="stylesheet" href="Content/css/bootstrap/main3.css" type="text/css" />
<link rel="stylesheet" href="Content/css/bootstrap/responsive.css" type="text/css" />
<!--[if lt IE 9]>
    <script src="Scripts/bootstrap/html5shiv.js" type="text/javascript"></script>
    <script src="Scripts/bootstrap/respond.min.js" type="text/javascript"></script>
    <![endif]-->
<link rel="shortcut icon" href="favicon.ico" />
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="Images/icons/apple-touch-icon-144-precomposed.png" />
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="Images/icons/apple-touch-icon-114-precomposed.png" />
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="Images/icons/apple-touch-icon-72-precomposed.png" />
<link rel="apple-touch-icon-precomposed" href="Images/icons/apple-touch-icon-57-precomposed.png" />
<script src="Scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
<script src="Scripts/bootstrap/bootstrap.min.js" type="text/javascript"></script>
<script src="Scripts/bootstrap/jquery.prettyPhoto.js" type="text/javascript"></script>
<script src="Scripts/bootstrap/jquery.isotope.min.js" type="text/javascript"></script>
<script src="Scripts/bootstrap/main.js" type="text/javascript"></script>
<script src="Scripts/bootstrap/wow.min.js" type="text/javascript"></script>
<script src="Content/Scripts/jquery.cookiefy.min.js" type="text/javascript"></script>
<link href="/Content/css/bootstrap/SignIn.css" type="text/css" rel="stylesheet" />
</head>
<body class="homepage">
<form method="post" action="./SignIn.aspx?ReturnUrl=%2fDetails%2fGetDetailsNew.ashx%3fid%3d<<ZÄHLER-ID>>&amp;id=<<ZÄHLER-ID>>" id="form1">
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="Y8MGO3Kwlq2AM3PiUyWqM7BqoccESSf9cx+ePc1cRLAYQ0mXsLFzpYsd9R3QDNzEbqauznt5qY8p+XIUC1JUJiABohY=" />
</div>
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value="ECDA716A" />
<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="706pTDWfdZ83uEXxAjlDhn7/ivkrcB+IU4WG99MMkKCMkuSbT+kY0Tpp19OvWSpXtDGuz2CkcTcgMfs4KW30yrYCCWNTkRLuX0UjK4bndR47kZniUezq2Rwv+GoWnfysDsBUjFcnONP3ja/FaIn1euvTtUk=" />
</div>

<header id="header">
<nav class="navbar navbar-inverse" role="banner">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="default.aspx">
<img src="Images/bootstrap/logo.png" alt="logo" style="width: 140px;" /></a>
</div>
<div class="collapse navbar-collapse navbar-right">
<ul class="nav navbar-nav">
<li><a href="Details/V2/All.aspx">Login</a></li>
<li><a href="Description/HowItWorks.aspx">Wie es funktioniert</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Anwendungen <i class="fa fa-angle-down"></i></a>
<ul class="dropdown-menu">
<li><a href="Description/Solutions.aspx?slide=0">Liegenschaften</a></li>
<li><a href="Description/Solutions.aspx?slide=1">Industrie</a></li>
<li><a href="Description/Solutions.aspx?slide=2">E-Mobilität</a></li>
</ul>
</li>
<li><a href="Description/Products.aspx">Produkte</a></li>
<li><a href="Description/Pricing.aspx">Preise</a></li>
<li><a href="buy/">Kaufen</a></li>
<li><a href="Description/Demo/">Live demo</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Support <i class="fa fa-angle-down"></i></a>
<ul class="dropdown-menu">
<li><a href="installation/">Installation</a></li>
<li><a href="Description/Tutorials/">Tutorials</a></li>
<li><a href="Description/Tutorials/OnlineTraining.aspx">Online Schulungen</a></li>
<li><a href="http://wiki.smart-me.com" target="_blank">Wiki</a></li>
<li><a href="http://wiki.smart-me.com/index.php/Downloads" target="_blank">Downloads</a></li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Mehr <i class="fa fa-angle-down"></i></a>
<ul class="dropdown-menu">
<li><a href="Description/App.aspx">Apps</a></li>
<li><a href="Description/billing/">smart-me Billing</a></li>
<li><a href="Developer/">Entwickler</a></li>
<li><a href="About/AboutUs.aspx">Über uns</a></li>
<li><a href="About/ContactUs.aspx">Kontakt</a></li>
</ul>
</li>
</ul>
</div>
</div>

</nav>

</header>

<div class="container">
<div class="row">
<div class="col-sm-6 col-md-4 col-md-offset-4">
<div class="account-wall">
<div id="my-tab-content" class="tab-content">
<div class="tab-pane active" id="login">
<img class="profile-img" src="Images/logoBlueSmall.png" alt="" style="width:140px" />
<table id="ContentPlaceHolder1_Login1" cellspacing="0" cellpadding="0" style="border-collapse:collapse;">
<tr>
<td>
<p class="validation-summary-errors">
</p>
<input name="ctl00$ContentPlaceHolder1$Login1$UserName" type="text" id="ContentPlaceHolder1_Login1_UserName" class="form-control" autofocus="" placeholder="Benutzername" />
<input name="ctl00$ContentPlaceHolder1$Login1$Password" type="password" id="ContentPlaceHolder1_Login1_Password" class="form-control" placeholder="Passwort" />
<input type="submit" name="ctl00$ContentPlaceHolder1$Login1$ctl01" value="Login" class="btn btn-lg btn-default btn-block" />
</td>
</tr>
</table>
<br />
<div id="tabs" data-tabs="tabs">
<p class="text-center"><a href="Users/SignUp.aspx">Als neuer Benutzer registieren</a></p>
<p class="text-center"><a href="Users/RequestPasswordReset.aspx">Passwort vergessen?</a></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<br />

<footer id="footer" class="midnight-blue">
<div class="container">
<div class="row">
<div class="col-sm-6">
&copy; 2018 <a target="_blank" href="https://smart-me.com" title="smart-me smart-energy">smart-me</a>
</div>
<div class="col-sm-6">
<ul class="pull-right">
<li><a href="About/Privacy.aspx">Datenschutzrichtlinie</a></li>
<li><a href="About/TermsOfService.aspx">Nutzungsbedingungen</a></li>
<li><a href="About/ContactUs.aspx">Kontakt</a></li>
<li><a href="About/LegalNotice.aspx">Impressum</a></li>
</ul>
</div>
</div>
</div>
</footer>

</form>
<script type="text/javascript">

        $('body').cookiefy({
            displayedHtml: 'Um unsere Webseite für Sie optimal zu gestalten und fortlaufend verbessern zu können, verwenden wir Cookies. Durch die weitere Nutzung der Webseite stimmen Sie der Verwendung von Cookies zu. Weitere Informationen zu Cookies erhalten Sie in unserer Datenschutzrichtline'
        });

        var _gaq = _gaq || [];
        _gaq.push(['_setAccount', 'UA-39019091-1']);
        _gaq.push(['_trackPageview']);

        (function () {
            var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
            ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
            var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
        })();

    </script>
</body>
</html>


Hier noch ein list vom Device:
Internals:
   BUSY       0
   CFGFN     
   DEF        https://www.smart-me.com/Details/GetDetailsNew.ashx?id=<<ZÄHLER-ID>> 0
   FUUID      5f10990f-f33f-8842-5e72-8a8146beea1a6cc2
   Interval   0
   LASTSEND   1594974367.67264
   LastAuthTry 2020-07-17 10:26:04
   MainURL    https://www.smart-me.com/Details/GetDetailsNew.ashx?id=<<ZÄHLER-ID>>
   ModuleVersion 3.5.22 - 7.2.2020
   NAME       solar_xml_test
   NOTIFYDEV  global
   NR         2166
   NTFY_ORDER 50-solar_xml_test
   STATE      ???
   TRIGGERTIME 0
   TRIGGERTIME_FMT
   TYPE       HTTPMOD
   addr       https://www.smart-me.com:443
   auth       0
   buf       
   code       200
   compress   1
   conn       
   data       
   displayurl https://www.smart-me.com:443/SignIn.aspx?ReturnUrl=%2fDetails%2fGetDetailsNew.ashx%3fid%3d<<ZÄHLER-ID>>&id=<<ZÄHLER-ID>>
   header     Cookie: $sid
Cookie: ASP.NET_SessionId=255kfaefkck2kidiii4isqwu; __cfduid=de727087768a4b83ca49b7bbb4b307b351594974025
   host       www.smart-me.com
   httpbody   
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>
smart-me  - Smart energy solutions
</title><meta name="description" content="smart-me is a simple Cloud-based Energy Monitoring Solution." /><meta charset="utf-8" /><meta http-equiv="X-UA-Compatible" content="IE=edge" /><meta name="viewport" content="width=device-width, initial-scale=1" />

<link rel="stylesheet" href="Content/css/bootstrap/bootstrap.min.css" type="text/css" />
<link rel="stylesheet" href="Content/css/bootstrap/font-awesome.min.css" type="text/css" />
<link rel="stylesheet" href="Content/css/bootstrap/animate.min.css" type="text/css" />
<link rel="stylesheet" href="Content/css/bootstrap/prettyPhoto.css" type="text/css" />
<link rel="stylesheet" href="Content/css/bootstrap/main3.css" type="text/css" />
<link rel="stylesheet" href="Content/css/bootstrap/responsive.css" type="text/css" />
<!--[if lt IE 9]>
    <script src="Scripts/bootstrap/html5shiv.js" type="text/javascript"></script>
    <script src="Scripts/bootstrap/respond.min.js" type="text/javascript"></script>
    <![endif]-->
<link rel="shortcut icon" href="favicon.ico" />
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="Images/icons/apple-touch-icon-144-precomposed.png" />
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="Images/icons/apple-touch-icon-114-precomposed.png" />
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="Images/icons/apple-touch-icon-72-precomposed.png" />
<link rel="apple-touch-icon-precomposed" href="Images/icons/apple-touch-icon-57-precomposed.png" />
<script src="Scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
<script src="Scripts/bootstrap/bootstrap.min.js" type="text/javascript"></script>
<script src="Scripts/bootstrap/jquery.prettyPhoto.js" type="text/javascript"></script>
<script src="Scripts/bootstrap/jquery.isotope.min.js" type="text/javascript"></script>
<script src="Scripts/bootstrap/main.js" type="text/javascript"></script>
<script src="Scripts/bootstrap/wow.min.js" type="text/javascript"></script>
<script src="Content/Scripts/jquery.cookiefy.min.js" type="text/javascript"></script>
<link href="/Content/css/bootstrap/SignIn.css" type="text/css" rel="stylesheet" />
</head>
<body class="homepage">
<form method="post" action="./SignIn.aspx?ReturnUrl=%2fDetails%2fGetDetailsNew.ashx%3fid%3d<<ZÄHLER-ID>>&amp;id=<<ZÄHLER-ID>>" id="form1">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="sV4MotHGv2vAU/SPhMTmTYUwseJMR8vf0JBeJC0UVqwmrhUHGwYI8jwengzuIjU5Akov4dqDCTDdsOrgPVmwqoP8rrQ=" />
<input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value="ECDA716A" />
<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="3MQwDHa/1WsFzaTAtxRoVZanYmQIhxi2BFSB9vG0WNXz3RR1o2dkyNzGuz+YumRmJJWkw+6NNGNekcBCMnGe2gbMX2b6xyt3R4v6RFLPrkhL4CXlNnSHA7IZENlpG3HC7ibp/R+PoLmPKvWygqLNoQLPhH8=" />

<header id="header">
<nav class="navbar navbar-inverse" role="banner">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="default.aspx">
<img src="Images/bootstrap/logo.png" alt="logo" style="width: 140px;" /></a>
</div>
<div class="collapse navbar-collapse navbar-right">
<ul class="nav navbar-nav">
<li><a href="Details/V2/All.aspx">Login</a></li>
<li><a href="Description/HowItWorks.aspx">How it works</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Solutions <i class="fa fa-angle-down"></i></a>
<ul class="dropdown-menu">
<li><a href="Description/Solutions.aspx?slide=0">Properties</a></li>
<li><a href="Description/Solutions.aspx?slide=1">Industrial</a></li>
<li><a href="Description/Solutions.aspx?slide=2">E-Mobility</a></li>
</ul>
</li>
<li><a href="Description/Products.aspx">Products</a></li>
<li><a href="Description/Pricing.aspx">Pricing</a></li>
<li><a href="buy/">Buy</a></li>
<li><a href="Description/Demo/">Live Demo</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Support <i class="fa fa-angle-down"></i></a>
<ul class="dropdown-menu">
<li><a href="installation/">Installation</a></li>
<li><a href="Description/Tutorials/">Tutorials</a></li>
<li><a href="Description/Tutorials/OnlineTraining.aspx">Online training</a></li>
<li><a href="http://en.wiki.smart-me.com" target="_blank">Wiki</a></li>
<li><a href="http://en.wiki.smart-me.com/index.php/Downloads" target="_blank">Downloads</a></li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">More <i class="fa fa-angle-down"></i></a>
<ul class="dropdown-menu">
<li><a href="Description/App.aspx">Apps</a></li>
<li><a href="Description/billing/">smart-me Billing</a></li>
<li><a href="Developer/">Developer</a></li>
<li><a href="About/AboutUs.aspx">About us</a></li>
<li><a href="About/ContactUs.aspx">Contact</a></li>
</ul>
</li>
</ul>
</div>
</div>

</nav>

</header>

<div class="container">
<div class="row">
<div class="col-sm-6 col-md-4 col-md-offset-4">
<div class="account-wall">
<div id="my-tab-content" class="tab-content">
<div class="tab-pane active" id="login">
<img class="profile-img" src="Images/logoBlueSmall.png" alt="" style="width:140px" />
<table id="ContentPlaceHolder1_Login1" cellspacing="0" cellpadding="0">
<tr>
<td>
<p class="validation-summary-errors">
</p>
<input name="ctl00$ContentPlaceHolder1$Login1$UserName" type="text" id="ContentPlaceHolder1_Login1_UserName" class="form-control" autofocus="" placeholder="User name" />
<input name="ctl00$ContentPlaceHolder1$Login1$Password" type="password" id="ContentPlaceHolder1_Login1_Password" class="form-control" placeholder="Password" />
<input type="submit" name="ctl00$ContentPlaceHolder1$Login1$ctl01" value="Sign In" class="btn btn-lg btn-default btn-block" />
</td>
</tr>
</table>
<br />
<div id="tabs" data-tabs="tabs">
<p class="text-center"><a href="Users/SignUp.aspx">Register as new user</a></p>
<p class="text-center"><a href="Users/RequestPasswordReset.aspx">Forgot password?</a></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<br />

<footer id="footer" class="midnight-blue">
<div class="container">
<div class="row">
<div class="col-sm-6">
&copy; 2018 <a target="_blank" href="https://smart-me.com" title="smart-me smart-energy">smart-me</a>
</div>
<div class="col-sm-6">
<ul class="pull-right">
<li><a href="About/Privacy.aspx">Data protection guidelines</a></li>
<li><a href="About/TermsOfService.aspx">Terms of service</a></li>
<li><a href="About/ContactUs.aspx">Contact</a></li>
<li><a href="About/LegalNotice.aspx">Legal details</a></li>
</ul>
</div>
</div>
</div>
</footer>

</form>
<script type="text/javascript">

        $('body').cookiefy({
            displayedHtml: 'We use cookies to ensure that we give you the best experience on our website. If you continue, you agree with &lt;strong&gt;Data protection guidelines&lt;/strong&gt;.'
        });

        var _gaq = _gaq || [];
        _gaq.push(['_setAccount', 'UA-39019091-1']);
        _gaq.push(['_trackPageview']);

        (function () {
            var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
            ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
            var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
        })();

    </script>
</body>
</html>

   httpheader HTTP/1.1 200 OK
Date: Fri, 17 Jul 2020 08:26:07 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: close
Cache-Control: private
Vary: Accept-Encoding
Set-Cookie: ASP.NET_SessionId=sce5mub55v02btjepgctwhy4; path=/; HttpOnly; SameSite=Lax
X-Powered-By: ASP.NET
P3P: CP="CAO PSA OUR"
CF-Cache-Status: DYNAMIC
cf-request-id: 03fd7a8813000072c3c40f7200000001
Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Server: cloudflare
CF-RAY: 5b4293868bc272c3-AMS
Content-Encoding: gzip
   httpversion 1.1
   hu_blocking 0
   hu_filecount 5
   hu_port    443
   hu_portSfx
   ignoreredirects 1
   loglevel   4
   path       /SignIn.aspx?ReturnUrl=%2fDetails%2fGetDetailsNew.ashx%3fid%3d<<ZÄHLER-ID>>&id=<<ZÄHLER-ID>>
   protocol   https
   redirects  0
   sid       
   timeout    2
   url        https://www.smart-me.com:443/SignIn.aspx?ReturnUrl=%2fDetails%2fGetDetailsNew.ashx%3fid%3d<<ZÄHLER-ID>>&id=<<ZÄHLER-ID>>
   value      0
   CompiledRegexes:
   HTTPCookieHash:
     ASP.NET_SessionId;/:
       Name       ASP.NET_SessionId
       Options    path=/; HttpOnly; SameSite=Lax
       Path       /
       Value      sce5mub55v02btjepgctwhy4
     __cfduid;/:
       Name       __cfduid
       Options    expires=Sun, 16-Aug-20 08:20:25 GMT; path=/; domain=.smart-me.com; HttpOnly; SameSite=Lax
       Path       /
       Value      de727087768a4b83ca49b7bbb4b307b351594974025
   QUEUE:
   READINGS:
   REQUEST:
     data       
     header     Cookie: $sid
     ignoreredirects 0
     retryCount 1
     type       update
     url        https://www.smart-me.com:443/SignIn.aspx?ReturnUrl=%2fDetails%2fGetDetailsNew.ashx%3fid%3d<<ZÄHLER-ID>>&id=<<ZÄHLER-ID>
     value      0
   sslargs:
Attributes:
   clearSIdBeforeAuth 1
   enableCookies 1
   handleRedirects 1
   httpVersion 1.1
   reAuthRegex /SignIn.aspx.*
   requestHeader1 Cookie: $sid
   showBody   1
   sid01IdRegex (ASP.NET_SessionId[^;;\n]+)
   sid02Data  ctl00$ContentPlaceHolder1$Login1$UserName=<<E-MAIL>>&ctl00$ContentPlaceHolder1$Login1$Password=<<PASSWORT>>&ctl00%24ContentPlaceHolder1%24Login1%24ctl01=Login
   sid02Header1 Cookie: $sid
   sid02IdRegex Cookie: ([^\n]+)
   sidURL     https://www.smart-me.com/SignIn.aspx?ReturnUrl=%2fDetails%2fGetDetailsNew.ashx%3fid%3d<<ZÄHLER-ID>>
   userattr   requestHeader1 sid01Data sid01Header1 sid01IdRegex sid02Data sid02Header1 sid02IdRegex sidURL


Vielen Dank im Voraus
Grüße^^
i3-10305T 4x3GHz;8GB RAM;250GB & 1TB NVMe:
FHEM 6.2;FTUI;8" Tablet's+Fully;NsPanelPro;HUE;ESPRGBWW;HM(CCU3);Duofern; ASC;MQTT(Tasmota);netatmo;SONOS;eBus;DbLog;XiaomiDevice;NUT;ModbusAttr

RPi3+: FHEM 6.2;I²C;GPIO;RFID;G-Tag;XiaomiBTLESens
RPi3: FHEM 6.2;DIY Relais-Board;I²C;GPIO;RFID;Photovoltaik

amenomade

smart-me hat eine REST API, die sogar BasicAuth unterstützt. Da musst Du nur ein Header "Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=="  mitschicken, wo die kryptische Zeichen einfach nur user:passwort base64 kodiert sind,

https://smart-me.com/swagger/ui/index

Pi 3B, Alexa, CUL868+Selbstbau 1/2λ-Dipol-Antenne, USB Optolink / Vitotronic, Debmatic und HM / HmIP Komponenten, Rademacher Duofern Jalousien, Fritz!Dect Thermostaten, Proteus

roman1528

Zitat von: amenomade am 17 Juli 2020, 17:22:44
smart-me hat eine REST API, die sogar BasicAuth unterstützt. Da musst Du nur ein Header "Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=="  mitschicken, wo die kryptische Zeichen einfach nur user:passwort base64 kodiert sind,

https://smart-me.com/swagger/ui/index

Moin.

Danke, die ist bekannt... liefert aber nur alle 60 Sekunden neue Daten wenn man kein Premium kauft. Ja... LifeTime 149€ okayyyy... aber wieso wenn es anders geht. [Man könnte es ja auch einfach ohne Cloud realisieren... bei dem Kaufpreis]
Die XML-Daten die ich ziehen möchte aktualisieren öfters... teilweise in Sekundenschritten... scheinbar ein Poll oder so. Diese XML liefert auch die LiveDaten für das Frontend von smart-me.

Ist es irgendwie möglich "name" und "value" (3 mal) aus der html zu lesen und in den neuen request zu verpacken? also innerhalb HTTPMOD, oder wird das bloß brutal aufwändig? mehrere Umwege möchte ich nämlich ungern gehen.

Grüße^^
i3-10305T 4x3GHz;8GB RAM;250GB & 1TB NVMe:
FHEM 6.2;FTUI;8" Tablet's+Fully;NsPanelPro;HUE;ESPRGBWW;HM(CCU3);Duofern; ASC;MQTT(Tasmota);netatmo;SONOS;eBus;DbLog;XiaomiDevice;NUT;ModbusAttr

RPi3+: FHEM 6.2;I²C;GPIO;RFID;G-Tag;XiaomiBTLESens
RPi3: FHEM 6.2;DIY Relais-Board;I²C;GPIO;RFID;Photovoltaik

amenomade

Also, theoretisch ist alles machbar. Einfach vielleicht aber nicht. Deswegen gibt es eine API...

Sekündlich eine Seite abfragen kann aber dazu führen, dass die Webseite irgendein "ban" Mechanismus einsetzt...

Zur Frage: Das ganze div aspNetHidden in sid holen
Dieses dann mit eine zusätzlich parse Funktion in myUtils und die "replacement" Funktionen von HTTPMOD benutzen
Pi 3B, Alexa, CUL868+Selbstbau 1/2λ-Dipol-Antenne, USB Optolink / Vitotronic, Debmatic und HM / HmIP Komponenten, Rademacher Duofern Jalousien, Fritz!Dect Thermostaten, Proteus

amenomade

So... hab es probiert. Nach ein paar falsche Requests hat mich smart-me.com gebannt. Versuche morgen wieder.

Pi 3B, Alexa, CUL868+Selbstbau 1/2λ-Dipol-Antenne, USB Optolink / Vitotronic, Debmatic und HM / HmIP Komponenten, Rademacher Duofern Jalousien, Fritz!Dect Thermostaten, Proteus

amenomade

So... jetzt haben wir "morgen" ;)

Folgendes in myUtils:
sub urlencode {
    my $s = shift;
    $s =~ s/ /+/g;
    $s =~ s/([^A-Za-z0-9\+-])/sprintf("%%%02X", ord($1))/seg;
    return $s;
}
sub getVIEWSTATE
{
my ($sid) = shift;
$sid=~ /__VIEWSTATE" value="(.*?)"/gs;
return urlencode($1);
}

sub getVIEWSTATEGENERATOR
{
my ($sid) = shift;
$sid=~ m/__VIEWSTATEGENERATOR" value="(.*?)"/gs;
return urlencode($1);
}

sub getEVENTVALIDATION
{
my ($sid) = shift;
$sid=~ /__EVENTVALIDATION" value="(.*?)"/gs;
return urlencode($1);
}


und folgende Definition:
defmod smartme HTTPMOD https://www.smart-me.com/Details/V2/All.aspx 0
attr smartme reAuthRegex SignUp.aspx
attr smartme replacement01Mode expression
attr smartme replacement01Regex %%VIEWSTATE%%
attr smartme replacement01Value getVIEWSTATE($defs{smartme}{sid})
attr smartme replacement02Mode expression
attr smartme replacement02Regex %%VIEWSTATEGENERATOR%%
attr smartme replacement02Value getVIEWSTATEGENERATOR($defs{smartme}{sid})
attr smartme replacement03Mode expression
attr smartme replacement03Regex %%EVENTVALIDATION%%
attr smartme replacement03Value getEVENTVALIDATION($defs{smartme}{sid})
attr smartme sid01IdRegex (?s)(__VIEWSTATE.*?__EVENTVALIDATION.*?)\/>
attr smartme sid02Data __VIEWSTATE=%%VIEWSTATE%%&__VIEWSTATEGENERATOR=%%VIEWSTATEGENERATOR%%&__EVENTVALIDATION=%%EVENTVALIDATION%%&ctl00$ContentPlaceHolder1$Login1$UserName=testusername&ctl00$ContentPlaceHolder1$Login1$Password=testpassword&ctl00$ContentPlaceHolder1$Login1$ctl01=Sign+In
attr smartme sid02URL https://www.smart-me.com/SignIn.aspx?ReturnUrl=/Details/V2/All.aspx
attr smartme sidHeader01 Origin: https://www.smart-me.com
attr smartme sidHeader02 Referer: https://www.smart-me.com/SignIn.aspx?ReturnUrl=/Details/V2/All.aspx
attr smartme sidHeader03 User-Agent: Mozilla/5.0 (Windows NT 10.0;; Win64;; x64;; rv:78.0) Gecko/20100101 Firefox/78.0

("testusername" und "testpassword" in sid02Data natürlich ersetzen)
Vorsicht in replacementXXValue wenn das Device anders genannt wird : $defs{smartme}{sid} muss mit dem Name stimmen


Damit bin ich angemeldet und komme zu Hauptseite https://www.smart-me.com/Details/V2/All.aspx
(da ich aber kein Device sondern nur ein Testkonto habe, kann ich nicht weiter testen)

Man kann das sicher noch optimieren, aber es ist spät ;) : Z.B. nur eine Funktion für alle 3 Parameter, oder Passwort mit replacementMode key verstecken, usw. Man könnte wahrscheinlich auch mit readings und sid01ParseResponse  statt mit Funktionen in myUtils arbeiten. Hab ich nicht getestet.
Pi 3B, Alexa, CUL868+Selbstbau 1/2λ-Dipol-Antenne, USB Optolink / Vitotronic, Debmatic und HM / HmIP Komponenten, Rademacher Duofern Jalousien, Fritz!Dect Thermostaten, Proteus

roman1528

Moin.

Du bist ein Schatz  ;D nur leider läuft es nicht  :'(

list:
Internals:
   BUSY       0
   DEF        https://www.smart-me.com/Details/GetDetailsNew.ashx?id=m40b79723-0f3c-468c-8853-90bba06917fd 0
   FUUID      5f10990f-f33f-8842-5e72-8a8146beea1a6cc2
   Interval   0
   LASTSEND   1595056847.84038
   LastAuthTry 2020-07-18 09:19:54
   MainURL    https://www.smart-me.com/Details/GetDetailsNew.ashx?id=m40b79723-0f3c-468c-8853-90bba06917fd
   ModuleVersion 3.5.22 - 7.2.2020
   NAME       dr_solar_smartme
   NOTIFYDEV  global
   NR         440
   NTFY_ORDER 50-solar_xml_test
   ReplacementEnabled 1
   STATE      ???
   TRIGGERTIME 0
   TRIGGERTIME_FMT
   TYPE       HTTPMOD
   addr       https://www.smart-me.com:443
   auth       0
   buf       

   code       302
   data       
   displayurl https://www.smart-me.com:443/SignIn.aspx?ReturnUrl=%2fDetails%2fGetDetailsNew.ashx%3fid%3dm40b79723-0f3c-468c-8853-90bba06917fd&id=m40b79723-0f3c-468c-8853-90bba06917fd
   header     Cookie: $sid
Cookie: __cfduid=d30423cb63f47b1d7273f19bf2bebf42a1595056847
   host       www.smart-me.com
   httpbody   
   httpdata   
   httpdatalen -1
   httpheader HTTP/1.1 200 OK
Date: Sat, 18 Jul 2020 07:20:48 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: close
Cache-Control: private
Vary: Accept-Encoding
Set-Cookie: ASP.NET_SessionId=sizg4nyavyhay3p0w2nljzie; path=/; HttpOnly; SameSite=Lax
X-Powered-By: smart-me
P3P: CP="CAO PSA OUR"
CF-Cache-Status: DYNAMIC
cf-request-id: 04026514610000f3ebd7836200000001
Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Server: cloudflare
CF-RAY: 5b4a7133c83ef3eb-LHR
Content-Encoding: gzip
   httpversion 1.1
   ignoreredirects 1
   loglevel   4
   path       /SignIn.aspx?ReturnUrl=%2fDetails%2fGetDetailsNew.ashx%3fid%3dm40b79723-0f3c-468c-8853-90bba06917fd&id=m40b79723-0f3c-468c-8853-90bba06917fd
   protocol   https
   redirects  0
   sid       
   timeout    2
   url        https://www.smart-me.com:443/SignIn.aspx?ReturnUrl=%2fDetails%2fGetDetailsNew.ashx%3fid%3dm40b79723-0f3c-468c-8853-90bba06917fd&id=m40b79723-0f3c-468c-8853-90bba06917fd
   value      0
   CompiledRegexes:
   HTTPCookieHash:
     ASP.NET_SessionId;/:
       Name       ASP.NET_SessionId
       Options    path=/; HttpOnly; SameSite=Lax
       Path       /
       Value      sizg4nyavyhay3p0w2nljzie
     __cfduid;/:
       Name       __cfduid
       Options    expires=Mon, 17-Aug-20 07:20:47 GMT; path=/; domain=.smart-me.com; HttpOnly; SameSite=Lax
       Path       /
       Value      d30423cb63f47b1d7273f19bf2bebf42a1595056847
   QUEUE:
   READINGS:
   REQUEST:
     data       
     header     Cookie: $sid
     ignoreredirects 0
     retryCount 0
     type       update
     url        https://www.smart-me.com:443/SignIn.aspx?ReturnUrl=%2fDetails%2fGetDetailsNew.ashx%3fid%3dm40b79723-0f3c-468c-8853-90bba06917fd&id=m40b79723-0f3c-468c-8853-90bba06917fd
     value      0
   sslargs:
Attributes:
   bodyDecode utf-8
   clearSIdBeforeAuth 1
   enableCookies 1
   handleRedirects 1
   httpVersion 1.1
   reAuthRegex /SignIn.aspx.*
   replacement01Mode expression
   replacement01Regex %%VIEWSTATE%%
   replacement01Value getVIEWSTATE($defs{dr_solar_smartme}{views})
   replacement02Mode expression
   replacement02Regex %%VIEWSTATEGENERATOR%%
   replacement02Value getVIEWSTATEGENERATOR($defs{dr_solar_smartme}{viewg})
   replacement03Mode expression
   replacement03Regex %%EVENTVALIDATION%%
   replacement03Value getEVENTVALIDATION($defs{dr_solar_smartme}{eventv})
   requestHeader1 Cookie: $sid
   showBody   1
   sid01IdRegex (ASP.NET_SessionId[^;;\n]+)
   sid02Data  __VIEWSTATE=%%VIEWSTATE%%&__VIEWSTATEGENERATOR=%%VIEWSTATEGENERATOR%%&__EVENTVALIDATION=%%EVENTVALIDATION%%&ctl00$ContentPlaceHolder1$Login1$UserName=E-MAIL&ctl00$ContentPlaceHolder1$Login1$Password=PASSWORT&ctl00%24ContentPlaceHolder1%24Login1%24ctl01=Login
   sid02Header1 Cookie: $sid
   sid02IdRegex Cookie: ([^\n]+)
   sid02URL   https://www.smart-me.com/SignIn.aspx?ReturnUrl=%2fDetails%2fGetDetailsNew.ashx%3fid%3dm40b79723-0f3c-468c-8853-90bba06917fd
   sidHeader1 Origin: https://www.smart-me.com
   sidHeader2 Referer: https://www.smart-me.com/SignIn.aspx?ReturnUrl=%2fDetails%2fGetDetailsNew.ashx%3fid%3dm40b79723-0f3c-468c-8853-90bba06917fd&id=m40b79723-0f3c-468c-8853-90bba06917fd
   sidHeader3 User-Agent: Mozilla/5.0 (Windows NT 10.0;; Win64;; x64;; rv:78.0) Gecko/20100101 Firefox/78.0
   userattr   replacement01Mode:reading,internal,text,expression,key replacement01Regex replacement01Value replacement02Mode:reading,internal,text,expression,key replacement02Regex replacement02Value replacement03Mode:reading,internal,text,expression,key replacement03Regex replacement03Value requestHeader1 sid01Data sid01Header1 sid01IdRegex sid02Data sid02Header1 sid02IdRegex sid02URL sidHeader1 sidHeader2 sidHeader3
   verbose    5


htmlbody musste ich rausnehmen... da standen nur komische Zeichen und das Forum hat gemeckert.

Log:
2020.07.18 09:20:45 5:  dr_solar_smartme: set called with clearCookies
2020.07.18 09:20:47 5:  dr_solar_smartme: set called with reread
2020.07.18 09:20:47 5:  dr_solar_smartme: GetUpdate called (reread)
2020.07.18 09:20:47 5:  dr_solar_smartme: AddToQueue adds type update to URL https://www.smart-me.com/Details/GetDetailsNew.ashx?id=m40b79723-0f3c-468c-8853-90bba06917fd, no data, header Cookie: $sid, retry 0, initial queue len: 0
2020.07.18 09:20:47 5:  dr_solar_smartme: HandleSendQueue called, qlen = 1
2020.07.18 09:20:47 5:  dr_solar_smartme: GetRegex found precompiled Regex for replacement01 as (?^:%%VIEWSTATE%%)
2020.07.18 09:20:47 5:  dr_solar_smartme: Replace called for type update, regex (?^:%%VIEWSTATE%%), mode expression, value getVIEWSTATE($defs{dr_solar_smartme}{views}) input: Cookie: $sid
2020.07.18 09:20:47 5:  dr_solar_smartme: GetRegex found precompiled Regex for replacement02 as (?^:%%VIEWSTATEGENERATOR%%)
2020.07.18 09:20:47 5:  dr_solar_smartme: Replace called for type update, regex (?^:%%VIEWSTATEGENERATOR%%), mode expression, value getVIEWSTATEGENERATOR($defs{dr_solar_smartme}{viewg}) input: Cookie: $sid
2020.07.18 09:20:47 5:  dr_solar_smartme: GetRegex found precompiled Regex for replacement03 as (?^:%%EVENTVALIDATION%%)
2020.07.18 09:20:47 5:  dr_solar_smartme: Replace called for type update, regex (?^:%%EVENTVALIDATION%%), mode expression, value getEVENTVALIDATION($defs{dr_solar_smartme}{eventv}) input: Cookie: $sid
2020.07.18 09:20:47 5:  dr_solar_smartme: GetRegex found precompiled Regex for replacement01 as (?^:%%VIEWSTATE%%)
2020.07.18 09:20:47 5:  dr_solar_smartme: Replace called for type update, regex (?^:%%VIEWSTATE%%), mode expression, value getVIEWSTATE($defs{dr_solar_smartme}{views}) input:
2020.07.18 09:20:47 5:  dr_solar_smartme: GetRegex found precompiled Regex for replacement02 as (?^:%%VIEWSTATEGENERATOR%%)
2020.07.18 09:20:47 5:  dr_solar_smartme: Replace called for type update, regex (?^:%%VIEWSTATEGENERATOR%%), mode expression, value getVIEWSTATEGENERATOR($defs{dr_solar_smartme}{viewg}) input:
2020.07.18 09:20:47 5:  dr_solar_smartme: GetRegex found precompiled Regex for replacement03 as (?^:%%EVENTVALIDATION%%)
2020.07.18 09:20:47 5:  dr_solar_smartme: Replace called for type update, regex (?^:%%EVENTVALIDATION%%), mode expression, value getEVENTVALIDATION($defs{dr_solar_smartme}{eventv}) input:
2020.07.18 09:20:47 5:  dr_solar_smartme: GetRegex found precompiled Regex for replacement01 as (?^:%%VIEWSTATE%%)
2020.07.18 09:20:47 5:  dr_solar_smartme: Replace called for type update, regex (?^:%%VIEWSTATE%%), mode expression, value getVIEWSTATE($defs{dr_solar_smartme}{views}) input: https://www.smart-me.com/Details/GetDetailsNew.ashx?id=m40b79723-0f3c-468c-8853-90bba06917fd
2020.07.18 09:20:47 5:  dr_solar_smartme: GetRegex found precompiled Regex for replacement02 as (?^:%%VIEWSTATEGENERATOR%%)
2020.07.18 09:20:47 5:  dr_solar_smartme: Replace called for type update, regex (?^:%%VIEWSTATEGENERATOR%%), mode expression, value getVIEWSTATEGENERATOR($defs{dr_solar_smartme}{viewg}) input: https://www.smart-me.com/Details/GetDetailsNew.ashx?id=m40b79723-0f3c-468c-8853-90bba06917fd
2020.07.18 09:20:47 5:  dr_solar_smartme: GetRegex found precompiled Regex for replacement03 as (?^:%%EVENTVALIDATION%%)
2020.07.18 09:20:47 5:  dr_solar_smartme: Replace called for type update, regex (?^:%%EVENTVALIDATION%%), mode expression, value getEVENTVALIDATION($defs{dr_solar_smartme}{eventv}) input: https://www.smart-me.com/Details/GetDetailsNew.ashx?id=m40b79723-0f3c-468c-8853-90bba06917fd
2020.07.18 09:20:47 4:  dr_solar_smartme: HandleSendQueue sends update with timeout 2 to https://www.smart-me.com/Details/GetDetailsNew.ashx?id=m40b79723-0f3c-468c-8853-90bba06917fd, No Data,
header: Cookie: $sid
2020.07.18 09:20:47 5:  HttpUtils url=https://www.smart-me.com/Details/GetDetailsNew.ashx?id=m40b79723-0f3c-468c-8853-90bba06917fd
2020.07.18 09:20:47 4:  IP: www.smart-me.com -> 104.18.42.92
2020.07.18 09:20:47 5:  HttpUtils request header:
GET /Details/GetDetailsNew.ashx?id=m40b79723-0f3c-468c-8853-90bba06917fd HTTP/1.1
Host: www.smart-me.com
User-Agent: fhem
Accept-Encoding: gzip,deflate
Connection: Close
Cookie: $sid

2020.07.18 09:20:47 4:  https://www.smart-me.com/Details/GetDetailsNew.ashx?id=m40b79723-0f3c-468c-8853-90bba06917fd: HTTP response code 302
2020.07.18 09:20:47 5:  HttpUtils https://www.smart-me.com/Details/GetDetailsNew.ashx?id=m40b79723-0f3c-468c-8853-90bba06917fd: Got data, length: 258
2020.07.18 09:20:47 5:  HttpUtils response header:
HTTP/1.1 302 Found
Date: Sat, 18 Jul 2020 07:20:47 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: close
Set-Cookie: __cfduid=d30423cb63f47b1d7273f19bf2bebf42a1595056847; expires=Mon, 17-Aug-20 07:20:47 GMT; path=/; domain=.smart-me.com; HttpOnly; SameSite=Lax
Cache-Control: private
Location: /SignIn.aspx?ReturnUrl=%2fDetails%2fGetDetailsNew.ashx%3fid%3dm40b79723-0f3c-468c-8853-90bba06917fd&id=m40b79723-0f3c-468c-8853-90bba06917fd
X-Powered-By: smart-me
P3P: CP="CAO PSA OUR"
CF-Cache-Status: DYNAMIC
cf-request-id: 040265135b00000712ae0ef200000001
Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Server: cloudflare
CF-RAY: 5b4a71322d290712-LHR
2020.07.18 09:20:47 4:  dr_solar_smartme: Read callback: request type was update retry 0,
header: HTTP/1.1 302 Found
Date: Sat, 18 Jul 2020 07:20:47 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: close
Set-Cookie: __cfduid=d30423cb63f47b1d7273f19bf2bebf42a1595056847; expires=Mon, 17-Aug-20 07:20:47 GMT; path=/; domain=.smart-me.com; HttpOnly; SameSite=Lax
Cache-Control: private
Location: /SignIn.aspx?ReturnUrl=%2fDetails%2fGetDetailsNew.ashx%3fid%3dm40b79723-0f3c-468c-8853-90bba06917fd&id=m40b79723-0f3c-468c-8853-90bba06917fd
X-Powered-By: smart-me
P3P: CP="CAO PSA OUR"
CF-Cache-Status: DYNAMIC
cf-request-id: 040265135b00000712ae0ef200000001
Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Server: cloudflare
CF-RAY: 5b4a71322d290712-LHR, body length 258
2020.07.18 09:20:47 5:  dr_solar_smartme: Read callback: body

Object moved to here.



2020.07.18 09:20:47 4:  dr_solar_smartme: Read is decoding the buffer as utf-8
2020.07.18 09:20:47 5:  dr_solar_smartme: GetCookies is looking for Cookies
2020.07.18 09:20:47 4:  dr_solar_smartme: GetCookies parsed Cookie: __cfduid Wert d30423cb63f47b1d7273f19bf2bebf42a1595056847 Rest expires=Mon, 17-Aug-20 07:20:47 GMT; path=/; domain=.smart-me.com; HttpOnly; SameSite=Lax
2020.07.18 09:20:47 5:  dr_solar_smartme: ExtractSid called, context reading, num
2020.07.18 09:20:47 4:  dr_solar_smartme: checking for redirects, code=302, ignore=0
2020.07.18 09:20:47 4:  dr_solar_smartme: https://www.smart-me.com/Details/GetDetailsNew.ashx?id=m40b79723-0f3c-468c-8853-90bba06917fd: Redirect (1) to https://www.smart-me.com:443/SignIn.aspx?ReturnUrl=%2fDetails%2fGetDetailsNew.ashx%3fid%3dm40b79723-0f3c-468c-8853-90bba06917fd&id=m40b79723-0f3c-468c-8853-90bba06917fd
2020.07.18 09:20:47 5:  dr_solar_smartme: AddToQueue prepends type update to URL https://www.smart-me.com:443/SignIn.aspx?ReturnUrl=%2fDetails%2fGetDetailsNew.ashx%3fid%3dm40b79723-0f3c-468c-8853-90bba06917fd&id=m40b79723-0f3c-468c-8853-90bba06917fd, no data, header Cookie: $sid, retry 0, initial queue len: 0
2020.07.18 09:20:47 5:  dr_solar_smartme: HandleSendQueue called, qlen = 1
2020.07.18 09:20:47 5:  dr_solar_smartme: GetRegex found precompiled Regex for replacement01 as (?^:%%VIEWSTATE%%)
2020.07.18 09:20:47 5:  dr_solar_smartme: Replace called for type update, regex (?^:%%VIEWSTATE%%), mode expression, value getVIEWSTATE($defs{dr_solar_smartme}{views}) input: Cookie: $sid
2020.07.18 09:20:47 5:  dr_solar_smartme: GetRegex found precompiled Regex for replacement02 as (?^:%%VIEWSTATEGENERATOR%%)
2020.07.18 09:20:47 5:  dr_solar_smartme: Replace called for type update, regex (?^:%%VIEWSTATEGENERATOR%%), mode expression, value getVIEWSTATEGENERATOR($defs{dr_solar_smartme}{viewg}) input: Cookie: $sid
2020.07.18 09:20:47 5:  dr_solar_smartme: GetRegex found precompiled Regex for replacement03 as (?^:%%EVENTVALIDATION%%)
2020.07.18 09:20:47 5:  dr_solar_smartme: Replace called for type update, regex (?^:%%EVENTVALIDATION%%), mode expression, value getEVENTVALIDATION($defs{dr_solar_smartme}{eventv}) input: Cookie: $sid
2020.07.18 09:20:47 5:  dr_solar_smartme: GetRegex found precompiled Regex for replacement01 as (?^:%%VIEWSTATE%%)
2020.07.18 09:20:47 5:  dr_solar_smartme: Replace called for type update, regex (?^:%%VIEWSTATE%%), mode expression, value getVIEWSTATE($defs{dr_solar_smartme}{views}) input:
2020.07.18 09:20:47 5:  dr_solar_smartme: GetRegex found precompiled Regex for replacement02 as (?^:%%VIEWSTATEGENERATOR%%)
2020.07.18 09:20:47 5:  dr_solar_smartme: Replace called for type update, regex (?^:%%VIEWSTATEGENERATOR%%), mode expression, value getVIEWSTATEGENERATOR($defs{dr_solar_smartme}{viewg}) input:
2020.07.18 09:20:47 5:  dr_solar_smartme: GetRegex found precompiled Regex for replacement03 as (?^:%%EVENTVALIDATION%%)
2020.07.18 09:20:47 5:  dr_solar_smartme: Replace called for type update, regex (?^:%%EVENTVALIDATION%%), mode expression, value getEVENTVALIDATION($defs{dr_solar_smartme}{eventv}) input:
2020.07.18 09:20:47 5:  dr_solar_smartme: GetRegex found precompiled Regex for replacement01 as (?^:%%VIEWSTATE%%)
2020.07.18 09:20:47 5:  dr_solar_smartme: Replace called for type update, regex (?^:%%VIEWSTATE%%), mode expression, value getVIEWSTATE($defs{dr_solar_smartme}{views}) input: https://www.smart-me.com:443/SignIn.aspx?ReturnUrl=%2fDetails%2fGetDetailsNew.ashx%3fid%3dm40b79723-0f3c-468c-8853-90bba06917fd&id=m40b79723-0f3c-468c-8853-90bba06917fd
2020.07.18 09:20:47 5:  dr_solar_smartme: GetRegex found precompiled Regex for replacement02 as (?^:%%VIEWSTATEGENERATOR%%)
2020.07.18 09:20:47 5:  dr_solar_smartme: Replace called for type update, regex (?^:%%VIEWSTATEGENERATOR%%), mode expression, value getVIEWSTATEGENERATOR($defs{dr_solar_smartme}{viewg}) input: https://www.smart-me.com:443/SignIn.aspx?ReturnUrl=%2fDetails%2fGetDetailsNew.ashx%3fid%3dm40b79723-0f3c-468c-8853-90bba06917fd&id=m40b79723-0f3c-468c-8853-90bba06917fd
2020.07.18 09:20:47 5:  dr_solar_smartme: GetRegex found precompiled Regex for replacement03 as (?^:%%EVENTVALIDATION%%)
2020.07.18 09:20:47 5:  dr_solar_smartme: Replace called for type update, regex (?^:%%EVENTVALIDATION%%), mode expression, value getEVENTVALIDATION($defs{dr_solar_smartme}{eventv}) input: https://www.smart-me.com:443/SignIn.aspx?ReturnUrl=%2fDetails%2fGetDetailsNew.ashx%3fid%3dm40b79723-0f3c-468c-8853-90bba06917fd&id=m40b79723-0f3c-468c-8853-90bba06917fd
2020.07.18 09:20:47 5:  dr_solar_smartme: HandleSendQueue is using Cookie __cfduid with path / and Value d30423cb63f47b1d7273f19bf2bebf42a1595056847 (key __cfduid;/, destination path is /SignIn.aspx?ReturnUrl=%2fDetails%2fGetDetailsNew.ashx%3fid%3dm40b79723-0f3c-468c-8853-90bba06917fd&id=m40b79723-0f3c-468c-8853-90bba06917fd)
2020.07.18 09:20:47 5:  dr_solar_smartme: HandleSendQueue is adding Cookie header: __cfduid=d30423cb63f47b1d7273f19bf2bebf42a1595056847
2020.07.18 09:20:47 4:  dr_solar_smartme: HandleSendQueue sends update with timeout 2 to https://www.smart-me.com:443/SignIn.aspx?ReturnUrl=%2fDetails%2fGetDetailsNew.ashx%3fid%3dm40b79723-0f3c-468c-8853-90bba06917fd&id=m40b79723-0f3c-468c-8853-90bba06917fd, No Data,
header: Cookie: $sid
Cookie: __cfduid=d30423cb63f47b1d7273f19bf2bebf42a1595056847
2020.07.18 09:20:47 5:  HttpUtils url=https://www.smart-me.com:443/SignIn.aspx?ReturnUrl=%2fDetails%2fGetDetailsNew.ashx%3fid%3dm40b79723-0f3c-468c-8853-90bba06917fd&id=m40b79723-0f3c-468c-8853-90bba06917fd
2020.07.18 09:20:47 4:  IP: www.smart-me.com -> 104.18.42.92
2020.07.18 09:20:47 5:  HttpUtils request header:
GET /SignIn.aspx?ReturnUrl=%2fDetails%2fGetDetailsNew.ashx%3fid%3dm40b79723-0f3c-468c-8853-90bba06917fd&id=m40b79723-0f3c-468c-8853-90bba06917fd HTTP/1.1
Host: www.smart-me.com
User-Agent: fhem
Accept-Encoding: gzip,deflate
Connection: Close
Cookie: $sid
Cookie: __cfduid=d30423cb63f47b1d7273f19bf2bebf42a1595056847

2020.07.18 09:20:49 3:  dr_solar_smartme: Read callback: Error: read from https://www.smart-me.com:443 timed out
2020.07.18 09:20:49 4:  dr_solar_smartme: Read callback: request type was update retry 0,
header: HTTP/1.1 200 OK
Date: Sat, 18 Jul 2020 07:20:48 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: close
Cache-Control: private
Vary: Accept-Encoding
Set-Cookie: ASP.NET_SessionId=sizg4nyavyhay3p0w2nljzie; path=/; HttpOnly; SameSite=Lax
X-Powered-By: smart-me
P3P: CP="CAO PSA OUR"
CF-Cache-Status: DYNAMIC
cf-request-id: 04026514610000f3ebd7836200000001
Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Server: cloudflare
CF-RAY: 5b4a7133c83ef3eb-LHR
Content-Encoding: gzip, no body
2020.07.18 09:20:49 5:  dr_solar_smartme: Read callback: body empty
2020.07.18 09:20:49 4:  dr_solar_smartme: Read is decoding the buffer as utf-8
2020.07.18 09:20:49 5:  dr_solar_smartme: GetCookies is looking for Cookies
2020.07.18 09:20:49 4:  dr_solar_smartme: GetCookies parsed Cookie: ASP.NET_SessionId Wert sizg4nyavyhay3p0w2nljzie Rest path=/; HttpOnly; SameSite=Lax
2020.07.18 09:20:49 5:  dr_solar_smartme: ExtractSid called, context reading, num
2020.07.18 09:20:49 4:  dr_solar_smartme: checking for redirects, code=200, ignore=0
2020.07.18 09:20:49 4:  dr_solar_smartme: no redirects to handle
2020.07.18 09:20:49 5:  dr_solar_smartme: GetRegex found precompiled reAuthRegex for  as (?^:/SignIn.aspx.*)
2020.07.18 09:20:49 5:  dr_solar_smartme: CheckAuth is checking buffer with ReAuthRegex (?^:/SignIn.aspx.*)
2020.07.18 09:20:49 5:  dr_solar_smartme: CheckAuth decided no authentication required


Zudem bekomm ich häufig so ein Müll angezeigt den keiner lesen kann... (list)

Aber wir sind schon einen Schritt weiter... ich bekomme ab und an Klartext mit einem Error wegen der Origin.
<!DOCTYPE html>
<html>
<head>
<title>Invalid postback or callback argument. &nbsp;Event validation is enabled using &lt;pages enableEventValidation=&quot;true&quot;/&gt; in configuration or &lt;%@ Page EnableEventValidation=&quot;true&quot; %&gt; in a page. &nbsp;For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. &nbsp;If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.</title>
<meta name="viewport" content="width=device-width" />
<style>
         body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;}
         p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px}
         b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px}
         H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red }
         H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon }
         pre {font-family:"Consolas","Lucida Console",Monospace;font-size:11pt;margin:0;padding:0.5em;line-height:14pt}
         .marker {font-weight: bold; color: black;text-decoration: none;}
         .version {color: gray;}
         .error {margin-bottom: 10px;}
         .expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; }
         @media screen and (max-width: 639px) {
          pre { width: 440px; overflow: auto; white-space: pre-wrap; word-wrap: break-word; }
         }
         @media screen and (max-width: 479px) {
          pre { width: 280px; }
         }
        </style>
</head>
<body bgcolor="white">
<span><H1>Server Error in '/' Application.<hr width=100% size=1 color=silver></H1>
<h2> <i>Invalid postback or callback argument. &nbsp;Event validation is enabled using &lt;pages enableEventValidation=&quot;true&quot;/&gt; in configuration or &lt;%@ Page EnableEventValidation=&quot;true&quot; %&gt; in a page. &nbsp;For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. &nbsp;If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.</i> </h2></span>
<font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif ">
<b> Description: </b>An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
<br><br>
<b> Exception Details: </b>System.ArgumentException: Invalid postback or callback argument. &nbsp;Event validation is enabled using &lt;pages enableEventValidation=&quot;true&quot;/&gt; in configuration or &lt;%@ Page EnableEventValidation=&quot;true&quot; %&gt; in a page. &nbsp;For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. &nbsp;If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.<br><br>
<b>Source Error:</b> <br><br>
<table width=100% bgcolor="#ffffcc">
<tr>
<td>
<code>
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.</code>
</td>
</tr>
</table>
<br>
<b>Stack Trace:</b> <br><br>
<table width=100% bgcolor="#ffffcc">
<tr>
<td>
<code><pre>
[ArgumentException: Invalid postback or callback argument.  Event validation is enabled using &lt;pages enableEventValidation=&quot;true&quot;/&gt; in configuration or &lt;%@ Page EnableEventValidation=&quot;true&quot; %&gt; in a page.  For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them.  If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.]
   System.Web.UI.ClientScriptManager.ValidateEvent(String uniqueId, String argument) +11822878
   System.Web.UI.Control.ValidateEvent(String uniqueID, String eventArgument) +143
   System.Web.UI.WebControls.TextBox.LoadPostData(String postDataKey, NameValueCollection postCollection) +38
   System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad) +558
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2927
</pre></code>
</td>
</tr>
</table>
<br>
<hr width=100% size=1 color=silver>
<b>Version Information:</b>&nbsp;Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.3535.0
</font>
</body>
</html>



Ich hab so ein bissl das gefühl, dass was mit meinen sid01 / sid02 und den Cookies nicht passt. Laut Log scheint er auch irgendwie nicht diese Hash's VIEWSTATE und co. richtig zu lesen.
Könnest du da nochmal drüber schauen? Bitte nicht wundern, ich habe die Variablen der replacements geändert, weil ich das Gefühl hatte, dass er da was falsches ersetzt (ja auch in der myUtils).

Grüße

EDIT: Mir ist da noch was in den Sinn gekommen... <form method="post"> hat das Relevanz? Im Log lese ich immer nur GET.
i3-10305T 4x3GHz;8GB RAM;250GB & 1TB NVMe:
FHEM 6.2;FTUI;8" Tablet's+Fully;NsPanelPro;HUE;ESPRGBWW;HM(CCU3);Duofern; ASC;MQTT(Tasmota);netatmo;SONOS;eBus;DbLog;XiaomiDevice;NUT;ModbusAttr

RPi3+: FHEM 6.2;I²C;GPIO;RFID;G-Tag;XiaomiBTLESens
RPi3: FHEM 6.2;DIY Relais-Board;I²C;GPIO;RFID;Photovoltaik

amenomade

Zitat2020.07.18 09:20:49 3:  dr_solar_smartme: Read callback: Error: read from https://www.smart-me.com:443 timed out

Das ist dein Problem. Der war noch nicht so weit, dass er das Login Verfahren ausführen konnte. Schon beim sid01 Step hat er ein Timeout bekommen
Also, das Timeout erhöhen.
Pi 3B, Alexa, CUL868+Selbstbau 1/2λ-Dipol-Antenne, USB Optolink / Vitotronic, Debmatic und HM / HmIP Komponenten, Rademacher Duofern Jalousien, Fritz!Dect Thermostaten, Proteus

roman1528

Moin.

Timeout 10 und deine Attribute und wir sind wieder einen Schritt weiter...

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.</code>
</td>
</tr>
</table>
<br>
<b>Stack Trace:</b> <br><br>
<table width=100% bgcolor="#ffffcc">
<tr>
<td>
<code><pre>
[FormatException: Invalid length for a Base-64 char array or string.]
   System.Convert.FromBase64_Decode(Char* startInputPtr, Int32 inputLength, Byte* startDestPtr, Int32 destLength) +456
   System.Convert.FromBase64CharPtr(Char* inputPtr, Int32 inputLength) +128
   System.Convert.FromBase64String(String s) +49
   System.Web.UI.ObjectStateFormatter.Deserialize(String inputString, Purpose purpose) +91
   System.Web.UI.Util.DeserializeWithAssert(IStateFormatter2 formatter, String serializedState, Purpose purpose) +61
   System.Web.UI.HiddenFieldPageStatePersister.Load() +177

[ViewStateException: Invalid viewstate.
Client IP: 162.158.159.109
Port: 29184
Referer: https://www.smart-me.com/SignIn.aspx?ReturnUrl=%2fDetails%2fGetDetailsNew.ashx%3fid%3dm40b79723-0f3c-468c-8853-90bba06917fd&amp;id=m40b79723-0f3c-468c-8853-90bba06917fd
Path: /SignIn.aspx
User-Agent: Mozilla/5.0 (Windows NT 10.0;; Win64;; x64;; rv:78.0) Gecko/20100101 Firefox/78.0
ViewState: VzE2gG NBZyvN/pFEqTqW4eTgfetFdcHjLVRlCt9vFr83LA8MZxVdqZrurYoDcOge9qpPgQca2SNc8xnmrJK5Va5Te8=]

[HttpException (0x80004005): The state information is invalid for this page and might be corrupted.]
   System.Web.UI.ViewStateException.ThrowError(Exception inner, String persistedState, String errorPageMessage, Boolean macValidationError) +153
   System.Web.UI.HiddenFieldPageStatePersister.Load() +317
   System.Web.UI.Page.LoadPageStateFromPersistenceMedium() +367
   System.Web.UI.Page.LoadAllState() +46
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +9458
   System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +345
   System.Web.UI.Page.ProcessRequest() +75
   System.Web.UI.Page.ProcessRequest(HttpContext context) +70
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +790
   System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +195
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously) +88
</pre></code>


Ich glaube da geht irgendein URLENCODE in die Hose  ;D

Grüße^^
i3-10305T 4x3GHz;8GB RAM;250GB & 1TB NVMe:
FHEM 6.2;FTUI;8" Tablet's+Fully;NsPanelPro;HUE;ESPRGBWW;HM(CCU3);Duofern; ASC;MQTT(Tasmota);netatmo;SONOS;eBus;DbLog;XiaomiDevice;NUT;ModbusAttr

RPi3+: FHEM 6.2;I²C;GPIO;RFID;G-Tag;XiaomiBTLESens
RPi3: FHEM 6.2;DIY Relais-Board;I²C;GPIO;RFID;Photovoltaik

roman1528

Moin nochmal...

Ich hab's... die Login-Daten sowie der Rest der POST-data sollten natürlich auch URL-encoded sein... Mein Fehler  :-[

Ich hab die XML im httpbody!

Vielen vielen Dank für deine Unterstützung. Das Cookie für die session wird auch übernommen.

Grüße^^
i3-10305T 4x3GHz;8GB RAM;250GB & 1TB NVMe:
FHEM 6.2;FTUI;8" Tablet's+Fully;NsPanelPro;HUE;ESPRGBWW;HM(CCU3);Duofern; ASC;MQTT(Tasmota);netatmo;SONOS;eBus;DbLog;XiaomiDevice;NUT;ModbusAttr

RPi3+: FHEM 6.2;I²C;GPIO;RFID;G-Tag;XiaomiBTLESens
RPi3: FHEM 6.2;DIY Relais-Board;I²C;GPIO;RFID;Photovoltaik

amenomade

Schön :)

Da bitte noch ein [gelöst] im Titel des ersten Posts,
Und für die Nachwelt noch ein "list" des Devices + ggf Code aus myUtils, wie es jetzt aussieht (das ganze natürlich anonymisiert ;) )
Pi 3B, Alexa, CUL868+Selbstbau 1/2λ-Dipol-Antenne, USB Optolink / Vitotronic, Debmatic und HM / HmIP Komponenten, Rademacher Duofern Jalousien, Fritz!Dect Thermostaten, Proteus

roman1528

Ja mach ich.. sobald das stabil läuft...  :o

ich bekomme nämlich immer noch diesen Blödsinn den man nicht lesen kann, woraus httpmod natürlich auch nichts lesen kann...

ich habe allerdings das gefühl, dass ich gebannt wurde, weil ich auch bei 30 Sekunden ein TimeOut bekomme.

An meinem Rechner (gleiche öffentliche IP) bekomme ich allerdings noch zugriff.
Ich glaube httpmod liest nicht beim ersten zugriff auf SignIn.aspx die Daten korrekt aus... sondern erst beim 2. oder 3. mal. in der zwischenzeit sind so viele anfragen eingegangen, dass smart-me dicht macht. 500 unhandled exception, validation error.......

Grüße^^
i3-10305T 4x3GHz;8GB RAM;250GB & 1TB NVMe:
FHEM 6.2;FTUI;8" Tablet's+Fully;NsPanelPro;HUE;ESPRGBWW;HM(CCU3);Duofern; ASC;MQTT(Tasmota);netatmo;SONOS;eBus;DbLog;XiaomiDevice;NUT;ModbusAttr

RPi3+: FHEM 6.2;I²C;GPIO;RFID;G-Tag;XiaomiBTLESens
RPi3: FHEM 6.2;DIY Relais-Board;I²C;GPIO;RFID;Photovoltaik

amenomade

Ja so war es auch bei mir nach ein Paar HTTP 500.

Ich habe mehrere Ideen, wie man es optimieren könnte. Im Moment (zumindest in meiner Version) läuft es so:

- Aufruf Zielseite. Da nicht angemeldet, wird man nach Loginseite (schon) automatisch weitergeleitet
- reAuthRegex merkt, dass eine Authentifizierung nötig ist => sid01 = 2. Aufruf der Zielseite, mit Weiterleitung nach Loginseite
- hier liest man die VIEWSTATE Infos
- Aufruf POST Loginseite, und nach erfolgreicher Anmeldung, automatische Weiterleitung auf Zielseite
- HTTPMOD macht wiederum eine Aufruf der Zielseite

Also insgesamt viele unnötige Requests, davon einige ignoriert werden.
Man kann wahrscheinlich:
- schon beim ersten Aufruf und folgenden automatischen Weiterleitung die VIEWSTATE Daten holen
- Nach dem POST und automatische Weiterleitung direkt das Ergebnis parsen (dontRequeueAfterAuth + sid02ParseResponse)

Und dann bleibt noch die Frage: braucht die Seite systematisch bei jedem Aufruf aktuelle VIEWSTATE Daten von der letzten Antwort, damit er eingeloggt bleibt?

Das habe ich noch nicht ganz analysieren können. Ich komme hoffentlich erst heute Abend drauf.
Pi 3B, Alexa, CUL868+Selbstbau 1/2λ-Dipol-Antenne, USB Optolink / Vitotronic, Debmatic und HM / HmIP Komponenten, Rademacher Duofern Jalousien, Fritz!Dect Thermostaten, Proteus

roman1528

Zitat von: amenomade am 19 Juli 2020, 11:59:57Und dann bleibt noch die Frage: braucht die Seite systematisch bei jedem Aufruf aktuelle VIEWSTATE Daten von der letzten Antwort, damit er eingeloggt bleibt?

So wie ich das sehe braucht es dann nicht direkt wieder eine Auth. Schau dir das Cookie an welches du nach dem GET der XML bekommst (im Browser). Da ist ein fetter .ASPXAUTH-Token und 2 id's drin. Wenn ich die XML im Browser nach einer Weile aktualisiere will er ja auch nicht wieder einen LogIn.

Grüße^^
i3-10305T 4x3GHz;8GB RAM;250GB & 1TB NVMe:
FHEM 6.2;FTUI;8" Tablet's+Fully;NsPanelPro;HUE;ESPRGBWW;HM(CCU3);Duofern; ASC;MQTT(Tasmota);netatmo;SONOS;eBus;DbLog;XiaomiDevice;NUT;ModbusAttr

RPi3+: FHEM 6.2;I²C;GPIO;RFID;G-Tag;XiaomiBTLESens
RPi3: FHEM 6.2;DIY Relais-Board;I²C;GPIO;RFID;Photovoltaik

amenomade

Zitat von: roman1528 am 19 Juli 2020, 12:06:39
Wenn ich die XML im Browser nach einer Weile aktualisiere will er ja auch nicht wieder einen LogIn.

Die Frage ist eher, ob der Browser wieder die aktuellste VIEWSTATE Daten schickt. Aber Du hast Recht, wenn schon ein .ASPXAUTH-TOken da ist, sollte es reichen.
Pi 3B, Alexa, CUL868+Selbstbau 1/2λ-Dipol-Antenne, USB Optolink / Vitotronic, Debmatic und HM / HmIP Komponenten, Rademacher Duofern Jalousien, Fritz!Dect Thermostaten, Proteus

roman1528

Zitat von: amenomade am 19 Juli 2020, 15:18:11
Die Frage ist eher, ob der Browser wieder die aktuellste VIEWSTATE Daten schickt. Aber Du hast Recht, wenn schon ein .ASPXAUTH-TOken da ist, sollte es reichen.

Also mein Mozilla führt nur ein GET mit Anfrage Cookie aus. Ich kann da später aber auch nochmal forschen... Nicht dass ich jetzt Mist erzähle oder so XD
i3-10305T 4x3GHz;8GB RAM;250GB & 1TB NVMe:
FHEM 6.2;FTUI;8" Tablet's+Fully;NsPanelPro;HUE;ESPRGBWW;HM(CCU3);Duofern; ASC;MQTT(Tasmota);netatmo;SONOS;eBus;DbLog;XiaomiDevice;NUT;ModbusAttr

RPi3+: FHEM 6.2;I²C;GPIO;RFID;G-Tag;XiaomiBTLESens
RPi3: FHEM 6.2;DIY Relais-Board;I²C;GPIO;RFID;Photovoltaik

amenomade

Ich glaube, ich weiss warum es nicht immer funktioniert. Die urlencode Funktion ist genug, um normale URL Zeichen zu escapen, aber da wollen wir möglicherweise andere Zeichen in VIEWSTATE Data auch escapen. Z.B. '+'. Und den . dagegen nicht escapen.


Pi 3B, Alexa, CUL868+Selbstbau 1/2λ-Dipol-Antenne, USB Optolink / Vitotronic, Debmatic und HM / HmIP Komponenten, Rademacher Duofern Jalousien, Fritz!Dect Thermostaten, Proteus

amenomade

Neue Version von myUtils (Funktion urlencode geändert, und die 3 andere Funktionen durch eine genarateLogin() ersetzt)
sub urlencode {
    my $s = shift;
    $s =~ s/ /+/g;
    $s =~ s/([^A-Za-z0-9-\.])/sprintf("%%%02X", ord($1))/seg;
    return $s;
}

sub generateLogin
{
my ($sid) = shift;
my $username = 'login@domain.com';
my $password = 'mypassword';
$sid =~ /__VIEWSTATE" value="(.*?)".*?__VIEWSTATEGENERATOR" value="(.*?)".*?__EVENTVALIDATION" value="(.*?)"/gs;
my $login = '__VIEWSTATE='.urlencode($1);
$login .= '&__VIEWSTATEGENERATOR='.urlencode($2);
$login .= '&__EVENTVALIDATION='.urlencode($3);
$login .= '&ctl00$ContentPlaceHolder1$Login1$UserName='.urlencode($username);
$login .= '&ctl00$ContentPlaceHolder1$Login1$Password='.urlencode($password);
$login .= '&ctl00$ContentPlaceHolder1$Login1$ctl01=Sign+In';
return $login;
}


Natürlich login@domain.com und mypassword ersetzen.
Damit scheint es zuverlässiger zu funktionieren.

HTTPMOD:
define smartme HTTPMOD https://www.smart-me.com/Details/GetDetailsNew.ashx?id=<<ID>> 0
attr smartme dontRequeueAfterAuth 1
attr smartme reAuthRegex SignUp.aspx
attr smartme reading01Name Power0
attr smartme reading01XPath-Strict //Element[./Title/text()='Power' and ./Type/text()='0']/Value/text()
attr smartme reading02Name Power1
attr smartme reading02XPath-Strict //Element[./Title/text()='Power' and ./Type/text()='1']/Value/text()
attr smartme reading03Name Counters
attr smartme reading03XPath-Strict //Element[contains(./Title/text(),'Counter')]/Value/text()
attr smartme reading05Name Voltage
attr smartme reading05XPath-Strict //Element[./Title/text()='Voltage']/Value/text()
attr smartme reading06Name Current
attr smartme reading06XPath-Strict //Element[./Title/text()='Current']/Value/text()
attr smartme reading07Name PowerFactor
attr smartme reading07XPath-Strict //Element[./Title/text()='Power Factor']/Value/text()
attr smartme reading09Name LastSeen
attr smartme reading09OExpr FmtDateTime($val)
attr smartme reading09XPath-Strict //Element[./Title/text()='Last seen']/Value/text()
attr smartme reading10Name Consumption
attr smartme reading10XPath-Strict //Element[./Title/text()='Consumption overview']/Value/text()
attr smartme replacement01Mode expression
attr smartme replacement01Regex %%LOGIN%%
attr smartme replacement01Value generateLogin($defs{smartme}{sid})
attr smartme sid01IdRegex (?s)(__VIEWSTATE.*?__EVENTVALIDATION.*?)\/>
attr smartme sid01URL https://www.smart-me.com/SignIn.aspx?ReturnUrl=/Details/GetDetailsNew.ashx?id=<<ID>>
attr smartme sid02Data %%LOGIN%%
attr smartme sid02ParseResponse 1
attr smartme sid02URL https://www.smart-me.com/SignIn.aspx?ReturnUrl=/Details/GetDetailsNew.ashx?id=<<ID>>
attr smartme sidHeader01 Origin: https://www.smart-me.com
attr smartme sidHeader02 Referer: https://www.smart-me.com/SignIn.aspx
attr smartme sidHeader03 User-Agent: Mozilla/5.0 (Windows NT 10.0;; Win64;; x64;; rv:78.0) Gecko/20100101 Firefox/78.0

<<ID>> 3 Mal ersetzen
Ergebnis:
   READINGS:
     2020-07-20 00:32:34   Consumption     -,-,-
     2020-07-20 00:32:34   Counters        0.000,0.000,0.000,,0.000,0.000,0.000,0.000,0.000,0.000
     2020-07-20 00:32:34   Current         0.000
     2020-07-20 00:32:34   LastSeen        2020-07-20 00:31:48
     2020-07-20 00:32:34   Power0          0.0
     2020-07-20 00:32:34   Power1          0.0
     2020-07-20 00:32:34   PowerFactor     0.000
     2020-07-20 00:32:34   Voltage         238.5
Pi 3B, Alexa, CUL868+Selbstbau 1/2λ-Dipol-Antenne, USB Optolink / Vitotronic, Debmatic und HM / HmIP Komponenten, Rademacher Duofern Jalousien, Fritz!Dect Thermostaten, Proteus

roman1528

Moin. Super Cool  8)

Nach langem hin und her hat er es bei mir tatsächlich auch geschafft.
Nehme ich das richtig an? Im urlencode wird alles außer A-Z  a-z  0-9  -  .  escaped?

Er hat bei mir nämlich ziemlich viele anläufe gebraucht um 1. überhaupt die "sid" zu lesen und sich dann erfolgreich einzuloggen.

Mal sehen wie lange das anhält ... werde die nächsten 2-3 Tage das noch beobachten.

Zu XPath:
Ist das version 1.0? Versuche nämlich die Counters direkt mit XPath einzeln auszulesen:
//Element[4]/Value/tokenize(text(),",")[3]
function tokenize() wird, wenn ich das richtig gelesen habe, erst ab XPath 2.0 unterstützt.

Ich vermute dass das von libxml-DingsBums-WieAuchImmer-perl abhängt?

Hab erstmal ganz lieben Dank für deine Hilfe. Melde mich die Tage nochmal.

Grüße^^
i3-10305T 4x3GHz;8GB RAM;250GB & 1TB NVMe:
FHEM 6.2;FTUI;8" Tablet's+Fully;NsPanelPro;HUE;ESPRGBWW;HM(CCU3);Duofern; ASC;MQTT(Tasmota);netatmo;SONOS;eBus;DbLog;XiaomiDevice;NUT;ModbusAttr

RPi3+: FHEM 6.2;I²C;GPIO;RFID;G-Tag;XiaomiBTLESens
RPi3: FHEM 6.2;DIY Relais-Board;I²C;GPIO;RFID;Photovoltaik

amenomade

Ich kann mich dunkel erinnern, dass der Modulautor vor kurzem geschrieben hat, dass XPath 2.0 noch nicht völlig unterstützt wird
Pi 3B, Alexa, CUL868+Selbstbau 1/2λ-Dipol-Antenne, USB Optolink / Vitotronic, Debmatic und HM / HmIP Komponenten, Rademacher Duofern Jalousien, Fritz!Dect Thermostaten, Proteus

amenomade

Ne, finde ich nicht mehr. Vielleicht irre ich mich.

Nutzt du readingXXXPath oder readingXXXPath-Strict?
Pi 3B, Alexa, CUL868+Selbstbau 1/2λ-Dipol-Antenne, USB Optolink / Vitotronic, Debmatic und HM / HmIP Komponenten, Rademacher Duofern Jalousien, Fritz!Dect Thermostaten, Proteus

roman1528

Sorry für die kurze Antwort. Bin mit dem Hund draußen.

readingXXXPath-Strict

Da gibt es 'nen Unterschied?
i3-10305T 4x3GHz;8GB RAM;250GB & 1TB NVMe:
FHEM 6.2;FTUI;8" Tablet's+Fully;NsPanelPro;HUE;ESPRGBWW;HM(CCU3);Duofern; ASC;MQTT(Tasmota);netatmo;SONOS;eBus;DbLog;XiaomiDevice;NUT;ModbusAttr

RPi3+: FHEM 6.2;I²C;GPIO;RFID;G-Tag;XiaomiBTLESens
RPi3: FHEM 6.2;DIY Relais-Board;I²C;GPIO;RFID;Photovoltaik

amenomade

Ja, mit XPath arbeitet er in HTML Mode, und mit XPath-Strict in XML Mode.

Trotzdem geht tokenize() nicht. Dein Problem kannst Du aber relativ einfach mit userReadings hinkriegen.
Pi 3B, Alexa, CUL868+Selbstbau 1/2λ-Dipol-Antenne, USB Optolink / Vitotronic, Debmatic und HM / HmIP Komponenten, Rademacher Duofern Jalousien, Fritz!Dect Thermostaten, Proteus

roman1528

Na dann mach ich ja alles richtig.

Schaue ich mir morgen an. Sollte ich hinkriegen. Bisschen RegEx klappt ja auch schon  ;D

Grüße^^
i3-10305T 4x3GHz;8GB RAM;250GB & 1TB NVMe:
FHEM 6.2;FTUI;8" Tablet's+Fully;NsPanelPro;HUE;ESPRGBWW;HM(CCU3);Duofern; ASC;MQTT(Tasmota);netatmo;SONOS;eBus;DbLog;XiaomiDevice;NUT;ModbusAttr

RPi3+: FHEM 6.2;I²C;GPIO;RFID;G-Tag;XiaomiBTLESens
RPi3: FHEM 6.2;DIY Relais-Board;I²C;GPIO;RFID;Photovoltaik

roman1528

so..
Fazit nach guten 24 Stunden pollen im 15 Sekunden Takt.

Läuft... mittelmäßig. Ich bekomme ab und an timeouts, 5 Sekunden später wird dann aber doch geholt. timeout steht auf 10.

So richtig non blocking scheint es nicht zu sein. wenn er pollt steht immer connection lost im fhem status und die readings werden auch nicht in ftui aktualisiert. es kommen auch keine events.

global dnsServer für httputils hab ich gesetzt.

'ne Idee was das sein könnte?

Grüße^^
i3-10305T 4x3GHz;8GB RAM;250GB & 1TB NVMe:
FHEM 6.2;FTUI;8" Tablet's+Fully;NsPanelPro;HUE;ESPRGBWW;HM(CCU3);Duofern; ASC;MQTT(Tasmota);netatmo;SONOS;eBus;DbLog;XiaomiDevice;NUT;ModbusAttr

RPi3+: FHEM 6.2;I²C;GPIO;RFID;G-Tag;XiaomiBTLESens
RPi3: FHEM 6.2;DIY Relais-Board;I²C;GPIO;RFID;Photovoltaik

amenomade

Ich würde ein ping -t smart-me.com parallel laufen lassen, und dann gucken, ob Packete verloren gehen.
Zum Vergleich auch ein ping -t auf eine zuverlässige webseite, z.B. 8.8.8.8, um unterscheiden zu können, ob es vom LAN oder von smart-me kommt.

Pi 3B, Alexa, CUL868+Selbstbau 1/2λ-Dipol-Antenne, USB Optolink / Vitotronic, Debmatic und HM / HmIP Komponenten, Rademacher Duofern Jalousien, Fritz!Dect Thermostaten, Proteus

roman1528

Hi.

Du kannst damit mehr anfangen als ich... Ich konnte auch nichts mit ping -t anfangen deswegen hab ich das anders gemacht.

smart-me.com:
root@FHEM-SERVER:~# ping -c 20 -i 15 smart-me.com
PING smart-me.com (172.67.203.243) 56(84) bytes of data.
64 bytes from 172.67.203.243 (172.67.203.243): icmp_seq=1 ttl=54 time=22.5 ms
64 bytes from 172.67.203.243 (172.67.203.243): icmp_seq=2 ttl=54 time=21.1 ms
64 bytes from 172.67.203.243 (172.67.203.243): icmp_seq=3 ttl=54 time=20.4 ms
64 bytes from 172.67.203.243 (172.67.203.243): icmp_seq=4 ttl=54 time=23.4 ms
64 bytes from 172.67.203.243 (172.67.203.243): icmp_seq=5 ttl=54 time=22.1 ms
64 bytes from 172.67.203.243 (172.67.203.243): icmp_seq=6 ttl=54 time=25.4 ms
64 bytes from 172.67.203.243 (172.67.203.243): icmp_seq=7 ttl=54 time=21.0 ms
64 bytes from 172.67.203.243 (172.67.203.243): icmp_seq=8 ttl=54 time=23.3 ms
64 bytes from 172.67.203.243 (172.67.203.243): icmp_seq=9 ttl=54 time=22.5 ms
64 bytes from 172.67.203.243 (172.67.203.243): icmp_seq=10 ttl=54 time=22.9 ms
64 bytes from 172.67.203.243 (172.67.203.243): icmp_seq=11 ttl=54 time=19.9 ms
64 bytes from 172.67.203.243 (172.67.203.243): icmp_seq=12 ttl=54 time=23.9 ms
64 bytes from 172.67.203.243 (172.67.203.243): icmp_seq=13 ttl=54 time=23.4 ms
64 bytes from 172.67.203.243 (172.67.203.243): icmp_seq=14 ttl=54 time=23.3 ms
64 bytes from 172.67.203.243 (172.67.203.243): icmp_seq=15 ttl=54 time=21.7 ms
64 bytes from 172.67.203.243 (172.67.203.243): icmp_seq=16 ttl=54 time=23.6 ms
64 bytes from 172.67.203.243 (172.67.203.243): icmp_seq=17 ttl=54 time=25.6 ms
64 bytes from 172.67.203.243 (172.67.203.243): icmp_seq=18 ttl=54 time=20.9 ms
64 bytes from 172.67.203.243 (172.67.203.243): icmp_seq=19 ttl=54 time=21.9 ms
64 bytes from 172.67.203.243 (172.67.203.243): icmp_seq=20 ttl=54 time=22.6 ms

--- smart-me.com ping statistics ---
20 packets transmitted, 20 received, 0% packet loss, time 285228ms
rtt min/avg/max/mdev = 19.957/22.629/25.643/1.472 ms


1.1.1.1:
root@FHEM-SERVER:~# ping -c 20 -i 15 1.1.1.1
PING 1.1.1.1 (1.1.1.1) 56(84) bytes of data.
64 bytes from 1.1.1.1: icmp_seq=1 ttl=56 time=13.7 ms
64 bytes from 1.1.1.1: icmp_seq=2 ttl=56 time=11.7 ms
64 bytes from 1.1.1.1: icmp_seq=3 ttl=56 time=16.0 ms
64 bytes from 1.1.1.1: icmp_seq=4 ttl=56 time=11.9 ms
64 bytes from 1.1.1.1: icmp_seq=5 ttl=56 time=15.4 ms
64 bytes from 1.1.1.1: icmp_seq=6 ttl=56 time=13.5 ms
64 bytes from 1.1.1.1: icmp_seq=7 ttl=56 time=12.0 ms
64 bytes from 1.1.1.1: icmp_seq=8 ttl=56 time=12.8 ms
64 bytes from 1.1.1.1: icmp_seq=9 ttl=56 time=13.4 ms
64 bytes from 1.1.1.1: icmp_seq=10 ttl=56 time=13.1 ms
64 bytes from 1.1.1.1: icmp_seq=11 ttl=56 time=15.6 ms
64 bytes from 1.1.1.1: icmp_seq=12 ttl=56 time=13.2 ms
64 bytes from 1.1.1.1: icmp_seq=13 ttl=56 time=10.9 ms
64 bytes from 1.1.1.1: icmp_seq=14 ttl=56 time=15.4 ms
64 bytes from 1.1.1.1: icmp_seq=15 ttl=56 time=13.9 ms
64 bytes from 1.1.1.1: icmp_seq=16 ttl=56 time=14.5 ms
64 bytes from 1.1.1.1: icmp_seq=17 ttl=56 time=12.8 ms
64 bytes from 1.1.1.1: icmp_seq=18 ttl=56 time=19.6 ms
64 bytes from 1.1.1.1: icmp_seq=19 ttl=56 time=15.3 ms
64 bytes from 1.1.1.1: icmp_seq=20 ttl=56 time=13.8 ms

--- 1.1.1.1 ping statistics ---
20 packets transmitted, 20 received, 0% packet loss, time 285248ms
rtt min/avg/max/mdev = 10.951/13.977/19.663/1.908 ms


ausgeführt natürlich auf dem FHEM-Rechner

Grüße^^
i3-10305T 4x3GHz;8GB RAM;250GB & 1TB NVMe:
FHEM 6.2;FTUI;8" Tablet's+Fully;NsPanelPro;HUE;ESPRGBWW;HM(CCU3);Duofern; ASC;MQTT(Tasmota);netatmo;SONOS;eBus;DbLog;XiaomiDevice;NUT;ModbusAttr

RPi3+: FHEM 6.2;I²C;GPIO;RFID;G-Tag;XiaomiBTLESens
RPi3: FHEM 6.2;DIY Relais-Board;I²C;GPIO;RFID;Photovoltaik

amenomade

Bringt nicht viel.
Das muss dauerhaft laufen, ggf über Fhem mit Modul ping und entspr. Logs. Dann zur Zeit wo Problemen auf dem HTTPMOD auftreten analysiert werden.

Sorry, unter Linux kein -t, sondern einfach ohne Option (nur Seite oder IP). Dann läuft es bis manueller Unterbrechung
Pi 3B, Alexa, CUL868+Selbstbau 1/2λ-Dipol-Antenne, USB Optolink / Vitotronic, Debmatic und HM / HmIP Komponenten, Rademacher Duofern Jalousien, Fritz!Dect Thermostaten, Proteus

roman1528

So mit "O"

Ich bin tatsächlich wieder einen Schritt weiter.
attr DEVICE requestHeader1 Referer: https://www.smart-me.com/Details/V2/All.aspx
läuft deutlich besser. Das ist auch die Seite, die die XML im !Sekundentakt! pollt.
Wenn man im Browser die Nezwerkanalyse laufen lässt, sieht man auch hier ab und an längere Ladezeiten bzw. Timeouts. Seltener als bei httpmod aber es gibt sie.

Kann es sein das das XPath blocking ist? Mal angenommen httpmod & httputils sind korrekt konfiguriert und laufen astrein non-blocking... Woher kommt dann immer das Connection lost.....?

Grüße^^
i3-10305T 4x3GHz;8GB RAM;250GB & 1TB NVMe:
FHEM 6.2;FTUI;8" Tablet's+Fully;NsPanelPro;HUE;ESPRGBWW;HM(CCU3);Duofern; ASC;MQTT(Tasmota);netatmo;SONOS;eBus;DbLog;XiaomiDevice;NUT;ModbusAttr

RPi3+: FHEM 6.2;I²C;GPIO;RFID;G-Tag;XiaomiBTLESens
RPi3: FHEM 6.2;DIY Relais-Board;I²C;GPIO;RFID;Photovoltaik

amenomade

Zitat von: roman1528 am 24 Juli 2020, 18:00:55
So mit "O"

Ich bin tatsächlich wieder einen Schritt weiter.
attr DEVICE requestHeader1 Referer: https://www.smart-me.com/Details/V2/All.aspx
läuft deutlich besser. Das ist auch die Seite, die die XML im !Sekundentakt! pollt.
Wenn man im Browser die Nezwerkanalyse laufen lässt, sieht man auch hier ab und an längere Ladezeiten bzw. Timeouts. Seltener als bei httpmod aber es gibt sie.

Kann es sein das das XPath blocking ist? Mal angenommen httpmod & httputils sind korrekt konfiguriert und laufen astrein non-blocking... Woher kommt dann immer das Connection lost.....?

Grüße^^
Vielleicht funktioniert es auch ohne Referer. Die Headers habe ich hinzugefügt als ich noch getestet habe. Ich weiss nicht, ob alle nötig sind.

Auf jeden Fall ist es besser, als Referer die Seite zu haben, die tatsächlich Referer ist ;)

Wie meinst Du "XPath blocking"? XPath macht nur das Parsing von den Daten.
Ich tippe eher auf einen Netzwerk Problem, oder temporäre Blockaden von der smart-me Seite
Pi 3B, Alexa, CUL868+Selbstbau 1/2λ-Dipol-Antenne, USB Optolink / Vitotronic, Debmatic und HM / HmIP Komponenten, Rademacher Duofern Jalousien, Fritz!Dect Thermostaten, Proteus

roman1528

Okay ... Ich schließe das hier erstmal ab. Versuche derweil was anderes. Da ist dein Wissen wahrscheinlich auch wieder gefragt  ;D

Fazit: Funktioniert. Warum die Timeouts weiß ich nicht... habe ich in anderen Devices aber leider auch.. ich werde forschen.

Device:

define dr_solar_smartme HTTPMOD https://www.smart-me.com/Details/GetDetailsNew.ashx?id=<ID> 10
attr dr_solar_smartme userattr reading01Name reading01XPath-Strict reading02Name reading02XPath-Strict reading03Name reading03XPath-Strict reading04Name reading04XPath-Strict reading05Name reading05XPath-Strict reading06Name reading06XPath-Strict reading07Name reading07XPath-Strict reading08Name reading08XPath-Strict reading09Name reading09XPath-Strict reading10Name reading10XPath-Strict reading11Name reading11XPath-Strict reading12Name reading12XPath-Strict reading13Name reading13XPath-Strict reading14Name reading14XPath-Strict reading15Name reading15XPath-Strict reading16Name reading16XPath-Strict reading17Name reading17XPath-Strict reading18Name reading18XPath-Strict reading19Name reading19OExpr reading19XPath-Strict reading20Name reading20XPath-Strict replacement01Mode:reading,internal,text,expression,key replacement01Regex replacement01Value requestHeader1 requestHeader2 requestHeader3 set01Header1 set01Header2 set01Header3 set01Header4 set01IMap set01Method:GET,POST,PUT set01Name set01ParseResponse:0,1 set01URL sid01IdRegex sid01URL sid02Data sid02ParseResponse:0,1 sid02URL sidHeader01 sidHeader02 sidHeader03
attr dr_solar_smartme dontRequeueAfterAuth 1
attr dr_solar_smartme enableControlSet 1
attr dr_solar_smartme enableCookies 1
attr dr_solar_smartme event-on-change-reading .*
attr dr_solar_smartme httpVersion 1.1
attr dr_solar_smartme reAuthRegex /SignIn.aspx.*
attr dr_solar_smartme reading01Name Name
attr dr_solar_smartme reading01XPath-Strict /Folder/FolderName/text()
attr dr_solar_smartme reading02Name ID
attr dr_solar_smartme reading02XPath-Strict /Folder/ID/text()
attr dr_solar_smartme reading03Name SerialNumber
attr dr_solar_smartme reading03XPath-Strict /Folder/SerialNumber/text()
attr dr_solar_smartme reading04Name Power
attr dr_solar_smartme reading04XPath-Strict /Folder/Elements/Element[1]/Value/text()
attr dr_solar_smartme reading05Name Switch
attr dr_solar_smartme reading05XPath-Strict /Folder/Elements/Element[3]/Value/text()
attr dr_solar_smartme reading06Name Counters
attr dr_solar_smartme reading06XPath-Strict /Folder/Elements/Element[4]/Value/text()
attr dr_solar_smartme reading07Name CounterTotalT1
attr dr_solar_smartme reading08Name CounterTotalT2
attr dr_solar_smartme reading09Name CounterImportTotal
attr dr_solar_smartme reading10Name CounterImportT1
attr dr_solar_smartme reading11Name CounterImportT2
attr dr_solar_smartme reading12Name CounterExportTotal
attr dr_solar_smartme reading13Name CounterExportT1
attr dr_solar_smartme reading14Name CounterExportT2
attr dr_solar_smartme reading15Name ActiveTariff
attr dr_solar_smartme reading15XPath-Strict /Folder/Elements/Element[4]/Tariff/text()
attr dr_solar_smartme reading16Name Voltage
attr dr_solar_smartme reading16XPath-Strict /Folder/Elements/Element[5]/Value/text()
attr dr_solar_smartme reading17Name Current
attr dr_solar_smartme reading17XPath-Strict /Folder/Elements/Element[6]/Value/text()
attr dr_solar_smartme reading18Name PowerFactor
attr dr_solar_smartme reading18XPath-Strict /Folder/Elements/Element[7]/Value/text()
attr dr_solar_smartme reading19Name LastConnect
attr dr_solar_smartme reading19OExpr FmtDateTime($val)
attr dr_solar_smartme reading19XPath-Strict /Folder/Elements/Element[9]/Value/text()
attr dr_solar_smartme reading20Name Consumption
attr dr_solar_smartme reading20XPath-Strict /Folder/Elements/Element[8]/Value/text()
attr dr_solar_smartme replacement01Mode expression
attr dr_solar_smartme replacement01Regex %%LOGIN%%
attr dr_solar_smartme replacement01Value generateLogin($defs{dr_solar_smartme}{sid})
attr dr_solar_smartme requestHeader1 Referer: https://www.smart-me.com/Details/V2/All.aspx
attr dr_solar_smartme requestHeader2 User-Agent: Mozilla/5.0 (Windows NT 10.0;; Win64;; x64;; rv:78.0) Gecko/20100101 Firefox/78.0
attr dr_solar_smartme requestHeader3 Host: www.smart-me.com
attr dr_solar_smartme set01Header1 Accept: application/json
attr dr_solar_smartme set01Header2 Authorization: Basic XXXXXXXXXXXXXXXXXXXXXX
attr dr_solar_smartme set01Header3 Content-Length: 0
attr dr_solar_smartme set01Header4 User-Agent: Mozilla/5.0 (Windows NT 10.0;; Win64;; x64;; rv:78.0) Gecko/20100101 Firefox/78.0
attr dr_solar_smartme set01IMap false:off, true:on
attr dr_solar_smartme set01Method PUT
attr dr_solar_smartme set01Name switch
attr dr_solar_smartme set01ParseResponse 1
attr dr_solar_smartme set01URL https://smart-me.com:443/api/Devices/<ID>?switchState=$val&switchNumber=1
attr dr_solar_smartme showBody 1
attr dr_solar_smartme showError 1
attr dr_solar_smartme sid01IdRegex (?s)(__VIEWSTATE.*?__EVENTVALIDATION.*?)\/>
attr dr_solar_smartme sid01URL https://www.smart-me.com/SignIn.aspx?ReturnUrl=%2fDetails%2fGetDetailsNew.ashx%3fid%3d<ID>&id=<ID>
attr dr_solar_smartme sid02Data %%LOGIN%%
attr dr_solar_smartme sid02ParseResponse 1
attr dr_solar_smartme sid02URL https://www.smart-me.com/SignIn.aspx?ReturnUrl=%2fDetails%2fGetDetailsNew.ashx%3fid%3d<ID>&id=<IID>
attr dr_solar_smartme sidHeader01 Origin: https://www.smart-me.com
attr dr_solar_smartme sidHeader02 https://www.smart-me.com/SignIn.aspx?ReturnUrl=%2fDetails%2fGetDetailsNew.ashx%3fid%3d<ID&id=<ID>
attr dr_solar_smartme sidHeader03 User-Agent: Mozilla/5.0 (Windows NT 10.0;; Win64;; x64;; rv:78.0) Gecko/20100101 Firefox/78.0
attr dr_solar_smartme timeout 20
attr dr_solar_smartme verbose 5


myUtils:

sub urlencode {
    my $s = shift;
    $s =~ s/ /+/g;
    $s =~ s/([^A-Za-z0-9-\.])/sprintf("%%%02X", ord($1))/seg;
    return $s;
}

sub generateLogin {
my ($sid) = shift;
my $username = 'e@mail.com';
my $password = 'XXXXXXXXXX';
$sid =~ /__VIEWSTATE" value="(.*?)".*?__VIEWSTATEGENERATOR" value="(.*?)".*?__EVENTVALIDATION" value="(.*?)"/gs;
my $login = '__VIEWSTATE='.urlencode($1);
$login .= '&__VIEWSTATEGENERATOR='.urlencode($2);
$login .= '&__EVENTVALIDATION='.urlencode($3);
$login .= '&ctl00$ContentPlaceHolder1$Login1$UserName='.urlencode($username);
$login .= '&ctl00$ContentPlaceHolder1$Login1$Password='.urlencode($password);
$login .= '&ctl00$ContentPlaceHolder1$Login1$ctl01=Login';
return $login;
}


Vielen Dank amenomade, du hast mir sehr sehr sehr geholfen!

Grüße^^
i3-10305T 4x3GHz;8GB RAM;250GB & 1TB NVMe:
FHEM 6.2;FTUI;8" Tablet's+Fully;NsPanelPro;HUE;ESPRGBWW;HM(CCU3);Duofern; ASC;MQTT(Tasmota);netatmo;SONOS;eBus;DbLog;XiaomiDevice;NUT;ModbusAttr

RPi3+: FHEM 6.2;I²C;GPIO;RFID;G-Tag;XiaomiBTLESens
RPi3: FHEM 6.2;DIY Relais-Board;I²C;GPIO;RFID;Photovoltaik