Skip to main content

pypopur

Experimental — a reverse-engineered Python client for the Popur S7 smart litter box, built from static analysis of the official Android app (v2.0.0 / ThingClips SDK). Tested against a single real device; expect rough edges.

PyPI License: MIT Tests

Features

  • LAN control — Tuya protocol 3.5 session-key negotiation, DP read/write over TCP:6668, auto-protocol probing (3.1–3.5), heartbeat keepalive, stale-session recovery
  • Cloud APIs — full ThingClips/Popur app surface: auth, homes, devices, DP shadow, pets, pet records, firmware, timers, device management
  • MQTT events — real-time DP deltas and alert events over TLS to the app's broker, with reconnect/resubscribe handling
  • Hybrid transport — LAN-first with automatic cloud fallback; slow reconciliation tier for settings DPs and pet data the LAN omits
  • Discovery — passive UDP announcements plus active host location via ARP MAC match and port-6668 subnet scan
  • DP codecs — all firmware-4 packed payloads decoded (settings, calibration, radar config, cat weight, visit records)
  • Pet tracking — household pet profiles, per-visit weight/duration records decoded from the app's own format
  • Home Assistant — this SDK powers the separate Popur S7 Home Assistant integration

Install

pip install pypopur

Requires Python 3.11+.

Quick start — local control

import asyncio
from pypopur import LocalTuyaTransport, PopurClient

async def main():
    transport = LocalTuyaTransport(
        device_id="your-device-id",
        host="192.168.1.x",
        local_key="your-local-key",
    )
    client = PopurClient(transport)

    async with client:
        snapshot = await client.refresh()
        print(snapshot.machine_status, snapshot.cat_present, snapshot.bin_full)
        await client.start_cleaning()

asyncio.run(main())

Quick start — cloud account

import asyncio
from pypopur.mobile import MobileAppProfile, PopurAccount, ThingMobileApi

async def main():
    api = ThingMobileApi(
        MobileAppProfile.bundled_popur_app2(),
        install_id="a-stable-id-for-this-install",
    )
    account = PopurAccount(api)
    await account.login("you@example.com", "your-password")

    home_id = (await account.homes())[0]["gid"]
    devices = await account.home_devices(home_id)

    for dev in devices:
        print(dev.name, dev.device_id, dev.local_key)

asyncio.run(main())

Quick start — pets

pets = await account.pets(home_id)
for pet in pets:
    print(pet.name, pet.pet_type, pet.weight)

page = await account.pet_records(home_id, page_size=50)
for record in page.records:
    usage = record.toilet_usage()
    if usage:
        print(record.pet_id, usage.weight_grams, "g", usage.duration_seconds, "s")

Quick start — MQTT events

events = account.connect_events(
    devices={dev.device_id: dev.local_key},
    on_event=lambda e: print(e.dev_id, e.dps),
    on_connect=lambda: print("connected"),
)
await events.connect()

Architecture

┌─────────────────────────────────────────────────┐
│                  PopurClient                     │
│         typed controls + DeviceSnapshot          │
├─────────────────────────────────────────────────┤
│              FallbackTransport                   │
│   LAN primary (3.5) ──fail──► Cloud fallback    │
├──────────┬──────────────────┬───────────────────┤
│ LAN TCP  │  MQTT TLS        │  Cloud HTTPS      │
│ :6668    │  smart/mb/in/    │  a1.tuyaus.com    │
│ DP r/w   │  DP deltas       │  shadow, pets,    │
│ ~23 DPs  │  alerts          │  mgmt APIs        │
└──────────┴──────────────────┴───────────────────┘
  • LAN — fast path for reads/writes; ~23 DPs in status responses
  • MQTT — real-time push (protocol-4 deltas, protocol-56 alerts); deltas only, no snapshots
  • Cloud — settings DPs LAN omits (102 etc.), pet profiles/records, firmware, timers, device management

Home Assistant

Popur S7 for Home Assistant uses pypopur as its Python SDK for device communication, discovery, MQTT, and cloud APIs. The Home Assistant integration is maintained in that separate repository, not here. For installation and configuration, see its README. Its Home Assistant domain is popur_s7.

Status

  • Tested against: one Popur S7 (Wi-Fi 3.0.30 / MCU 4.3.0), firmware-4 protocol family
  • LAN protocol: verified live — handshake, DP read/write, heartbeat, reconnect
  • Cloud APIs: signature-exact to the app; read paths verified live, write paths untested
  • MQTT: verified live — connect, subscribe, decode protocol-4/56 frames, reconnect
  • Test suite: 769 tests, all passing

Limitations

  • Only tested against one device and one firmware version — other S7s may differ
  • App-layer write APIs (pets, device management) are signature-verified but never executed live
  • The standalone LAN transport doesn't fetch the thing model — no schema validation on writes
  • MQTT is event-driven (deltas only) — it can't replace polling for state seeding or reconciliation
  • Settings DPs and pet data require the cloud — they don't exist on the LAN channel

Development

python -m pytest tests/          # 769 tests
ruff check src tests             # lint

License

MIT — see LICENSE.

Disclaimer

This is an unofficial, reverse-engineered client. It is not affiliated with or endorsed by Popur. Use at your own risk — the author is not responsible for bricked devices, angry cats, or unexpected litter box behavior.

Metadata

Release files for pypopur 0.1.4

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

Source distribution (sdist)

Source distribution for pypopur 0.1.4
File Size Uploaded Provenance Actions
pypopur-0.1.4.tar.gz 322.7 kB With provenance Details for pypopur-0.1.4.tar.gz

Built distribution (wheel)

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

Total release size: 566.2 kB

Release files / pypopur-0.1.4.tar.gz

Download URL pypopur-0.1.4.tar.gz
Size 322.7 kB
Tags Source
SHA-256 checksum
How to use checksums
88bb321f45d1af627fcc98b4cebb61e731fd8a41d0d6e20008ba46608dd54c39
BLAKE2b-256 checksum
How to use checksums
0bbcd1d74903219c8424053807f7598e85058e9905cedb4595f19db394525b8e
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 23, 2026.

Transparency log

Release files / pypopur-0.1.4-py3-none-any.whl

Download URL pypopur-0.1.4-py3-none-any.whl
Size 243.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fa7bcc5f88bb2d042c2f74a13f2f75c5892afc9201700a983b35cf02f080f28e
BLAKE2b-256 checksum
How to use checksums
c24f58e92cf39aaf37a6cc97b49cbafd8c64b43690256493fe8fa81fcd088910
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 23, 2026.

Transparency log

Security for pypopur 0.1.4

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 pypopur-0.1.4.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 23, 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