Skip to main content

Python client for the Swisscom Internet-Box

Project description

python-swisscom-internet-box

Async Python client for the Swisscom Internet-Box local API (/ws endpoint).

Installation

pip install python-swisscom-internet-box

Usage

import asyncio
import aiohttp
from swisscom_internet_box import SwisscomClient

async def main():
    async with aiohttp.ClientSession() as session:
        client = SwisscomClient(session, "192.168.1.1", "admin", "your-password")

        # Device info & WAN status (unauthenticated)
        info = await client.get_box_info()
        print(f"{info.model_name} — FW {info.software_version}")

        wan = await client.get_wan_status()
        print(f"WAN: {wan.connection_state} ({wan.protocol})")

        # WiFi access points (includes guest network)
        for ap in await client.get_access_points():
            label = "guest" if ap.is_guest else "main"
            print(f"[{label}] {ap.ssid}{ap.frequency_band}{'on' if ap.enabled else 'off'}")

        # Connected LAN devices
        for device in await client.get_devices():
            if device.active:
                print(f"{device.name}{device.ip_address}{'wifi' if device.is_wireless else 'eth'}")

        # Steer the box (authenticated; logs in automatically)
        await client.set_guest_wifi(True)   # turn the guest network on
        await client.set_wifi(False)        # turn all WiFi off
        await client.reboot()               # reboot the box

asyncio.run(main())

API

SwisscomClient(session, host, username, password)

Method Auth required Description
get_box_info() No Manufacturer, model, firmware, MAC, uptime
get_wan_status() No Link type/state, protocol, connection state
get_nmc_info() No WAN mode, active interface, provisioning state
get_wifi_status() No WiFi global enable/active state
get_access_points() Yes All VAPs (main + guest); use ap.is_guest to filter
get_devices(expression) Yes LAN devices; default expression: "lan and not self"
set_wifi(enabled) Yes Turn all WiFi radios on/off (global switch)
set_guest_wifi(enabled) Yes Turn the guest WiFi network on/off
reboot(reason) Yes Reboot the box (default reason: "GUI_Reboot")

Device expressions

Expression Result
"lan and not self" All LAN clients (default)
"wifi" Wireless clients only
"eth" Wired clients only

Models

  • BoxInfomanufacturer, model_name, software_version, base_mac, up_time, device_status
  • WANStatuslink_type, link_state, protocol, connection_state, .is_connected
  • NMCInfowan_mode, active_wan_interface, provisioning_state
  • WiFiStatusenabled, active, wps_enabled, scheduler_enabled
  • AccessPointkey, ssid, bssid, enabled, frequency_band, channel, .is_guest
  • Devicekey, name, phys_address, ip_address, active, interface_name, .is_wireless, ipv4_addresses, ipv6_addresses, bandwidth

Compatibility

Tested on Internet-Box 4 (IB4-00, firmware 14.20.40). Should work on IB2, IB3 and IB5 running similar firmware.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python_swisscom_internet_box-0.2.0.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

python_swisscom_internet_box-0.2.0-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file python_swisscom_internet_box-0.2.0.tar.gz.

File metadata

File hashes

Hashes for python_swisscom_internet_box-0.2.0.tar.gz
Algorithm Hash digest
SHA256 1b5fe15b68d1e882960274aa717a8aea9516f6f18c971c04d4cef9c380420eec
MD5 af0d8eea3a97ef9ff539bc7b4dc94d4a
BLAKE2b-256 f0874033d1cf5d94bd1cdde3bae02891440222bbfdccdab6933580d27225f274

See more details on using hashes here.

Provenance

The following attestation bundles were made for python_swisscom_internet_box-0.2.0.tar.gz:

Publisher: publish.yml on anatosun/python-swisscom-internet-box

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file python_swisscom_internet_box-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for python_swisscom_internet_box-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2b590b5c1ceae49fb1b01e8fad0bf6aa723f49419738b7e00f6950d434fd08e9
MD5 8e74b77f892fe8e301ed09c764e265dd
BLAKE2b-256 754d41362afe3908a11dcd0e4b8802c5cd240682baaa4967f62ef21b1d3ca321

See more details on using hashes here.

Provenance

The following attestation bundles were made for python_swisscom_internet_box-0.2.0-py3-none-any.whl:

Publisher: publish.yml on anatosun/python-swisscom-internet-box

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page