Salamek / huawei-lte-api

API For huawei LAN/WAN LTE Modems
GNU Lesser General Public License v3.0
376 stars 92 forks source link

Switch Wifi on/off #162

Closed colpomatteo closed 1 year ago

colpomatteo commented 1 year ago

Hi, is there a script for switch wifi on/off? I need it for B535-232.

Thanks ;)

Salamek commented 1 year ago

See https://github.com/Salamek/huawei-lte-api/blob/master/huawei_lte_api/api/WLan.py

wifi_guest_network_switch is used to toggle guest wifi, just copy and modify that code to toggle wifi with specific ssid...

colpomatteo commented 1 year ago

Thank you. I tried but If I call wifi_guest_networkswitch as it is, it returns 'Request format error', if I try to use it with my wifi ssid it returns '100006: Unknown'. ‾\_(*-*)\/‾

My code:

def _set_wifi_enable(ssid: dict, status: bool) -> dict:
    if ssid.get('WifiSsid') != "myssid":
        return ssid

    ssid['WifiEnable'] = '1' if status else '0'
    return ssid
Salamek commented 1 year ago

@colpomatteo check version 1.6.8, i have added a method to disable/enable wifi, see this example https://github.com/Salamek/huawei-lte-api/blob/master/examples/toggle_wifi.py