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.3

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.3
File Size Uploaded Provenance Actions
pypopur-0.1.3.tar.gz 315.9 kB With provenance Details for pypopur-0.1.3.tar.gz

Built distribution (wheel)

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

Total release size: 556.4 kB

Release files / pypopur-0.1.3.tar.gz

Download URL pypopur-0.1.3.tar.gz
Size 315.9 kB
Tags Source
SHA-256 checksum
How to use checksums
d09ade38ed8456b9a25caa246039f6fe5e6f90de0d3981273692d5a5f486cac2
BLAKE2b-256 checksum
How to use checksums
f81379a2a091dc30e0f194bc198adb76236bc67e0b3ed3570b7f42848e3f8854
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 16, 2026.

Transparency log

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

Download URL pypopur-0.1.3-py3-none-any.whl
Size 240.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
16ae3044334281acf8066012cdd553b95acf2b5b8e8c793775122bcd6b5c35b0
BLAKE2b-256 checksum
How to use checksums
d973edb84204d21adf4fc2aad929434d5b9e18ab636c0fb96ed0e5c0bf3db7a9
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 16, 2026.

Transparency log

Security for pypopur 0.1.3

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.3.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 16, 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