Skip to main content

MadVR Envy Python Library

This library implements the IP control specification for madVR Envy.

It supports real time notifications and commands asynchronously. It is intended to be used with my official Home Assistant integration (madvr)

Installation

pip install py-madvr2

Usage

from pymadvr.madvr import Madvr

# Create instance
madvr = Madvr("192.168.1.100")  # Replace with your MadVR IP

# Connect and use
await madvr.open_connection()
response = await madvr.send_command(["GetMacAddress"])
await madvr.close_connection()

Connection Architecture

This library uses an efficient connection management system:

  • User Commands: Uses a simple connection pool that keeps connections alive for 10 seconds after last use, automatically extending the timeout when new commands arrive
  • Background Tasks: Use direct connections to avoid interference with user commands
  • Automatic Cleanup: Idle connections are automatically closed to respect MadVR's 60-second connection limit

This design eliminates connection race conditions and hanging issues while providing optimal performance.

Wake On Lan

If the client is initialized without a mac, it will assume you provide your own wake on lan automation. Standby does not respond to pings so you may as well do a full power off. You may also provide a mac when you call the power on function.

Commands

Command structure follows the same in the manual https://madvrenvy.com/wp-content/uploads/EnvyIpControl.pdf?r=112a

For things that take values, use a comma -> ["KeyPress, MENU"]

Not every single command is implemented, such as submenus or changing complicated options. You can use commands for all the typical stuff the remote can do.

Typing

This module uses mypy with strict typing.

Display Commands

async def demo_display_commands():
    """Demonstrate the new display commands."""

    # Initialize MadVR connection
    from pymadvr.madvr import Madvr
    madvr = Madvr("192.168.1.100")  # Replace with your MadVR IP

    try:
        # Connect to MadVR
        await madvr.open_connection()

        # Display a message for 3 seconds
        await madvr.display_message(3, "Hello from Python!")
        await asyncio.sleep(4)  # Wait for message to clear

        # Display audio volume control (0-100%, currently at 75%)
        await madvr.display_audio_volume(0, 75, 100, "%")
        await asyncio.sleep(3)

        # Show audio mute indicator
        await madvr.display_audio_mute()
        await asyncio.sleep(2)

        # Close the audio mute indicator
        await madvr.close_audio_mute()

        # Display decibel-based volume (AVR style: -80dB to 0dB, currently -25dB)
        await madvr.display_audio_volume(-80, -25, 0, "dB")
        await asyncio.sleep(3)

    except Exception as e:
        print(f"Error: {e}")
    finally:
        await madvr.close_connection()

Testing

Unit Tests

Run unit tests with:

pytest tests/test_MadVR.py -v

Integration Tests

Integration tests require a real MadVR device on the network. Set these environment variables:

# Required for Wake-on-LAN functionality
export MADVR_MAC=00:11:22:33:44:55  # Your device's MAC address

# Optional (defaults shown)
export MADVR_HOST=192.168.1.100
export MADVR_PORT=44077

To get your device's MAC address (device must be on):

python scripts/power_on_device.py --get-mac

To power on the device for testing:

python scripts/power_on_device.py

Run integration tests:

pytest tests/test_simple_integration.py -v

Run connection pool tests:

pytest tests/test_connection_pool.py -v

Integration tests will automatically skip if the device is not available.

Connection Pool Testing

The connection pool tests verify:

  • Connection reuse and timeout behavior
  • Background task isolation
  • No hanging or race conditions

These tests help ensure the reliability improvements in the connection management system.

Metadata

Release files for py-madvr2 1.9.1

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

Source distribution (sdist)

Source distribution for py-madvr2 1.9.1
File Size Uploaded
py_madvr2-1.9.1.tar.gz 30.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for py-madvr2 1.9.1
File Interpreter ABI Platform
py_madvr2-1.9.1-py3-none-any.whl Python 3 none any Details

Total release size: 52.4 kB

Release files / py_madvr2-1.9.1.tar.gz

Download URL py_madvr2-1.9.1.tar.gz
Size 30.2 kB
Tags Source
SHA-256 checksum
How to use checksums
ce4d2f5cd9e721d09f2392b34f3fec066e8ddb232c65db5cc6cb6d46bbfb02b6
BLAKE2b-256 checksum
How to use checksums
e9a7c771afcd332d34a374ca0e4c1ceca81048fc293e72b33e00d8af29833ce1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 Dec 30, 2025.

Transparency log

Release files / py_madvr2-1.9.1-py3-none-any.whl

Download URL py_madvr2-1.9.1-py3-none-any.whl
Size 22.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9100c1809d89d26721bc3d889c6f017d55dfd5aa32e1a3f3ee612cb822e1fbe4
BLAKE2b-256 checksum
How to use checksums
43f0f56881fc764dc2b68fa4805fdc3c01c3b426c984ccf5daa8c0c3a1b03dbb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 Dec 30, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

1.9.1 This release

2 release files

1.9.0

2 release files

1.8.14

2 release files

1.8.13

2 release files

1.8.12

2 release files

1.8.11

2 release files

1.8.10

2 release files

1.8.9

2 release files

1.8.8

2 release files

1.8.7

2 release files

1.8.6

2 release files

1.8.5

2 release files

1.8.4

2 release files

1.8.3

2 release files

1.8.2

2 release files

1.8.1

2 release files

1.8.0

2 release files

1.7.5

2 release files

1.7.4

2 release files

1.7.3

2 release files

1.7.1

2 release files

1.6.40

2 release files

1.6.39

2 release files

1.6.38

2 release files

1.6.37

2 release files

1.6.36

2 release files

1.6.29

2 release files

1.6.16

2 release files

1.6.15

2 release files

1.6.14

2 release files

1.6.13

2 release files

1.6.12

2 release files

1.6.11

2 release files

1.6.10

2 release files

1.6.9

2 release files

1.6.8

2 release files

1.6.7

2 release files

1.6.6

2 release files

1.6.5

2 release files

1.6.4

2 release files

1.6.3

2 release files

1.6.2

2 release files

1.6.1

2 release files

1.6.0

2 release files

1.5.99

2 release files

1.5.98

2 release files

1.5.97

2 release files

1.5.96

2 release files

1.5.95

2 release files

1.5.94

2 release files

1.5.92

2 release files

1.5.91

2 release files

1.5.9

2 release files

1.5.8

2 release files

1.5.7

2 release files

1.5.6

2 release files

1.5.5

2 release files

1.5.4

2 release files

1.5.2

2 release files

1.5.1

2 release files

1.5.0

2 release files

1.4.91

2 release files

1.4.9

2 release files

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