gluap / pyess

Python library for communication with LG ESS power converters
MIT License
31 stars 10 forks source link

Remote browser login #32

Open su-sd opened 2 weeks ago

su-sd commented 2 weeks ago

If somebody needs to connect without access to the "login-wifi", you can use the following script in the browser console:

let password =  "PASSWORD";
let result = await (await fetch(
    "https://IP/v1/user/setting/login",
    {
        method: "PUT",
        body: JSON.stringify({"password": password}),
        headers: {
            "Charset": "UTF-8",
            "Content-Type": "application/json",
        },
    })).json();
sessionStorage.setItem('auth_key', result.auth_key)
sessionStorage.setItem("role", "user")

Not sure where to document.

gluap commented 2 weeks ago

@su-sd did you try that shortly after having authenticated on the login wifi? I had observed getting the token was possible via external network once but later it turned out that was only reproducible within a few minutes after login on wifi.

su-sd commented 1 week ago

@gluap Interesting. Last time I was in the ess wifi was over half a year ago. I logged in since that a few times. I use the following page https://192.168.[ESS.IP]/system/index.html, the root-directory always returns an error. What is the result of the request above when it fails?

gluap commented 1 week ago

Back in the day the response was something with {"success": "false"} . But it seems nowadays you're right: My ess also allows me to log in from the regular network.