ckarrie / ckw-ha-gs108e

HomeAssistant Netgear Switch Integration
18 stars 6 forks source link

Support for GS316EPP #20

Open ckarrie opened 1 month ago

ckarrie commented 1 month ago

Add support for GS316EPP requested by @AlessandroTischer in #12

ckarrie commented 1 month ago

Do you use the HomeAssistant OS? If yes, could you login to your Maschine via SSH and provide the Log output when trying to add the Netgear Device to HomeAssistant.

ha core log -f

If there isn't any relevant log output, let me now.

Next step if that fails: try out the Example calls from the README.

AlessandroTischer commented 1 month ago

Do you use the HomeAssistant OS? If yes, could you login to your Maschine via SSH and provide the Log output when trying to add the Netgear Device to HomeAssistant.

ha core log -f

If there isn't any relevant log output, let me now.

Next step if that fails: try out the Example calls from the README.

First of all, thanks for your time and patience.

I'm not using HA OS, I'm running HA core as a Docker container. I enabled debug logging in the HA configuration, then this appeared:

2024-07-06 09:29:00.369 INFO (SyncWorker_5) [custom_components.ckw_hass_gs108e.gs108e] [NetgearSwitchConnector.autodetect_model] called for IP=192.168.188.55
2024-07-06 09:29:00.369 INFO (SyncWorker_5) [custom_components.ckw_hass_gs108e.gs108e] [NetgearSwitchConnector.check_login_url] calling request for url=http://192.168.188.55/login.cgi
2024-07-06 09:29:01.414 INFO (SyncWorker_5) [custom_components.ckw_hass_gs108e.gs108e] [NetgearSwitchConnector.autodetect_model] passed_checks_by_model={'GS105E': {'check_login_form_rand': False, 'check_login_title_tag': False}, 'GS105Ev2': {'check_login_form_rand': False, 'check_login_title_tag': False}, 'GS108E': {'check_login_form_rand': False, 'check_login_title_tag': False, 'check_login_switchinfo_tag': False}, 'GS108Ev3': {'check_login_form_rand': False, 'check_login_title_tag': False, 'check_login_switchinfo_tag': False}, 'GS305EP': {'check_login_form_rand': False, 'check_login_title_tag': False}, 'GS308EP': {'check_login_form_rand': False, 'check_login_title_tag': False}, 'GS316EP': {'check_login_form_rand': False, 'check_login_title_tag': False}, 'GS316EPP': {'check_login_form_rand': False, 'check_login_title_tag': False}} matched_models=[]
2024-07-06 09:29:01.414 INFO (SyncWorker_5) [custom_components.ckw_hass_gs108e.gs108e] [NetgearSwitchConnector.get_login_cookie] calling request.post for url=http://192.168.188.55/login.cgi with login_password=*********
2024-07-06 09:29:02.460 WARNING (SyncWorker_5) [custom_components.ckw_hass_gs108e.gs108e] [ckw_hass_gs108e.get_login_cookie] [IP: 192.168.188.55] Response from switch: "[]"

It seems like it doesn't recognize the model...

Reguarding the python example calls, unfortunately I think I will need some more help, since I'm not familiar at all with python

ckarrie commented 1 month ago

Hmm, none of the checks passed. Even the check_login_form_rand check (calling login.cgi and check if there is a hidden input with id rand).

How the integration checks:

If both fails, either the IP is wrong, IP is blocked or there is no info in the login.cgi. Could you provide the content of http://192.168.188.55/login.cgi

AlessandroTischer commented 1 month ago

Hmm, none of the checks passed. Even the check_login_form_rand check (calling login.cgi and check if there is a hidden input with id rand).

How the integration checks:

  • First check: check_login_form_rand: parses the responded html of login.cgi and looks for a <input id="rand"...>
  • Second check: check_login_title_tag: pareses the responded html of login.cgi and looks the <title>MODEL NAME</title>tag

If both fails, either the IP is wrong, IP is blocked or there is no info in the login.cgi. Could you provide the content of http://192.168.188.55/login.cgi

http://192.168.188.55/login.cgi: image

http://192.168.188.55: image

AlessandroTischer commented 1 month ago

Hmm, none of the checks passed. Even the check_login_form_rand check (calling login.cgi and check if there is a hidden input with id rand).

How the integration checks:

  • First check: check_login_form_rand: parses the responded html of login.cgi and looks for a <input id="rand"...>
  • Second check: check_login_title_tag: pareses the responded html of login.cgi and looks the <title>MODEL NAME</title>tag

If both fails, either the IP is wrong, IP is blocked or there is no info in the login.cgi. Could you provide the content of http://192.168.188.55/login.cgi

UPDATE:

In the custom_components/ckw_hass_gs108e/gs108e/__init__.py file I changed these lines:

LOGIN_HTM_URL_TMPL = "http://{ip}/login.htm"
LOGIN_CGI_URL_TMPL = "http://{ip}/login.cgi"
...
LOGIN_URL = "http://{ip}/login.cgi"

like this:

LOGIN_HTM_URL_TMPL = "http://{ip}"
LOGIN_CGI_URL_TMPL = "http://{ip}"
...
LOGIN_URL = "http://{ip}"

