ckarrie / ckw-ha-gs108e

HomeAssistant Netgear Switch Integration
18 stars 6 forks source link

ckw-ha-gs108e

HomeAssistant Netgear Switch Integration

What it does

Grabs statistical network data from supported Netgear Switches

How it works

  1. Detecting Switch Model/Product in login.cgi
  2. Connects to the Switch and asks for a cookie (http://IP_OF_SWITCH/login.cgi)
  3. HTTP-Request send to the Switch twice (http://IP_OF_SWITCH/portStatistics.cgi) and compared with previous data ("in response time")

Which entities

List of port sensors

Sensor Name Platform mapped key from get_switch_infos() Unit
Port {port} Traffic Received SENSOR port_{port}_traffic_rx_mbytes MB (in response time)
Port {port} Traffic Transferred SENSOR port_{port}_traffic_tx_mbytes MB (in response time)
Port {port} Receiving SENSOR port_{port}_speed_rx_mbytes MB/s
Port {port} Transferring SENSOR port_{port}_speed_tx_mbytes MB/s
Port {port} IO SENSOR port_{port}_speed_io_mbytes MB/s
Port {port} Total Received SENSOR port_{port}_sum_rx_mbytes MB (since last switch reboot/reset)
Port {port} Total Transferred SENSOR port_{port}_sum_tx_mbytes MB (since last switch reboot/reset)
Port {port} Connection Speed SENSOR port_{port}_connection_speed MB/s
Port {port} Status BINARY_SENSOR port_{port}_status "on"/"off"
Port {poe_port} POE Power SWITCH port_{poe_port}_poe_power_active "on"/"off"

List of aggregated sensors

Sensor Name Platform mapped key from get_switch_infos() Unit
Switch IO SENSOR sum_port_speed_bps_io MB/s
Switch Traffic Received SENSOR sum_port_traffic_rx MB (in response time)
Switch Traffic Transferred SENSOR sum_port_traffic_tx MB (in response time)

Supported and tested Netgear Models/Products and firmwares

Model Ports Firmwares Bootloader
GS105E 5 ?
GS108E 8 V1.00.11 V1.00.03
GS105Ev3 5 ?
GS108Ev3 8 V2.00.05, V2.06.10, V2.06.17, V2.06.24 V2.06.01 - V2.06.03
GS305EP 5 V1.0.1.1

Supported firmware languages: GR (German), EN (English)

How to integrate in your HomeAssistant

Open your Home Assistant instance and open a repository inside the Home Assistant Community Store.

  1. Goto HACS > Integrations
  2. Click on the right corner on the vertical dots and select "Custom Repositories"
  3. Add "https://github.com/ckarrie/ckw-ha-gs108e" as Integration

After adding the integration go to Add Integration and select Netgear GS108e Integration.

Lovelance examples

Example with ha-sankey-chart

image

Example with mini-graph-card

image

type: custom:mini-graph-card
entities:
  - entity: sensor.gs108ev3_192_168_178_8_port_1_io
    show_points: false
    name: QNAP
  - entity: sensor.gs108ev3_192_168_178_8_port_2_io
    show_points: false
    name: P2
  - entity: sensor.gs108ev3_192_168_178_8_port_3_io
    show_points: false
    name: rpi4-001
  - entity: sensor.gs108ev3_192_168_178_8_port_4_io
    show_points: false
    name: Telefon
  - entity: sensor.gs108ev3_192_168_178_8_port_5_io
    show_points: false
    name: Unraid
  - entity: sensor.gs108ev3_192_168_178_8_port_6_io
    show_points: false
    name: Drucker
  - entity: sensor.gs108ev3_192_168_178_8_port_7_io
    show_points: false
    name: Beelink (HA)
  - entity: sensor.gs108ev3_192_168_178_8_port_8_io
    show_points: false
    name: HomeOffice und WLAN
hours_to_show: 0.1
points_per_hour: 1000
name: 192.168.178.8 - GS108Ev3 Büro
line_width: 1
animate: true

ToDo

API Level

create a python venv with requests and lxml

python3 -m venv test-netgear
cd test-netgear
source bin/activate
pip install lxml requests

Using this VENV go to your local source folder

Example calls

cd ~/workspace/src/ckw-ha-gs108e/custom_components/ckw_hass_gs108e
python3
ip = '192.168.178.68'
p = 'fyce4gKZemkqjDY'
import gs108e
sw = gs108e.NetgearSwitchConnector(ip, p)
sw.autodetect_model()
sw.get_login_cookie()

data = sw.get_switch_infos()
print(sw.switch_model.MODEL_NAME)
print(data["port_1_sum_rx_mbytes"])
print(data)