Skip to main content

Python package for setting up and retrieving data from Axis devices using MQTT

Project description

ax-devil-mqtt

Python 3.10+ License: MIT Type Hints

Python package for working with Axis devices MQTT functionality.

See also: ax-devil-device-api for device API integration.


📋 Contents


🔍 Feature Overview

Feature Description Python API CLI Tool
🔌 MQTT Connection Connect to MQTT brokers and Axis devices RawMQTTManager ax-devil-mqtt device monitor
📊 Analytics Streaming Stream analytics data from Axis devices via MQTT AnalyticsManager ax-devil-mqtt device monitor
💾 Data Recording Record any MQTT data for later replay and analysis manager.start(recording_file) ax-devil-mqtt device monitor --record
⏯️ Replay Replay recorded MQTT data for testing and development ReplayManager ax-devil-mqtt replay

🚀 Quick Start

Installation

pip install ax-devil-mqtt

Environment Variables

For an easier experience, you can set the following environment variables:

export AX_DEVIL_TARGET_ADDR=<device-ip>
export AX_DEVIL_TARGET_USER=<username>
export AX_DEVIL_TARGET_PASS=<password>
export AX_DEVIL_USAGE_CLI="safe" # Set to "unsafe" to skip SSL certificate verification for CLI calls

💻 Usage Examples

Python API Usage

🔌 MQTT Connection and Analytics Streaming

import time
from ax_devil_mqtt import AnalyticsManager
from ax_devil_device_api import DeviceConfig

# Configure device
device_config = DeviceConfig.http(
    host="192.168.1.200",
    username="root",
    password="pass"
)

def message_callback(message):
    print(message)

# Create analytics manager
manager = AnalyticsManager(
    broker_host="192.168.1.100",
    broker_port=1883,
    device_config=device_config,
    analytics_data_source_key="com.axis.analytics_scene_description.v0.beta#1",
    message_callback=message_callback
)

manager.start()
# or manager.start(recording_file="recordings/some_file_name.jsonl")
time.sleep(10)
manager.stop()

⏯️ Replay

import time
from ax_devil_mqtt import ReplayManager

def message_callback(message):
    print(message)

# Create a replay manager
manager = ReplayManager(
    recording_file="recordings/device_recording.jsonl",
    message_callback=message_callback
)

# Start the manager
manager.start()
time.sleep(10)
manager.stop()

CLI Usage Examples

🔍 (Optional): Use ax-devil-device-api CLI to find available analytics streams.

ax-devil-device-api-analytics-mqtt sources

📊 Streaming Analytics Data Source

ax-devil-mqtt device monitor \
    --device-ip <device-ip> \
    --username <username> \
    --password <password> \
    --broker <broker-ip> \
    --port 1883 \
    --stream "com.axis.analytics_scene_description.v0.beta#1" \
    --duration 3600

💾 Recording MQTT Data

ax-devil-mqtt device monitor \
    --device-ip <device-ip> \
    --username <username> \
    --password <password> \
    --broker <broker-ip> \
    --port 1883 \
    --stream "com.axis.analytics_scene_description.v0.beta#1" \
    --record \
    --duration 3600

⏯️ Replaying Recorded Data

ax-devil-mqtt replay recordings/device_recording.jsonl

Example Scripts

Analytics Monitor Example

python src/ax_devil_mqtt/examples/analytics_monitor.py --host <broker-ip>

Replay Example

python src/ax_devil_mqtt/examples/replay.py recordings/device_recording.jsonl

Note: For more examples, check the examples directory in the source code.


⚠️ Disclaimer

This project is an independent, community-driven implementation and is not affiliated with or endorsed by Axis Communications AB. For official APIs and development resources, please refer to Axis Developer Community.

📄 License

MIT License - See LICENSE file for details.

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

ax_devil_mqtt-0.2.3.tar.gz (15.6 kB view details)

Uploaded Source

Built Distribution

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

ax_devil_mqtt-0.2.3-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

Details for the file ax_devil_mqtt-0.2.3.tar.gz.

File metadata

  • Download URL: ax_devil_mqtt-0.2.3.tar.gz
  • Upload date:
  • Size: 15.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.12

File hashes

Hashes for ax_devil_mqtt-0.2.3.tar.gz
Algorithm Hash digest
SHA256 0e6e3604ea69600c4b1559125b567e5ecff7bbab21beab6acf338446ed2ab36f
MD5 ffff7f5c43ce7f6f679c9105f176c72b
BLAKE2b-256 29dfa27b79445af64702f33fbc5d0372f8cb9b4020d7b6fccc68b815c6464e8e

See more details on using hashes here.

File details

Details for the file ax_devil_mqtt-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: ax_devil_mqtt-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 16.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.12

File hashes

Hashes for ax_devil_mqtt-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ff6ec4d11c5c35e2f6d31f5063d381b40f4ca655a68ade1ae7b677c9fa2b63fc
MD5 579f0f67f51c87775d7e1151f89ad64b
BLAKE2b-256 106b9e849b8e0328adb11a6b15ebd2cf80eef9e785f0817150f6d1a6e84c4c5e

See more details on using hashes here.

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