and now I get this output:

2024-07-07 11:32:54.646 INFO (SyncWorker_1) [custom_components.ckw_hass_gs108e.gs108e] [NetgearSwitchConnector.autodetect_model] called for IP=192.168.188.55
2024-07-07 11:32:54.646 INFO (SyncWorker_1) [custom_components.ckw_hass_gs108e.gs108e] [NetgearSwitchConnector.check_login_url] calling request for url=http://192.168.188.55
2024-07-07 11:32:54.704 INFO (SyncWorker_1) [custom_components.ckw_hass_gs108e.gs108e] [NetgearSwitchConnector.autodetect_model] passed_checks_by_model={'GS105E': {'check_login_form_rand': True, 'check_login_title_tag': False}, 'GS105Ev2': {'check_login_form_rand': True, 'check_login_title_tag': False}, 'GS108E': {'check_login_form_rand': True, 'check_login_title_tag': False, 'check_login_switchinfo_tag': False}, 'GS108Ev3': {'check_login_form_rand': True, 'check_login_title_tag': False, 'check_login_switchinfo_tag': False}, 'GS305EP': {'check_login_form_rand': True, 'check_login_title_tag': False}, 'GS308EP': {'check_login_form_rand': True, 'check_login_title_tag': False}, 'GS316EP': {'check_login_form_rand': True, 'check_login_title_tag': False}, 'GS316EPP': {'check_login_form_rand': True, 'check_login_title_tag': True}} matched_models=[<custom_components.ckw_hass_gs108e.gs108e.models.GS316EPP object at 0x7fe566cb3b30>]
2024-07-07 11:32:54.704 INFO (SyncWorker_1) [custom_components.ckw_hass_gs108e.gs108e] [NetgearSwitchConnector.get_login_cookie] calling request.post for url=http://192.168.188.55 with login_password=xxxxxxxxxxxxxx
2024-07-07 11:32:54.741 WARNING (SyncWorker_1) [custom_components.ckw_hass_gs108e.gs108e] [ckw_hass_gs108e.get_login_cookie] [IP: 192.168.188.55] Response from switch: "[]"

This is the html of the login page:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Pragma" content="no-cache">
<title>NETGEAR  GS316EPP</title>
<link rel="stylesheet" type="text/css" href="/loginPage.css">
<!LANGUAGE_SCRIPT_TYPE_KEY>
<script src="/jquery.min.js" type="text/javascript"></script>
<script src="/jquery_migrate_min.js" type="text/javascript"></script>
<script src="/jquery.md5.js" type="text/javascript"></script>
<script src="/loginPage.js" type="text/javascript"></script>
<script type='text/javascript' language='JavaScript'>
function submitLogin()
{
    encryptPwd();
    document.forms[0].submit();
    return true;
}
function onEnterSub(e)
{
    var whKey;

    if (window.event)
    {
        whKey = e.keyCode;
    }
    else if (e.which)
    {
        whKey = e.which;
    }

    if(whKey == '13')
    {
        submitLogin();
    }
}
</script>
</head>
<body id="loginBody">
<form name="login" method="post" onSubmit="return false;" action="/redirect.html" autocomplete="off">
    <input type="hidden" id="submitPwd" name="LoginPassword" value="">
<div id="loginWrapper">
    <div class="netgearLogo" style="height:214px;">
        <a href="http://www.netgear.com/" target="_blank">
            <img src="/switch_logo_login.svg" style="border:none;">
        </a>
        <span class="p-name">GS316EPP</span>
    </div>
    <div class="summary" style="width:85%;"><span class="lang">If logging in for the first time, log in with your switch's default password which is found on the label on the bottom of the switch.</span></div>
    <div id="passwordWrapperdiv" class="passwordWrapper">
        <div id="loginPasswordDiv" class="input-wrapper ng-init-block">

                <div class="input-title editHead active lang">Password</div>
                <input id="Password" class="editBody wideInput" type="password" value="" maxlength="20" onkeypress="onEnterSub(event);" autocomplete="off">
                <div onclick="toggleEye()" class="switch-eye">
                    <i class="icon-eye-off show"></i>
                    <i class="icon-eye-on"></i>
                </div>
                <input type="hidden" id='rand' value="415587398" disabled>
                <span id="loginPageErrorMsg" class="validationRed"></span>

        </div>
    </div>

    <div class="loginButton modalFooterBlockOne apply waves-effect waves-gray btn">
        <div class="btnWrapper" onclick="submitLogin()">
            <a class="lang">LOG IN</a>
        </div>
    </div>
</div>
</form>
</body>
</html>

and it is reachable using http://{IP} or http://{IP}/redirect.html (which brings to http://{IP}/wmi/login)

ckarrie commented 1 month ago

Oh nice, thanks for the response. So Netgear changed the WebUI Endpoints again. I'll take a look into it.

AlessandroTischer commented 1 month ago

Oh nice, thanks for the response. So Netgear changed the WebUI Endpoints again. I'll take a look into it.

Hi! I'm sorry to bother you. Did you manage to make any progress? I have no rush, it's just out of curiosity. Btw, I think I forgot to mention my switch firmware version, which is 1.0.4.1 (it's the latest as far as I know), if it's of any use.