OpenWrt Monitoring [SSH connection] Request help for creation

I am not satisfied with the current components. This forces us to install additional packages and the data collected is not sufficient. I wanted a component that groups together like miwifi. I would like some help to create a new component which uses the ssh connection. I have a complete script in php that should be adapted in python.

The idea is to recover the data processor, memory, activate / deactivate the radios. Track wifi + ethernet connected devices.

Following sharing agreement I put the code here

code php

It would take a code to match the two in order to create an aioopenwrt
aioasuswrt

Error as requirements in Home Assistant

I think I have found an equivalent library for pyhton.

ssh2-python

my test
```
import socket

from ssh2.session import Session

host = ‘MYIPROUTER’
user = ‘MYLOGIN’
password = ‘MYPASSWORD’

sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((host, 22))

session = Session()
session.handshake(sock)
session.userauth_password(user, password)

channel = session.open_session()
channel.execute(‘ip neigh’)
size, data = channel.read()
while size > 0:
print(data.decode())
size, data = channel.read()
channel.close()
print(“Exit status: {0}”.format(channel.get_exit_status()))
```

or

replace channel.execute(‘ip neigh’) with channel.execute(‘echo $((cat /sys/class/thermal/thermal_zone0/temp/1000))’)

return
48

Exit status: 0

Problem to implement the library so it would be necessary to start on paramiko here.

exemple:

import paramiko

host = "MYIP"
user = "MYLOGIN"
password = "MYPASSWORD"
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(hostname=host,username=user,password=password,look_for_keys=False,allow_agent=False)
stdin, stdout, stderr = client.exec_command('iwinfo | grep ESSID | cut -f 1 -s -d" "')
for line in stdout:
    print(line.strip('\n'))
client.close()

The return of this order is
Wlan_2_4Ghz
Wlan_5Ghz
Wlan_IoT
mesh0