Netgear Enhanced (sensors and switches for router controls)

Still down, can’t access it. Yup, Github would be good. :slight_smile:

Added a new link in OP to github.

Github works a treat.

Nighthawk® R7000 seems to be working fine, i’ve got 2 other netgear routers to add on, so I’ll post the results.

How do you find out who is connected to the networks? works well in the Apps and I’d like to emulate it, but can’t find any attributes with connected devices.

Any help appreciated, and thank you for the effort.

@Bigrob8181 I’m getting this error in the logs. Does the RB50 support this?

[homeassistant.components.recorder] Event is not JSON serializable: <Event state_changed[L]:  
entity_id=sensor.ng_enhanced_traffic_meter, old_state=None, new_state=<state sensor.ng_enhanced_traffic_meter=0:01:00; NewTodayConnectionTime=0:01:00, NewTodayUpload=0.0, NewTodayDownload=0.0, NewYesterdayConnectionTime=0:04:00, NewYesterdayUpload=0.0, NewYesterdayDownload=0.0, NewWeekConnectionTime=0:05:00, NewWeekUpload=(0.0, 0.0), NewWeekDownload=(0.0, 0.0), NewMonthConnectionTime=0:05:00, NewMonthUpload=(0.0, 0.0), NewMonthDownload=(0.0, 0.0), NewLastMonthConnectionTime=0:00:00, NewLastMonthUpload=(0.0, 0.0), NewLastMonthDownload=(0.0, 0.0), unit_of_measurement=, friendly_name=Traffic Meter, icon=mdi:chart-areaspline @ 2020-07-05T14:34:26.400928-07:00>>

As I also have multiple netgear routers I tried to add multiple “netgear_enhanced” platforms in my configuration file mainly for the “check_app_fw” resource but it does not seem to work : only one sensor.ng_enhanced_check_app_fw appears and it doesn’t have value anymore.

Did you successfully add multiple platforms for your different routers ?

been playing around with this again.

made a handy card if it helps anyone else, for when using “guest mode”
basically, when you enable the guest wifi, it will tell you the password being used for it

type: entities
title: Guest Network
entities:
  - entity: switch.ng_enhanced_5g_guest_wifi
    name: 5G Guest Network Status
    type: 'custom:secondaryinfo-entity-row'
    secondary_info: >-
      Password: [[ if(switch.ng_enhanced_5g_guest_wifi == "off", "Wifi Off",
      sensor.ng_enhanced_5g_guest_wifi_info.attributes.NewKey) ]]
  - entity: switch.ng_enhanced_2g_guest_wifi
    name: 2G Guest Network Status
    type: 'custom:secondaryinfo-entity-row'
    secondary_info: >-
      Password: [[ if(switch.ng_enhanced_2g_guest_wifi == "off", "Wifi Off",
      sensor.ng_enhanced_2g_guest_wifi_info.attributes.NewKey) ]]
show_header_toggle: false

image

Is this component still working? at version 0.118?

Where do you get the username and passwords for this to work?

Most of it is working for me: I have a Netgear RAX80, RAX40, and RAX15, the last two running in AP mode.

I’m using these options for the router:

  • get_lan_config_info
  • get_wan_ip_info
  • info
  • bw_control
  • 2g_wifi_info
  • 5g_wifi_info
  • traffic_meter

These for the APs:

  • get_lan_config_info
  • info
  • 2g_wifi_info
  • 5g_wifi_info

This one doesn’t work at all for me:

  • mac_address

These don’t seem to show anything useful:

  • get_device_config_info
  • supported_features

The others work, I think, but I don’t need; ymmv depending on your netgear router.

For the switches, I’m only using the reboot one; some of the switches don’t work with AP mode. To run it on three routers/APs, I had have three copies of the Addin and add a number to the folders and I think manifests of each copy and added a prefix (rax80, rax40, rax15) in the code on the device_tracker, sensor, and switches pages to create separate sensors.

The RAX15 also required using port 80 and a code change to force login v2 on those pages in each addin but that was pretty simple. If anyone needs that, I think I posted what to do to the github page.

The usename and password are the ones you use to login to your router.

This is the easiest way to get access to multiple routers/APs and you can do it with minimal code changes.

Example with one router and two APs:

1.) Add three copies of netgear_enhanced to custom components to your custom components folder and give the two copies slightly different names

netgear_enhanced
netgear_enhanced_2
netgear_enhanced_3

2.) In the two numbered copies go to manifest.json and make the following changes:
Note: I’m not sure this is needed but I haven’t tested without doing this. Feel free to try without.
“domain”: “netgear_enhanced_[2 or 3]”,
“name”: “Netgear Enhanced [2 or 3]”,

