Async Python library for controlling Manhattan T4/T4R TV Box via HTTP
Project description
Manhattan Remote
Async Python library for controlling Manhattan T4 and T4R TV Boxes via their HTTP interface.
Features
- Async/await support - Built with
aiohttpfor non-blocking I/O - Full remote control - All remote buttons mapped and available
- Model detection - Automatically detects T4 vs T4R models
- Press and hold - Support for long-press actions
- Type hints - Full typing support for better IDE integration
- Context manager - Clean resource management with async context managers
Installation
Using uv:
uv pip install manhattan-remote
Using pip:
pip install manhattan-remote
Quick Start
import asyncio
from manhattan_remote import ManhattanRemote
async def main():
# Using context manager (recommended)
async with ManhattanRemote("192.168.1.100") as remote:
# Check if device is available
if await remote.check_alive():
print("TV Box is online!")
# Get model
model = await remote.get_model()
print(f"Model: {model.value}")
# Navigate and select
await remote.up()
await remote.right()
await remote.ok()
# Volume control
await remote.volume_up()
await remote.mute()
# Change channel
await remote.channel(105)
asyncio.run(main())
Usage
Basic Remote Control
async with ManhattanRemote("192.168.1.100") as remote:
# Navigation
await remote.up()
await remote.down()
await remote.left()
await remote.right()
await remote.ok()
await remote.back()
# Home and menu
await remote.home()
await remote.guide()
await remote.info()
await remote.exit()
# Volume and channels
await remote.volume_up()
await remote.volume_down()
await remote.channel_up()
await remote.channel_down()
await remote.mute()
# Playback
await remote.play_pause()
await remote.stop()
await remote.fast_forward()
await remote.rewind()
# Color buttons
await remote.red()
await remote.green()
await remote.yellow()
await remote.blue()
# Numbers
await remote.number(5)
await remote.channel(123) # Changes to channel 123
Advanced Features
from manhattan_remote import ManhattanRemote, KeyCode, KeyEventType
async with ManhattanRemote("192.168.1.100", timeout=10) as remote:
# Check connection
is_alive = await remote.check_alive()
# Detect model
model = await remote.get_model()
if model == ManhattanModel.T4:
print("This is a T4 model")
# Send raw key codes
await remote.send_key(KeyCode.POWER)
# Press and hold (e.g., for volume)
await remote.press_and_hold(KeyCode.VOL_PLUS, duration=2.0)
# Custom key event types
await remote.send_key(KeyCode.OK, KeyEventType.KEY_DOWN)
await asyncio.sleep(0.5)
await remote.send_key(KeyCode.OK, KeyEventType.KEY_UP)
Reusing aiohttp Session
import aiohttp
from manhattan_remote import ManhattanRemote
async with aiohttp.ClientSession() as session:
remote1 = ManhattanRemote("192.168.1.100", session=session)
remote2 = ManhattanRemote("192.168.1.101", session=session)
await remote1.power()
await remote2.power()
Key Codes
All remote control buttons are available as methods or via the KeyCode enum:
Common Keys (T4 & T4R)
- Power, Mute
- Numbers 0-9
- Navigation (Up, Down, Left, Right, OK)
- Back, Home, Exit, Guide, Info
- Volume +/-, Channel +/-
- Play/Pause, Stop, Fast Forward, Rewind
- Color buttons (Red, Green, Yellow, Blue)
- Search, Swap, Zoom, AD (Audio Description)
T4 Specific
- Settings
- Featured
T4R Specific
- Rec (Record)
- RC/ES
Configuration
The ManhattanRemote constructor accepts the following parameters:
host(str): IP address or hostname of the TV box (required)port(int): HTTP port (default: 80)timeout(int): Request timeout in seconds (default: 5)session(aiohttp.ClientSession): Optional session to reuse
Error Handling
from manhattan_remote import (
ManhattanRemote,
ManhattanError,
ManhattanConnectionError,
ManhattanTimeoutError
)
async with ManhattanRemote("192.168.1.100") as remote:
try:
await remote.power()
except ManhattanTimeoutError:
print("Request timed out")
except ManhattanConnectionError:
print("Could not connect to TV box")
except ManhattanError as e:
print(f"Error: {e}")
Requirements
- Python 3.8+
- aiohttp 3.8.0+
Web Remote Setup
The web remote interface must be enabled on your Manhattan T4/T4R box:
- Go to Settings → Internet → Browsing Options
- Enable Web Remote
License
MIT License - see LICENSE file for details
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Acknowledgments
Based on the Manhattan T4/T4R web remote control interface.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file manhattan_remote-0.1.0.tar.gz.
File metadata
- Download URL: manhattan_remote-0.1.0.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d235e19fe0cbb9c1bf98f224ad33aa9776be6fdbe32b1b0b1f8ab1270e0aa497
|
|
| MD5 |
7dfb8b2ca9ae698577fd0105eb4011d2
|
|
| BLAKE2b-256 |
eacd2a5936bd55e1d45b28e41e88c6d516f0c7a17f041adaea62876956d63802
|
File details
Details for the file manhattan_remote-0.1.0-py3-none-any.whl.
File metadata
- Download URL: manhattan_remote-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f9bdc3503f23aecea23447a64e30b5de217a1ef45baf5cbfde332a1bb4c7ac54
|
|
| MD5 |
1bd65156591ab83b4f28b0d34ee26f9b
|
|
| BLAKE2b-256 |
d0947269e73bc3ace4c81438e94aab52aa9aa704ad49db253583ccd718f933a6
|