| Name | ev-remote-lib JSON | 
            
| Version | 
                  0.8.0
                   
                  JSON | 
            
 | download  | 
            
| home_page | None  | 
            
| Summary | A robust Python library for handling Bluetooth and USB remote controls with automatic reconnection | 
            | upload_time | 2025-11-01 16:48:59 | 
            | maintainer | None | 
            
            | docs_url | None | 
            | author | foxy82 | 
            
            | requires_python | >=3.12 | 
            
            
            | license | MIT License  Copyright (c) 2025 foxy82  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | 
            | keywords | 
                
                    bluetooth
                
                     usb
                
                     remote
                
                     control
                
                     evdev
                
                     udev
                
                     input
                
                     linux
                 | 
            | VCS | 
                
                     | 
                
            
            | bugtrack_url | 
                
                 | 
             
            
            | requirements | 
                
                  No requirements were recorded.
                
             | 
            
| Travis-CI | 
                
                   No Travis.
                
             | 
            | coveralls test coverage | 
                
                   No coveralls.
                
             | 
        
        
            
            # Bluetooth Remote Control Library
[](https://badge.fury.io/py/bluetooth-remote-lib)
[](https://pypi.org/project/bluetooth-remote-lib/)
[](https://opensource.org/licenses/MIT)
A robust Python library for handling Bluetooth remote controls that go to sleep, combining udev device monitoring with evdev event handling for seamless reconnection and event processing.
## Features
- ๐ **Automatic Reconnection**: Handles Bluetooth remotes that go to sleep and wake up
- ๐ฑ **Multiple Device Support**: Manage multiple remotes simultaneously with individual configurations
- โก **Real-time Detection**: Uses udev for instant device discovery (no polling)
- ๐ฏ **Flexible Filtering**: Filter devices by name, vendor ID, product ID, or bus type
- ๐ง **Per-Device Handlers**: Different event handlers and settings for each remote type
- ๐๏ธ **Async/Await**: Built with modern Python async patterns
- ๐งต **Thread-Safe**: Proper threading and cleanup
- ๐ **Device Discovery**: Built-in tools to find your remote's details
## Installation
### Using uv (recommended)
```bash
uv add bluetooth-remote-lib
```
### Using pip
```bash
pip install bluetooth-remote-lib
```
## Quick Start
```python
import asyncio
from bluetooth_remote_lib import RemoteManager, RemoteEventHandler, KeyEvent
class MyHandler(RemoteEventHandler):
    async def on_key_event(self, event: KeyEvent):
        print(f"Key pressed: {event.keycode}")
async def main():
    handler = MyHandler()
    manager = RemoteManager(
        event_handler=handler,
        device_filters={'name': 'remote'}  # Match devices with 'remote' in name
    )
    
    async with manager.managed_context():
        await asyncio.sleep(60)  # Run for 60 seconds
asyncio.run(main())
```
## Advanced Usage - Multiple Remotes
```python
import asyncio
from bluetooth_remote_lib import (
    RemoteManager, RemoteEventHandler, RemoteConfig,
    KeyEvent, KeyEventType, DeviceInfo
)
# Define handlers for specific remotes
async def handle_fire_tv(event: KeyEvent):
    if event.event_type == KeyEventType.KEY_DOWN:
        print(f"๐ฅ Fire TV: {event.keycode}")
async def handle_roku(event: KeyEvent):
    if event.event_type == KeyEventType.KEY_DOWN:
        print(f"๐บ Roku: {event.keycode}")
class MainHandler(RemoteEventHandler):
    async def on_key_event(self, event: KeyEvent):
        print(f"Generic remote: {event.keycode}")
    
    async def on_device_connected(self, device_info: DeviceInfo):
        print(f"Connected: {device_info.name}")
# Configure multiple remotes with individual settings
remote_configs = [
    RemoteConfig(
        name="Fire TV Remote",
        filters={
            'name': 'fire tv',
            'vendor_id': 0x1949,  # Amazon
        },
        handler=handle_fire_tv,
        reconnect_delay=1.5,  # Custom timing
        scan_interval=3.0
    ),
    RemoteConfig(
        name="Roku Remote",
        filters={
            'name': 'roku',
            'vendor_id': 0x0B05,  # Roku
        },
        handler=handle_roku,
        reconnect_delay=2.0
    )
]
async def main():
    manager = RemoteManager(
        event_handler=MainHandler(),
        remote_configs=remote_configs
    )
    
    async with manager.managed_context():
        while True:
            await asyncio.sleep(1)
asyncio.run(main())
```
## Device Discovery
Find your remote's vendor/product IDs:
```bash
# Discover all input devices
bt-remote-discover
# Or use the module directly
python -m bluetooth_remote_lib discover
# Find specific devices
bt-remote find --name "fire tv"
bt-remote find --vendor-id 0x1949
```
Example output:
```
Device: Amazon Fire TV Remote
  Path: /dev/input/event5
  Vendor ID: 0x1949 (6473)
  Product ID: 0x0404 (1028)
  Key capabilities: 15 keys
    Keys: KEY_UP, KEY_DOWN, KEY_LEFT, KEY_RIGHT, KEY_ENTER...
```
## Configuration Options
### RemoteConfig Parameters
- **name**: Friendly name for the remote configuration
- **filters**: Dictionary of device matching criteria:
  - `name`: Substring to match in device name (case insensitive)
  - `vendor_id`: Vendor ID (integer)
  - `product_id`: Product ID (integer)  
  - `bus_type`: Bus type (integer)
- **handler**: Optional async function to handle events from this remote
- **reconnect_delay**: Custom delay before reconnection attempts (seconds)
- **scan_interval**: Custom interval between reconnection scans (seconds)
### Manager Parameters
- **event_handler**: Main event handler (RemoteEventHandler subclass)
- **remote_configs**: List of RemoteConfig objects
- **device_filters**: Legacy single filter dict (use remote_configs instead)
- **reconnect_delay**: Default reconnection delay (2.0 seconds)
- **scan_interval**: Default scan interval (5.0 seconds)
- **log_level**: Logging level (logging.INFO)
## Event Handling
### Key Events
```python
class MyHandler(RemoteEventHandler):
    async def on_key_event(self, event: KeyEvent):
        # event.keycode: 'KEY_UP', 'KEY_HOME', etc.
        # event.event_type: KEY_DOWN, KEY_UP, KEY_HOLD
        # event.timestamp: Event timestamp
        # event.device_name: Name of the device
        # event.raw_event: Original evdev event
        
        if event.event_type == KeyEventType.KEY_DOWN:
            if event.keycode == 'KEY_HOME':
                print("Home button pressed!")
```
### Device Events
```python
class MyHandler(RemoteEventHandler):
    async def on_device_connected(self, device_info: DeviceInfo):
        print(f"Device connected: {device_info.name}")
        print(f"Vendor: 0x{device_info.vendor_id:04x}")
    
    async def on_device_disconnected(self, device_info: DeviceInfo):
        print(f"Device disconnected: {device_info.name}")
    
    async def on_device_reconnecting(self, device_info: DeviceInfo):
        print(f"Reconnecting: {device_info.name}")
```
## Requirements
- **Linux**: This library uses Linux-specific evdev and udev systems
- **Python 3.8+**: Modern async/await support
- **Permissions**: May require user to be in `input` group or run with appropriate permissions
### System Setup
```bash
# Add user to input group (recommended)
sudo usermod -a -G input $USER
# Then log out and back in
# Or install udev rule for your specific devices
echo 'SUBSYSTEM=="input", GROUP="input", MODE="0664"' | sudo tee /etc/udev/rules.d/99-input.rules
sudo udevadm control --reload-rules
```
## Examples
The `examples/` directory contains:
- `basic_usage.py`: Simple single remote example
- `advanced_usage.py`: Multiple remotes with individual configurations
Run examples:
```bash
python examples/basic_usage.py
python examples/advanced_usage.py
```
## Contributing
Contributions welcome! Please feel free to submit a Pull Request.
1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Add tests if applicable
5. Submit a pull request
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## Changelog
See [CHANGELOG.md](CHANGELOG.md) for version history and changes.
## Support
- **Issues**: [GitHub Issues](https://github.com/yourusername/bluetooth-remote-lib/issues)
- **Discussions**: [GitHub Discussions](https://github.com/yourusername/bluetooth-remote-lib/discussions)
## Related Projects
- [evdev](https://python-evdev.readthedocs.io/) - Linux input handling
- [pyudev](https://pyudev.readthedocs.io/) - Python udev bindings
            
         
        Raw data
        
            {
    "_id": null,
    "home_page": null,
    "name": "ev-remote-lib",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.12",
    "maintainer_email": null,
    "keywords": "bluetooth, USB, remote, control, evdev, udev, input, linux",
    "author": "foxy82",
    "author_email": "foxy82 <foxy82.github@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/ca/e9/594c712cce09b3c28276c871cc161ed787d8b505e455a0b75adbf092c2c8/ev_remote_lib-0.8.0.tar.gz",
    "platform": null,
    "description": "# Bluetooth Remote Control Library\n\n[](https://badge.fury.io/py/bluetooth-remote-lib)\n[](https://pypi.org/project/bluetooth-remote-lib/)\n[](https://opensource.org/licenses/MIT)\n\nA robust Python library for handling Bluetooth remote controls that go to sleep, combining udev device monitoring with evdev event handling for seamless reconnection and event processing.\n\n## Features\n\n- \ud83d\udd04 **Automatic Reconnection**: Handles Bluetooth remotes that go to sleep and wake up\n- \ud83d\udcf1 **Multiple Device Support**: Manage multiple remotes simultaneously with individual configurations\n- \u26a1 **Real-time Detection**: Uses udev for instant device discovery (no polling)\n- \ud83c\udfaf **Flexible Filtering**: Filter devices by name, vendor ID, product ID, or bus type\n- \ud83d\udd27 **Per-Device Handlers**: Different event handlers and settings for each remote type\n- \ud83c\udfd7\ufe0f **Async/Await**: Built with modern Python async patterns\n- \ud83e\uddf5 **Thread-Safe**: Proper threading and cleanup\n- \ud83d\udd0d **Device Discovery**: Built-in tools to find your remote's details\n\n## Installation\n\n### Using uv (recommended)\n\n```bash\nuv add bluetooth-remote-lib\n```\n\n### Using pip\n\n```bash\npip install bluetooth-remote-lib\n```\n\n## Quick Start\n\n```python\nimport asyncio\nfrom bluetooth_remote_lib import RemoteManager, RemoteEventHandler, KeyEvent\n\nclass MyHandler(RemoteEventHandler):\n    async def on_key_event(self, event: KeyEvent):\n        print(f\"Key pressed: {event.keycode}\")\n\nasync def main():\n    handler = MyHandler()\n    manager = RemoteManager(\n        event_handler=handler,\n        device_filters={'name': 'remote'}  # Match devices with 'remote' in name\n    )\n    \n    async with manager.managed_context():\n        await asyncio.sleep(60)  # Run for 60 seconds\n\nasyncio.run(main())\n```\n\n## Advanced Usage - Multiple Remotes\n\n```python\nimport asyncio\nfrom bluetooth_remote_lib import (\n    RemoteManager, RemoteEventHandler, RemoteConfig,\n    KeyEvent, KeyEventType, DeviceInfo\n)\n\n# Define handlers for specific remotes\nasync def handle_fire_tv(event: KeyEvent):\n    if event.event_type == KeyEventType.KEY_DOWN:\n        print(f\"\ud83d\udd25 Fire TV: {event.keycode}\")\n\nasync def handle_roku(event: KeyEvent):\n    if event.event_type == KeyEventType.KEY_DOWN:\n        print(f\"\ud83d\udcfa Roku: {event.keycode}\")\n\nclass MainHandler(RemoteEventHandler):\n    async def on_key_event(self, event: KeyEvent):\n        print(f\"Generic remote: {event.keycode}\")\n    \n    async def on_device_connected(self, device_info: DeviceInfo):\n        print(f\"Connected: {device_info.name}\")\n\n# Configure multiple remotes with individual settings\nremote_configs = [\n    RemoteConfig(\n        name=\"Fire TV Remote\",\n        filters={\n            'name': 'fire tv',\n            'vendor_id': 0x1949,  # Amazon\n        },\n        handler=handle_fire_tv,\n        reconnect_delay=1.5,  # Custom timing\n        scan_interval=3.0\n    ),\n    RemoteConfig(\n        name=\"Roku Remote\",\n        filters={\n            'name': 'roku',\n            'vendor_id': 0x0B05,  # Roku\n        },\n        handler=handle_roku,\n        reconnect_delay=2.0\n    )\n]\n\nasync def main():\n    manager = RemoteManager(\n        event_handler=MainHandler(),\n        remote_configs=remote_configs\n    )\n    \n    async with manager.managed_context():\n        while True:\n            await asyncio.sleep(1)\n\nasyncio.run(main())\n```\n\n## Device Discovery\n\nFind your remote's vendor/product IDs:\n\n```bash\n# Discover all input devices\nbt-remote-discover\n\n# Or use the module directly\npython -m bluetooth_remote_lib discover\n\n# Find specific devices\nbt-remote find --name \"fire tv\"\nbt-remote find --vendor-id 0x1949\n```\n\nExample output:\n```\nDevice: Amazon Fire TV Remote\n  Path: /dev/input/event5\n  Vendor ID: 0x1949 (6473)\n  Product ID: 0x0404 (1028)\n  Key capabilities: 15 keys\n    Keys: KEY_UP, KEY_DOWN, KEY_LEFT, KEY_RIGHT, KEY_ENTER...\n```\n\n## Configuration Options\n\n### RemoteConfig Parameters\n\n- **name**: Friendly name for the remote configuration\n- **filters**: Dictionary of device matching criteria:\n  - `name`: Substring to match in device name (case insensitive)\n  - `vendor_id`: Vendor ID (integer)\n  - `product_id`: Product ID (integer)  \n  - `bus_type`: Bus type (integer)\n- **handler**: Optional async function to handle events from this remote\n- **reconnect_delay**: Custom delay before reconnection attempts (seconds)\n- **scan_interval**: Custom interval between reconnection scans (seconds)\n\n### Manager Parameters\n\n- **event_handler**: Main event handler (RemoteEventHandler subclass)\n- **remote_configs**: List of RemoteConfig objects\n- **device_filters**: Legacy single filter dict (use remote_configs instead)\n- **reconnect_delay**: Default reconnection delay (2.0 seconds)\n- **scan_interval**: Default scan interval (5.0 seconds)\n- **log_level**: Logging level (logging.INFO)\n\n## Event Handling\n\n### Key Events\n\n```python\nclass MyHandler(RemoteEventHandler):\n    async def on_key_event(self, event: KeyEvent):\n        # event.keycode: 'KEY_UP', 'KEY_HOME', etc.\n        # event.event_type: KEY_DOWN, KEY_UP, KEY_HOLD\n        # event.timestamp: Event timestamp\n        # event.device_name: Name of the device\n        # event.raw_event: Original evdev event\n        \n        if event.event_type == KeyEventType.KEY_DOWN:\n            if event.keycode == 'KEY_HOME':\n                print(\"Home button pressed!\")\n```\n\n### Device Events\n\n```python\nclass MyHandler(RemoteEventHandler):\n    async def on_device_connected(self, device_info: DeviceInfo):\n        print(f\"Device connected: {device_info.name}\")\n        print(f\"Vendor: 0x{device_info.vendor_id:04x}\")\n    \n    async def on_device_disconnected(self, device_info: DeviceInfo):\n        print(f\"Device disconnected: {device_info.name}\")\n    \n    async def on_device_reconnecting(self, device_info: DeviceInfo):\n        print(f\"Reconnecting: {device_info.name}\")\n```\n\n## Requirements\n\n- **Linux**: This library uses Linux-specific evdev and udev systems\n- **Python 3.8+**: Modern async/await support\n- **Permissions**: May require user to be in `input` group or run with appropriate permissions\n\n### System Setup\n\n```bash\n# Add user to input group (recommended)\nsudo usermod -a -G input $USER\n# Then log out and back in\n\n# Or install udev rule for your specific devices\necho 'SUBSYSTEM==\"input\", GROUP=\"input\", MODE=\"0664\"' | sudo tee /etc/udev/rules.d/99-input.rules\nsudo udevadm control --reload-rules\n```\n\n## Examples\n\nThe `examples/` directory contains:\n\n- `basic_usage.py`: Simple single remote example\n- `advanced_usage.py`: Multiple remotes with individual configurations\n\nRun examples:\n```bash\npython examples/basic_usage.py\npython examples/advanced_usage.py\n```\n\n## Contributing\n\nContributions welcome! Please feel free to submit a Pull Request.\n\n1. Fork the repository\n2. Create a feature branch\n3. Make your changes\n4. Add tests if applicable\n5. Submit a pull request\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Changelog\n\nSee [CHANGELOG.md](CHANGELOG.md) for version history and changes.\n\n## Support\n\n- **Issues**: [GitHub Issues](https://github.com/yourusername/bluetooth-remote-lib/issues)\n- **Discussions**: [GitHub Discussions](https://github.com/yourusername/bluetooth-remote-lib/discussions)\n\n## Related Projects\n\n- [evdev](https://python-evdev.readthedocs.io/) - Linux input handling\n- [pyudev](https://pyudev.readthedocs.io/) - Python udev bindings",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2025 foxy82  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": "A robust Python library for handling Bluetooth and USB remote controls with automatic reconnection",
    "version": "0.8.0",
    "project_urls": {
        "Homepage": "https://github.com/designer-living/ev-remote-lib",
        "Issues": "https://github.com/designer-living/ev-remote-lib/issues",
        "Repository": "https://github.com/designer-living/ev-remote-lib"
    },
    "split_keywords": [
        "bluetooth",
        " usb",
        " remote",
        " control",
        " evdev",
        " udev",
        " input",
        " linux"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "a253b335e1a23fdb14942200ea9c50f5f638b2830a94038ccee2ec56e297be12",
                "md5": "2e75e1bb40948869efa59ea6e557e474",
                "sha256": "8fa610f5734246db120a6142365e563e1addf36b8d8a72180a9669159b74879c"
            },
            "downloads": -1,
            "filename": "ev_remote_lib-0.8.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2e75e1bb40948869efa59ea6e557e474",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.12",
            "size": 7696,
            "upload_time": "2025-11-01T16:48:58",
            "upload_time_iso_8601": "2025-11-01T16:48:58.052438Z",
            "url": "https://files.pythonhosted.org/packages/a2/53/b335e1a23fdb14942200ea9c50f5f638b2830a94038ccee2ec56e297be12/ev_remote_lib-0.8.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "cae9594c712cce09b3c28276c871cc161ed787d8b505e455a0b75adbf092c2c8",
                "md5": "8885034819816115c6bdf04b49e39f85",
                "sha256": "31140c5562612ff57a8bc30ca85a52352cc18acbf964c1574d7fa48308a977f6"
            },
            "downloads": -1,
            "filename": "ev_remote_lib-0.8.0.tar.gz",
            "has_sig": false,
            "md5_digest": "8885034819816115c6bdf04b49e39f85",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.12",
            "size": 6819,
            "upload_time": "2025-11-01T16:48:59",
            "upload_time_iso_8601": "2025-11-01T16:48:59.060411Z",
            "url": "https://files.pythonhosted.org/packages/ca/e9/594c712cce09b3c28276c871cc161ed787d8b505e455a0b75adbf092c2c8/ev_remote_lib-0.8.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-11-01 16:48:59",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "designer-living",
    "github_project": "ev-remote-lib",
    "github_not_found": true,
    "lcname": "ev-remote-lib"
}