Skip to main content

A package to control MadVR Envy over IP

Project description

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.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py_madvr2-1.9.1.tar.gz (30.2 kB view details)

Uploaded Source

Built Distribution

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

py_madvr2-1.9.1-py3-none-any.whl (22.1 kB view details)

Uploaded Python 3

File details

Details for the file py_madvr2-1.9.1.tar.gz.

File metadata

  • Download URL: py_madvr2-1.9.1.tar.gz
  • Upload date:
  • Size: 30.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for py_madvr2-1.9.1.tar.gz
Algorithm Hash digest
SHA256 ce4d2f5cd9e721d09f2392b34f3fec066e8ddb232c65db5cc6cb6d46bbfb02b6
MD5 9591d5e055d3913a216baa75c157e85b
BLAKE2b-256 e9a7c771afcd332d34a374ca0e4c1ceca81048fc293e72b33e00d8af29833ce1

See more details on using hashes here.

Provenance

The following attestation bundles were made for py_madvr2-1.9.1.tar.gz:

Publisher: build.yml on iloveicedgreentea/py-madvr

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file py_madvr2-1.9.1-py3-none-any.whl.

File metadata

  • Download URL: py_madvr2-1.9.1-py3-none-any.whl
  • Upload date:
  • Size: 22.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for py_madvr2-1.9.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9100c1809d89d26721bc3d889c6f017d55dfd5aa32e1a3f3ee612cb822e1fbe4
MD5 8602332678c99dc112e621945ebd3029
BLAKE2b-256 43f0f56881fc764dc2b68fa4805fdc3c01c3b426c984ccf5daa8c0c3a1b03dbb

See more details on using hashes here.

Provenance

The following attestation bundles were made for py_madvr2-1.9.1-py3-none-any.whl:

Publisher: build.yml on iloveicedgreentea/py-madvr

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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