twrecked/pyaarlo
حول
Unofficial asynchronous Python library and command-line tools for Arlo cameras, doorbells, lights, and security systems. Powers the Aarlo Home Assistant integration.
الأمان والخصوصيةالنمو المقاس للنجوم
- خلال 24 ساعة
- ٠
- خلال 7 أيام
- ٠
- خلال 15 يومًا
- ٠
- خلال شهر
- جارٍ جمع السجل
تغيّر صافي النجوم خلال فترات متداخلة، وليس مجموعًا يوميًا. تبقى القياسات المفقودة فارغة. النجوم تقيس الاهتمام لا جودة البرمجيات.
README.md
الأصلPyArlo
An asynchronous Python library and command-line automation toolkit for Netgear/Arlo security cameras, doorbells, lights, sensors, and base stations.
⚠️ Beta Release Notice (
v0.9.0-beta)PyArlo v0.9 is a major rewrite transitioning the entire codebase from legacy synchronous threads to native Python
asyncio.This is an active beta release — please test, report issues, and verify hardware compatibility.
Note on Hardware Testing: The maintainer does not own or have access to every Arlo hardware model (such as all generations of cameras, floodlights, doorbells, chimes, and SmartHubs) and cannot test every permutation. Community testing and feedback are essential to stabilizing this release!
If you encounter issues, regressions, or unexpected behavior with your hardware, please open a GitHub issue. Please include your Python version, Arlo device models, and sanitized/encrypted debug logs generated with
--debug-report.If you need the legacy synchronous documentation for PyArlo v0.8, it is archived in docs/README_v8.md.
Table of Contents
- Breaking Changes in v0.9
- Installation
- Command Line Interface (CLI)
- Using the Python Module
- Two-Factor Authentication (2FA)
- Operational Notes & Recommendations
- Diagnostics & Error Reporting
- Documentation Links
- Credits
Breaking Changes in v0.9
If you are upgrading from PyArlo 0.8.x, please note the following architectural changes:
- Native
asyncioCore:PyArlomust be initialized with the asynchronous factoryawait PyArlo.create(...). The synchronousPyArlo(...)constructor is deprecated.- All network and device actions are now coroutines and must be
awaited (e.g.await light.turn_on(),await location.set_mode(),await arlo.stop()).
synchronous_moderenamed toinline_mode:inline_mode=Truetells PyArlo to wait for an operation's response or event acknowledgment inline before returning.- Legacy
synchronous_moderemains as a deprecated alias.
- Execution & Startup Optimizations:
start_background=False: Fast one-shot mode that skips connecting to persistent MQTT/SSE event streams and cron loops.refresh_devices=False: Skips querying/users/devicesand reuses locally cached device definitions.- Optimistic token reuse: Valid session tokens are reused directly without making redundant network calls to
/api/validateAccessToken.
- CLI Reorganization:
- The CLI has been split into three purpose-built tools:
pyaarlo,pyaarlo-monitor, andpyaarlo-utils.
- The CLI has been split into three purpose-built tools:
Installation
Requires Python >= 3.10.
# Install latest release from git
pip install git+https://github.com/twrecked/pyaarlo.git
# Or install locally in editable mode for development
git clone https://github.com/twrecked/pyaarlo.git
cd pyaarlo
pip install -e .
Command Line Interface (CLI)
PyArlo provides three command-line tools:
1. pyaarlo — Device Actions & Automations
Perform instant actions on your devices with sub-second response times:
# Check token status and expiration
pyaarlo login --status
# Interactive configuration wizard (creates or updates ~/.config/pyaarlo/config.json)
pyaarlo config create
pyaarlo config update
pyaarlo config show
# Authenticate or refresh tokens (supports push, email:imap, sms)
pyaarlo login --push
# Control lights by name or ID
pyaarlo light turn-on "Side Light"
pyaarlo light turn-on --brightness 128 "Side Light"
pyaarlo light turn-off "Side Light"
# Security modes
pyaarlo location list
pyaarlo location set-mode "armHome"
# Media library
pyaarlo media list --days 1 --compact
pyaarlo media list --object animal
pyaarlo media download --limit 5 -o ./media
# Local storage (RATLS direct USB/SD access on SmartHub / Base Station)
pyaarlo local-media status "Front Base"
pyaarlo local-media list --base "Front Base" --compact
pyaarlo local-media download --base "Front Base" --limit 5 -o ./local_media
# List devices and status
pyaarlo list devices --compact
2. pyaarlo-monitor — Real-Time Event Stream
Observe incoming live events (motion, doorbell rings, battery, mode changes):
# Stream live events
pyaarlo-monitor --compact
# Filter by camera and truncate long payloads
pyaarlo-monitor --filter-device "Front Door Bell" -l 60
# Stream events formatted as JSON lines
pyaarlo-monitor --json
3. pyaarlo-utils — Diagnostic Tools
# Dump raw device dictionaries
pyaarlo-utils dump lights
# Anonymize logs and encrypt for GitHub issue reporting
cat error.log | pyaarlo-utils anonymize | pyaarlo-utils encrypt > error.log.enc
👉 See docs/cli.md for full configuration, arguments, and options.
Using the Python Module
import asyncio
from pyaarlo import PyArlo
async def main():
# Initialize the PyArlo controller
arlo = await PyArlo.create(
username="[email protected]",
password="your-password",
tfa="push",
)
try:
# Access devices
for cam in arlo.cameras:
print(f"Camera: {cam.name} (Battery: {cam.battery_level}%)")
for light in arlo.lights:
if not light.is_on:
await light.turn_on(brightness=200)
# Set location mode
if arlo.locations:
await arlo.locations[0].set_mode("armHome")
finally:
# Cleanly stop background tasks and connections
await arlo.stop(logout=False)
if __name__ == "__main__":
asyncio.run(main())
Subscribing to Live Events
def on_event(device, attr, value):
print(f"[{device.name}] {attr} -> {value}")
# Subscribe to motion on a camera
camera.add_attr_callback("motionDetected", on_event)
# Subscribe to doorbell presses
doorbell.add_attr_callback("ding", on_event)
# Subscribe to all events on a device
camera.add_attr_callback("*", on_event)
👉 See docs/api.md for detailed API documentation and one-shot execution patterns.
Two-Factor Authentication (2FA)
PyArlo supports three primary 2FA methods:
1. Push Notification (push) — Recommended
When logging in, Arlo sends a push notification to your trusted mobile device. PyArlo waits for you to tap "Approve".
- CLI:
pyaarlo login --pushorexport ARLO_TFA="push" - Python:
arlo = await PyArlo.create(username="...", password="...", tfa="push")
2. Email via IMAP (email:imap) — Automated
PyArlo connects to your email account over IMAP and automatically reads the verification code from the email sent by Arlo.
- CLI:
pyaarlo login --tfa email:imap --tfa-host imap.gmail.com --tfa-user [email protected] --tfa-pass "app-password" - Python:
arlo = await PyArlo.create( username="...", password="...", tfa="email:imap", tfa_host="imap.gmail.com", tfa_username="...", tfa_password="..." )
3. Interactive Console (email:console or sms)
PyArlo requests Arlo to send a code via email or SMS, and prompts you to type the code into the terminal.
- CLI:
pyaarlo login --tfa smsorpyaarlo login --tfa email:console - Python:
arlo = await PyArlo.create(username="...", password="...", tfa="sms")
Choosing the factor
Arlo calls each 2FA destination a factor: an email address, a phone number, or a phone running the Arlo app. By default PyArlo picks one by matching the tfa type and then tfa_nickname. When the account has several factors of the same type, two phones for example, name the one you want with tfa_factor_id; it wins over both.
- CLI:
pyaarlo tfa-factorslists the ids, thenpyaarlo login --factor-id <id>orexport ARLO_TFA_FACTOR_ID="<id>" - Python:
for factor in await arlo.tfa_factors(): print(factor["factorType"], factor["factorNickname"], factor["factorId"]) arlo = await PyArlo.create(username="...", password="...", tfa_factor_id="<id>")
The flow follows the factor: a PUSH factor always waits for the approval on the phone, whatever tfa says. PyArlo waits up to 5 minutes for the approval, like the Arlo web app, and stops straight away if you tap deny. Tune it with tfa_push_timeout and tfa_push_poll.
Step by step login for setup screens (ArloLogin)
A setup UI can show the user their real factors and let them choose, instead of asking which 2FA method to use up front. ArloLogin only logs in; it doesn't read devices or start the event stream.
from pyaarlo import ArloLogin, LoginStep
login = ArloLogin(username="...", password="...", storage_dir=STORAGE_DIR)
step = await login.start()
if step == LoginStep.NEEDS_FACTOR:
step = await login.choose_factor(pick_one(login.factors)["factorId"])
while step == LoginStep.AWAITING_PUSH:
await asyncio.sleep(login.push_poll)
step = await login.poll_push()
if step == LoginStep.AWAITING_CODE:
step = await login.submit_code(input("Code: "))
await login.close()
On SUCCESS the session and cookies are saved in storage_dir and Arlo trusts this "browser". A later PyArlo.create() with the same username, storage_dir and user_agent reuses them and doesn't need 2FA again until the trust expires.
PyArlo keeps presenting the user agent a browser was paired with, as long as the user_agent setting doesn't change, so random no longer throws the trust away on every login.
Operational Notes & Recommendations
Choosing an Event Stream Backend (MQTT vs. SSE)
PyArlo supports two streaming backends for real-time device updates:
- MQTT (
mqtt) — Default:- Modern, lightweight WebSocket protocol used by Arlo's official mobile apps.
- Supports multiple concurrent connections: you can run
pyaarlo-monitorin one terminal while running action commands or scripts in another without interrupting your session. - Limitation: Arlo does not publish every legacy event type (such as stream snapshot notifications) over MQTT.
- SSE (
sse) — Legacy:- HTTP Server-Sent Events stream (
/subscribe). - Emits a broader range of legacy event types (like stream snapshots).
- Limitation: Arlo restricts SSE to a single active connection per account. Opening a second stream will disconnect the first. You can select it with
--backend sseor--sseonpyaarlo-monitor.
- HTTP Server-Sent Events stream (
Dedicated Arlo Account Recommendation
Even though MQTT allows concurrent event streams with your primary mobile app without immediately logging you out, we strongly recommend creating a separate, dedicated Arlo account and sharing your cameras/devices to it:
- Security & Least Privilege: Protects your primary account credentials and limits access strictly to the shared devices.
- Session Stability: Prevents token refresh races and conflicting login state between automation scripts, Home Assistant, and your mobile phone app.
Diagnostics & Error Reporting
Automated Debug Report (--debug-report)
You can append --debug-report to any pyaarlo command. It automatically records all debug logs, anonymizes sensitive tokens/passwords, and encrypts the diagnostic package using PyArlo's public key:
pyaarlo --debug-report light turn-on "Side Light"
pyaarlo --debug-report login
This writes pyaarlo-debug-report.enc, which you can safely attach directly to a GitHub Issue.
Enabling Verbose Logs
Pass -v (INFO) or -vv (DEBUG) to any CLI tool, or enable debug logging in Python:
import logging
logging.basicConfig(level=logging.DEBUG)
Anonymizing & Encrypting Diagnostics for Issues
To safely report bugs without exposing personal credentials, device IDs, or tokens:
# Anonymize account identifiers and encrypt using PyArlo's public key
cat trace.log | pyaarlo-utils anonymize | pyaarlo-utils encrypt > trace.log.enc
You can paste the resulting -----BEGIN PYAARLO DUMP----- block directly into a GitHub Issue. Only the repository maintainers holding the private key can decrypt it.
Recording Browser Traffic (.har)
If troubleshooting unexpected Arlo web changes:
- Open my.arlo.com in Chrome/Firefox.
- Open Developer Tools (
F12), switch to the Network tab, and check Preserve log. - Perform the action (e.g. view stream, arm device, toggle light).
- Right-click any network request and select Save all as HAR with content.
- Anonymize and encrypt the
.harfile usingpyaarlo-utilsbefore sharing.
Documentation Links
- CLI Reference Guide — Complete manual for
pyaarlo,pyaarlo-monitor, andpyaarlo-utils. - Python API Reference — Asynchronous API documentation, classes, and lifecycle options.
- Legacy v0.8 Documentation — Preserved synchronous v0.8 documentation.
- v0.9.0-beta.7 Release Notes — V3 Custom Mode per-device control, mode query CLI, and event snapshot updates.
- v0.9.0-alpha.9 Release Notes — Dynamic capability document parsing, static fallbacks, and expanded capabilities CLI diagnostics.
- v0.9.0-alpha.8 Release Notes — Media retention policies, disk space management, and offline media pruning CLI.\n- v0.9.0-alpha.6 Release Notes — CLI packaging standardization and removal of legacy bin/ scripts.
- v0.9.0-alpha.5 Release Notes — Fix SSE stream connectivity and async streaming with curl_cffi.
- v0.9.0-alpha.4 Release Notes — Push 2FA rate-limit protection and troubleshooting knowledge base.
- v0.9.0-alpha.3 Release Notes — Session transaction tracking, directory auto-creation, and CLI inline live stream support.
- v0.9.0-alpha.2 Release Notes — Session stability, request draining, V3 mode sync, and API normalization.
- v0.9.0-alpha.1 Release Notes — Detailed overview of the v0.9 native asyncio rewrite.
Credits
Special thanks to:
- Edwin Anne for reverse-engineering the SIP/WebRTC signaling protocol and contributing the foundational SDP repairs and SIP client (PR #210).
- Pyarlo and Arlo for the original foundational reverse-engineering work.
- JetBrains for their past support providing open source development licenses throughout most of the v0.8 releases.
استكشف مشاريع مشابهة ومرتبطة
جارٍ التحميل…