-
Notifications
You must be signed in to change notification settings - Fork 2
playground
The API Playground is an advanced feature that allows you to interact directly with the GL.iNet router's JSON-RPC/ubus API. By using the glinet_router.playground service, you can execute custom API methods and receive the raw JSON responses directly in Home Assistant.
Warning
This is an advanced feature intended for developers and power users. Sending invalid commands or parameters can alter your router's configuration, interrupt network connectivity, or cause reboot loops. Use with caution.
Because the playground allows arbitrary commands to be executed on the router, it is disabled by default. To enable it:
- In Home Assistant, go to Settings > Devices & Services.
- Find the GL.iNet integration cards.
- Click Configure on the router instance you wish to use.
- In the features checklist, check the box next to API Playground.
- Click Submit to save changes.
Once enabled, the glinet_router.playground service will be registered and available to call from Developer Tools, automations, and scripts.
The glinet_router.playground service takes the following fields:
| Field | Type | Required | Description |
|---|---|---|---|
method |
String | Yes | The JSON-RPC or ubus method to invoke (e.g., system/get_info or challenge). |
body |
Object / Dict | No | The JSON/YAML parameters to pass with the method. |
mac |
String | No | The router MAC address to target (optional if you only have one router configured). |
The playground automatically handles your session cookie/token (sid) behind the scenes:
-
Ubus calls (Slash syntax): If your method contains a slash (e.g.,
module/method), it is treated as a ubus call. The integration compiles this into a JSON-RPCcallrequest:{"method": "call", "params": [sid, "module", "method", body]}. -
Top-Level Methods: If your method does not contain a slash (e.g.,
challengeorlogin), it is sent directly as a top-level RPC method:{"method": "method", "params": body}.
Below are multiple examples demonstrating how to call the playground service using YAML and the structure of the JSON responses you can expect.
This calls the get_status method of the system ubus module to fetch router uptime, memory info, temperature, and load average.
Service Call YAML:
action: glinet_router.playground
data:
method: "system/get_status"Returned Response Data:
{
"system": {
"uptime": 86400,
"loadavg": [0.05, 0.12, 0.08],
"memory_total": 256000000,
"memory_free": 128000000
},
"cpu": {
"temperature": 48
}
}This fetches the lists of defined network security zones on your router.
Service Call YAML:
action: glinet_router.playground
data:
method: "firewall/get_zone_list"Returned Response Data:
{
"zones": [
{
"name": "lan",
"input": "ACCEPT",
"output": "ACCEPT",
"forward": "ACCEPT"
},
{
"name": "wan",
"input": "REJECT",
"output": "ACCEPT",
"forward": "REJECT"
}
]
}This toggles the router's physical front LED panel on or off.
Service Call YAML (Turn off LED):
action: glinet_router.playground
data:
method: "led/set_config"
body:
led_enable: falseReturned Response Data:
{
"result": 0
}This retrieves the connection state of active VPN tunnels on newer GL.iNet firmware.
Service Call YAML:
action: glinet_router.playground
data:
method: "vpn-client/get_status"Returned Response Data:
{
"status_list": [
{
"type": "wireguard",
"peer_id": 1,
"status": 1,
"ip": "10.0.0.2"
}
]
}This calls the unauthenticated top-level challenge method to query authentication algorithms and salt for a user.
Service Call YAML:
action: glinet_router.playground
data:
method: "challenge"
body:
username: "root"Returned Response Data:
{
"alg": 6,
"salt": "$6$abcdefgh",
"nonce": "123456789abcdef",
"hash-method": "sha256"
}- Services & Actions — How to use Home Assistant services with this integration.
-
Targeting a Specific Router — The optional
macparameter. - Router API Notes — Endpoints, authentication, and module inventory.