3.) In the original and both copies, in sensor.py and switch.py:
for my router: DEFAULT_PREFIX = ‘ng_enhanced_myrouter’
for my first ap: DEFAULT_PREFIX = ‘ng_enhanced_myap1’
for my second ap: DEFAULT_PREFIX = ‘ng_enhanced_myap2’

4.) Now configuration in HA:
In /config/sensors.yaml and /config/switches.yaml (or wherever you put your netgear_enhanced configurations):

For your router:

  • platform: netgear_enhanced
    host: [ router IP]
    username: [username]
    password: [password]
    resources:
    • [your options]

For your APs:

  • platform: netgear_enhanced_2
    host: [ AP1 IP ]
    username: [username]
    password: [password]
    resources:

  • [ your options]

  • platform: netgear_enhanced_3
    host: [ AP2 IP ]
    username: [username]
    password: [password]
    resources:

  • [ your options]

This will create unique names for each of the sensors matching each router/ap/whatever. Tested with Netgear RAX80, RAX40, and RAX15.

That said: if you have an RAX15, it requires the addition of Port: 80 to the configs; it also requires login v2. This may apply to other routers in netgear that don’t work with either the default Port 5000 or using Port 80. If your logs show a 401 response from SOAP when you try to login from either 5000 or 80, try this.

Below are the code changes to device_tracker.py (if you use it for device_tracker), sensor.py, and switch.py to force a Login V.2.

Note: this is purely a workaround I wrote after checking pynetgear_enhanced until the developer has time to update the component. The drawback to using this is you’ll need to remove the code if you switch to a router that doesn’t need login_v2 or create a separate copy of netgear_enhanced in your custom_components for routers that need login_v2. Which is what I did for my RAX12.

For sensor.py and switch.py, I added the following:
1.) In def_setup_platform (starts on line 154 for sensor.py, 70 for switch.py)

add and define these variables:
url = None
force_login_v2=True

Add the variables to args:
args = [password, host, username, port, ssl, url, force_login_v2]

2.) Under class NetgearEnhancedSensor(Entity) in def init (for switch.py, class NetgearEnhancedSwitch(SwitchDevice))

add args[5] and args[6] to self._api:
self._api = NetgearEnhanced(args[0], args[1], args[2], args[3], args[4], args[5], args[6])

For device tracker: this seemed to work but is only partially tested since I’m using my RAX15 as an AP:
1.) def get_scanner

Add and define url and force_login_v2 variables as above but do not add them to scanner=NetgearDeviceScanner. But I could be wrong and they may need to be added there as well.

2.) to Class NetgearDeviceScanner

Add variables url and force_login_v2 to self._api

That should cover it all.

I seem to be having a similar issue as martellucci, I have not been able to get this working. My sole interest in this is to use the reboot router switch. Here’s what I see in the logs:

Logger: pynetgear_enhanced
Source: /usr/local/lib/python3.8/site-packages/pynetgear_enhanced/__init__.py:143
First occurred: February 20, 2021, 1:45:49 AM (1295 occurrences)
Last logged: 7:30:36 AM

