Skip to content

Instantly share code, notes, and snippets.

@orther
Last active January 11, 2024 15:53
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save orther/f6119b9fb81b2a2196f0dc4fa672b30f to your computer and use it in GitHub Desktop.
Save orther/f6119b9fb81b2a2196f0dc4fa672b30f to your computer and use it in GitHub Desktop.
JS Code To Disable WiFi for T-Mobile 5G Home Internet Router

This script can be copied into the browser console and used to disable wifi on the T-Mobile 5G Home Internet router. The web interface for the router doesn't allow you to disable it.

Steps

  1. Go to http://192.168.12.1
  2. Open dev console (on mac [cmd]+[opt]+i)
  3. Copy the code from the below JS file and with the password value updated to be your actual password and hit enter
  4. Call the code by typing tmobileHomeInternetDisableWifi() and hitting enter
async function tmobileHomeInternetDisableWifi() {
const username = 'admin'
const password = 'REPLACE-WITH-REAL-PASSWORD' // <<------- Make sure to replace this
async function loginTmobile(username, password) {
const resp = await fetch("http://192.168.12.1/TMI/v1/auth/login", {
"headers": {
"accept": "application/json",
"accept-language": "en-US,en;q=0.9",
"cache-control": "max-age=0",
"content-type": "text/plain;charset=UTF-8"
},
"referrer": "http://192.168.12.1/home",
"referrerPolicy": "strict-origin-when-cross-origin",
// "body": "{\"username\":\"admin\",\"password\":\"tug.ecologist.cover.facility\"}",
body: JSON.stringify({ username, password }),
"method": "POST",
"mode": "cors",
"credentials": "include"
});
console.log('resp', { headers: resp.headers })
if (resp.ok) {
const jsonValue = await resp.json(); // Get JSON value from the response body
const authToken = jsonValue?.auth?.token
return Promise.resolve(authToken);
} else {
return Promise.reject('Failed to get JSON respon value');
}
}
async function getAccessPointConfig(authToken) {
const resp = await fetch("http://192.168.12.1/TMI/v1/network/configuration?get=ap", {
headers: {
"accept": "application/json",
"accept-language": "en-US,en;q=0.9",
"authorization": `Bearer ${authToken}`,
"cache-control": "max-age=0"
},
referrer: "http://192.168.12.1/networks",
referrerPolicy: "strict-origin-when-cross-origin",
body: null,
method: "GET",
mode: "cors",
credentials: "include"
});
console.log('ap config resp', resp)
if (resp.ok) {
const jsonValue = await resp.json(); // Get JSON value from the response body
return Promise.resolve(jsonValue);
} else {
return Promise.reject('Failed to get JSON respon value');
}
}
function disableWifiProps(apConfig) {
const configWifiOff = {
...apConfig,
'2.4ghz': { ...apConfig['2.4ghz'], isRadioEnabled: false },
'5.0ghz': { ...apConfig['5.0ghz'], isRadioEnabled: false },
}
console.log('configWifiOff', configWifiOff)
return configWifiOff
}
async function disableAccessPointWifi(authToken) {
const apConfig = await getAccessPointConfig(authToken)
const wifiOffConfig = disableWifiProps(apConfig)
const resp = await fetch("http://192.168.12.1/TMI/v1/network/configuration?set=ap", {
headers: {
"accept": "application/json",
"accept-language": "en-US,en;q=0.9",
"authorization": `Bearer ${authToken}`,
"cache-control": "max-age=0",
"content-type": "text/plain;charset=UTF-8"
},
referrer: "http://192.168.12.1/networks",
referrerPolicy: "strict-origin-when-cross-origin",
body: JSON.stringify(wifiOffConfig),
method: "POST",
mode: "cors",
credentials: "include"
});
console.log('ap config resp', resp)
if (resp.ok) {
const jsonValue = await resp.json(); // Get JSON value from the response body
return Promise.resolve(jsonValue);
} else {
return Promise.reject('Failed to get JSON respon value');
}
}
const authToken = await loginTmobile(username, password)
const result = await disableAccessPointWifi(authToken)
return result
}
@kaipyroami
Copy link

'2.4ghz': { ...apConfig['2.4ghz'], isRadioEnabled: false },
'5.0ghz': { ...apConfig['5.0ghz'], isRadioEnabled: false },

Thank you for writing this up! One thing I wanted to check before I proceed.
Do you know if changing from false to true will reenable the radios? T-Mobile is forcing the use of the App (via WiFi) to do any other admin on the box.

@orther
Copy link
Author

orther commented Apr 29, 2022

@kaipyroami yes it will reenable the radios. You should be good to toggle on and off when you need. I‘ve done it from time to time and it works as expected.

@nbvb20
Copy link

nbvb20 commented Oct 24, 2022

First time [user...] where do I insert the code? Attached is a screenshot:

Screen Shot 2022-10-24 at 10 21 45 AM

@mborrero33
Copy link

@kaipyroami yes it will reenable the radios. You should be good to toggle on and off when you need. I‘ve done it from time to time and it works as expected.

Hi, when running the code I get the following message:
Post http://192.168.12.1/TMI/V1/auth/loging 401 (Unauthorized)
Uncaught (in promise) Failed to get JSON respon value
Can you tell me what I am doing wrong. Thanks

@mborrero33
Copy link

Hi, when running the code I get the following message:
Post http://192.168.12.1/TMI/V1/auth/loging 401 (Unauthorized)
Uncaught (in promise) Failed to get JSON respon value
Can you tell me what I am doing wrong. Thanks

@will-cole-oe
Copy link

I suspect you aren't updating line 3 with the correct admin password you created when you set up your T-Mobile Internet router. I just ran this code myself (after updating the password) and it worked perfectly.

@LASD9958
Copy link

When Calling the Code
I keep getting the error
Uncaught SyntaxError: Unexpected token function

@GodsBest
Copy link

GodsBest commented Mar 1, 2023

@kaipyroami yes it will reenable the radios. You should be good to toggle on and off when you need. I‘ve done it from time to time and it works as expected.

Hi, when running the code I get the following message: Post http://192.168.12.1/TMI/V1/auth/loging 401 (Unauthorized) Uncaught (in promise) Failed to get JSON respon value Can you tell me what I am doing wrong. Thanks

The post URL should be http://192.168.12.1/TMI/v1/auth/login .... See line 6.

@antonywu
Copy link

antonywu commented Jun 22, 2023

Does the code work for the Sagemcom Fast 5688W Gateway?
Ran into the following error

"VM107:1  Uncaught (in promise) SyntaxError: Unexpected end of JSON input
    at disableAccessPointWifi (<anonymous>:92:36)
    at async tmobileHomeInternetDisableWifi (<anonymous>:100:18)"

However, even before I ran the code, I can already see that isRadioEnabled is false on both 2.4 and 5Ghz because I set the WiFi network to hidden (within the android T Mobile Home Internet app).
GET http://192.168.12.1/TMI/v1/network/configuration?get=ap and returned the following
{"2.4ghz":{"isRadioEnabled":false..},"5.0ghz":{"isRadioEnabled":false..}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment