Skip to main content

pybticino

PyPI CI Python License

Async Python library for the BTicino/Netatmo API. Controls BTicino Classe 100X/300X video intercom systems via the Netatmo cloud.

Used by the bticino_intercom Home Assistant integration.

Installation

pip install pybticino

Requires Python 3.13 or later.

Features

  • Authentication: OAuth2 password grant with automatic token refresh and persistence support
  • Home topology: fetch homes, modules, and their configuration
  • Device control: lock/unlock doors, turn lights on/off
  • Events: fetch call history with snapshots and vignettes
  • WebSocket: real-time push notifications (call events, connection status, state changes)
  • Re-subscribe: refresh OAuth token on existing connection without reconnecting
  • WebRTC signaling: offer/answer/ICE exchange for live video calls (experimental)

Quick start

import asyncio
from pybticino import AuthHandler, AsyncAccount

async def on_token_change(tokens):
    """Called when tokens are refreshed — persist them to avoid re-auth."""
    print(f"New token expires at {tokens['expires_at']}")

async def main():
    auth = AuthHandler(
        "your_email@example.com",
        "your_password",
        token_callback=on_token_change,  # optional: persist tokens
    )
    account = AsyncAccount(auth)

    await account.async_update_topology()
    for home_id, home in account.homes.items():
        print(f"Home: {home.name} ({len(home.modules)} modules)")

        status = await account.async_get_home_status(home_id)
        events = await account.async_get_events(home_id, size=5)

    await auth.close_session()

asyncio.run(main())

To restore tokens from a previous session (skip initial auth):

auth = AuthHandler("email", "password", token_callback=on_token_change)
auth.set_tokens(
    access_token=saved["access_token"],
    refresh_token=saved["refresh_token"],
    expires_at=saved["expires_at"],
)

WebSocket (real-time events)

import asyncio
from pybticino import AuthHandler, WebsocketClient

async def on_message(message):
    print(f"Event: {message.get('push_type')} - {message}")

async def main():
    auth = AuthHandler("your_email@example.com", "your_password")
    ws = WebsocketClient(auth, on_message)

    # Option 1: run forever with auto-reconnect (recommended)
    await ws.run_forever(reconnect_delay=30)

    # Option 2: manual connect + listen
    await ws.connect()
    task = ws.get_listener_task()
    if task:
        await task
    await ws.disconnect()

    await auth.close_session()

asyncio.run(main())

Re-subscribe (keep connection alive)

# Refresh token on existing connection without disconnecting.
# Call this periodically (e.g., every hour) to prevent token expiry.
await ws.resubscribe()

API endpoints

Method Endpoint Description
async_update_topology() /api/homesdata Fetch homes and modules
async_get_home_status(home_id) /syncapi/v1/homestatus Get module status
async_set_module_state(home_id, module_id, state) /syncapi/v1/setstate Control devices
async_get_events(home_id, size) /api/getevents Get event history
async_get_turn_servers() /turn Fetch TURN/STUN ICE server credentials for WebRTC

WebSocket event types

Events are delivered with push_type in format {DEVICE_TYPE}-{EVENT_TYPE}:

push_type Description
BNC1-rtc Incoming WebRTC call (with SDP offer)
BNC1-incoming_call Doorbell ring (with snapshot URL)
BNC1-missed_call Unanswered call
BNC1-accepted_call Call answered
BNC1-connection Bridge connected
BNC1-disconnection Bridge disconnected

Documentation

Full documentation at k-the-hidden-hero.github.io/pybticino

Key guides from reverse engineering:

Examples

Working example scripts in examples/:

Script Description
webrtc_offer_mode.py On-demand video: send offer → receive answer → ICE → connected
webrtc_answer_mode.py Answer incoming call: wait for doorbell → answer via signaling
webrtc_audio_test.html Browser-based audio test with silence oscillator
websocket_test.py Real-time push notification listener

Contributing

pip install -e ".[test,dev]"
pytest tests/ -v
ruff check src/ tests/

License

MIT

Metadata

Release files for pybticino 1.10.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pybticino 1.10.0
File Size Uploaded Provenance Actions
pybticino-1.10.0.tar.gz 86.4 kB With provenance Details for pybticino-1.10.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pybticino 1.10.0
File Interpreter ABI Platform Actions
pybticino-1.10.0-py3-none-any.whl Python 3 none any Details for pybticino-1.10.0-py3-none-any.whl

Total release size: 117.0 kB

Release files / pybticino-1.10.0.tar.gz

Download URL pybticino-1.10.0.tar.gz
Size 86.4 kB
Tags Source
SHA-256 checksum
How to use checksums
ca00dd77bcd12e950e7602d42525c31caff964889f72b4172c400246cebf3505
BLAKE2b-256 checksum
How to use checksums
58eceec2fda71229a9cf824c6e2634d78bd61242f65009cac4c9390011e60ebe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

Release files / pybticino-1.10.0-py3-none-any.whl

Download URL pybticino-1.10.0-py3-none-any.whl
Size 30.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9b0c70c066547967ab22fd1b48b36b6ea3afa59ce243d99ef21b91611b8b2c56
BLAKE2b-256 checksum
How to use checksums
eedf2b86c54013a637e42c90165e371b68a17f2702715d41c1df492ac3645ee1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

Security for pybticino 1.10.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pybticino-1.10.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page