Connection error: HTTPConnectionPool(host='192.168.0.1', port=5000): Max retries exceeded with url: /soap/server_sa/ (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7f51a06bb0>, 'Connection to 192.168.0.1 timed out. (connect timeout=30)'))
Connection error: HTTPConnectionPool(host='192.168.0.1', port=5000): Max retries exceeded with url: /soap/server_sa/ (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7f516514c0>, 'Connection to 192.168.0.1 timed out. (connect timeout=30)'))
Connection error: HTTPConnectionPool(host='192.168.0.1', port=5000): Max retries exceeded with url: /soap/server_sa/ (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7f53898700>, 'Connection to 192.168.0.1 timed out. (connect timeout=30)'))
Connection error: HTTPConnectionPool(host='192.168.0.1', port=5000): Max retries exceeded with url: /soap/server_sa/ (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7f53817f10>, 'Connection to 192.168.0.1 timed out. (connect timeout=30)'))
Connection error: HTTPConnectionPool(host='192.168.0.1', port=5000): Max retries exceeded with url: /soap/server_sa/ (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7f536efe50>, 'Connection to 192.168.0.1 timed out. (connect timeout=30)'))
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/urllib3/connection.py", line 169, in _new_conn
    conn = connection.create_connection(
  File "/usr/local/lib/python3.8/site-packages/urllib3/util/connection.py", line 96, in create_connection
    raise err
  File "/usr/local/lib/python3.8/site-packages/urllib3/util/connection.py", line 86, in create_connection
    sock.connect(sa)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 699, in urlopen
    httplib_response = self._make_request(
  File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 394, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/local/lib/python3.8/site-packages/urllib3/connection.py", line 234, in request
    super(HTTPConnection, self).request(method, url, body=body, headers=headers)
  File "/usr/local/lib/python3.8/http/client.py", line 1255, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/local/lib/python3.8/http/client.py", line 1301, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/local/lib/python3.8/http/client.py", line 1250, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/local/lib/python3.8/http/client.py", line 1010, in _send_output
    self.send(msg)
  File "/usr/local/lib/python3.8/http/client.py", line 950, in send
    self.connect()
  File "/usr/local/lib/python3.8/site-packages/urllib3/connection.py", line 200, in connect
    conn = self._new_conn()
  File "/usr/local/lib/python3.8/site-packages/urllib3/connection.py", line 174, in _new_conn
    raise ConnectTimeoutError(
urllib3.exceptions.ConnectTimeoutError: (<urllib3.connection.HTTPConnection object at 0x7f70e2e160>, 'Connection to 192.168.0.1 timed out. (connect timeout=30)')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/requests/adapters.py", line 439, in send
    resp = conn.urlopen(
  File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 755, in urlopen
    retries = retries.increment(
  File "/usr/local/lib/python3.8/site-packages/urllib3/util/retry.py", line 573, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='192.168.0.1', port=5000): Max retries exceeded with url: /soap/server_sa/ (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7f70e2e160>, 'Connection to 192.168.0.1 timed out. (connect timeout=30)'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/pynetgear_enhanced/__init__.py", line 102, in _make_request
    response = requests.post(self.soap_url, headers=headers,
  File "/usr/local/lib/python3.8/site-packages/requests/api.py", line 119, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/requests/api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 542, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 655, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/requests/adapters.py", line 504, in send
    raise ConnectTimeout(e, request=request)
requests.exceptions.ConnectTimeout: HTTPConnectionPool(host='192.168.0.1', port=5000): Max retries exceeded with url: /soap/server_sa/ (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7f70e2e160>, 'Connection to 192.168.0.1 timed out. (connect timeout=30)'))

In addition to creating and copying the github files to a custom_components folder, is there anything else I need to do to install this correctly? Are there any commands I need to enter into the Pi’s console?

1 Like

Hello! Is it possible to allow/block access to one specific equipment with this in HA? I have been able to do it with the python script but i don’t know how do to in in HA…

Just trying this to see if it works, but I have an Orbi RBR50 router. What port, etc. should I use for that?

Also, is this actually still maintained as I notice it complains about missing version info in the manifest and the issue on Github is still open for that.

1 Like

@Bigrob8181

Any chance this can also Control insight managed Switches ? (Especially poe port control)?

1 Like

Anyone know if this still works? Trying to get it working for my Orbi RBR50 with the following config, but I just get

2021-12-30 12:13:16 ERROR (SyncWorker_4) [pynetgear_enhanced] Invalid response
2021-12-30 12:13:17 ERROR (SyncWorker_4) [pynetgear_enhanced] Invalid response
2021-12-30 12:13:18 ERROR (SyncWorker_4) [pynetgear_enhanced] Invalid response
2021-12-30 12:13:18 ERROR (SyncWorker_4) [pynetgear_enhanced] Invalid response
2021-12-30 12:13:21 ERROR (SyncWorker_4) [pynetgear_enhanced] Invalid response
2021-12-30 12:13:22 ERROR (SyncWorker_4) [pynetgear_enhanced.helpers] Error finding node in XML response
2021-12-30 12:13:22 ERROR (SyncWorker_4) [pynetgear_enhanced] Invalid response
- platform: netgear_enhanced
  host: 192.168.1.254
  port: 80
  username: admin
  password: !secret orbi_pwd
  ssl: false
  resources:
    - firmware
    - check_app_fw
    - get_device_config_info
    - get_lan_config_info
    - get_wan_ip_info
    - parental_control_on
    - mac_address
    - dns_masq
    - info
    - supported_features
    - speed_test_result
    - 2g_guest_wifi_on
    - 5g_guest_wifi_on
    - get_channel
    - get_smart_conn

If I use this command, then it works fine.

python3 -m pynetgear_enhanced --host 192.168.1.254 --password 'mypassword'  --port 80 --no-ssl attached_devices```

my 2 cents… possible ip/arp resolution from HA? Are you running HA in a non-host-network docker and the command from host ?

When will the new version?

with the script using

python3 -m pynetgear_enhanced --host 192.168.1.250 --password 'mypassword'  --port 80 --no-ssl attached_devices```

I got such a response

Invalid response
Invalid response
Get attached devices failed

PORT STATE SERVICE
80/tcp open http
3333/tcp open dec-notes
49152/tcp open unknown

$ ping 192.168.1.250
PING 192.168.1.250 (192.168.1.250) 56(84) bytes of data.
64 bytes from 192.168.1.250: icmp_seq=1 ttl=64 time=2.02 ms
64 bytes from 192.168.1.250: icmp_seq=2 ttl=64 time=2.45 ms
^C
--- 192.168.1.250 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 2.018/2.232/2.447/0.214 ms

any idea of the root cause ?