Emulated Roku Device to Bridge HA and Logitech Harmony. Added MQTT and Docker support
  • Python 95.6%
  • Dockerfile 2.4%
  • Makefile 2%
Find a file
Kevin a4cfa1ac6c
All checks were successful
Build and Push OCI Container / build-and-push (push) Successful in 21s
Build and Push OCI Container / call-docker-build-and-push (push) Successful in 0s
Upstep to Python 3.14 (#6)
Co-authored-by: Kevin Van Boom <kevin.vanboom@softathome.com>
Reviewed-on: #6
2026-06-04 12:47:51 +02:00
.forgejo/workflows use shared workflow 2026-05-22 18:46:03 +00:00
emulated_roku added mqtts support 2026-05-26 00:14:10 +02:00
.dockerignore first commit 2026-02-12 16:28:53 +01:00
.env.example added mqtts support 2026-05-26 00:14:10 +02:00
.gitignore first commit 2026-02-12 16:28:53 +01:00
advertise.py first commit 2026-02-12 16:28:53 +01:00
docker-compose.yml first commit 2026-02-12 16:28:53 +01:00
DOCKER.md first commit 2026-02-12 16:28:53 +01:00
Dockerfile Upstep to Python 3.14 (#6) 2026-06-04 12:47:51 +02:00
entrypoint.py Upstep to Python 3.14 (#6) 2026-06-04 12:47:51 +02:00
example.py added mqtts support 2026-05-26 00:14:10 +02:00
LICENSE first commit 2026-02-12 16:28:53 +01:00
Makefile first commit 2026-02-12 16:28:53 +01:00
pyproject.toml first commit 2026-02-12 16:28:53 +01:00
README.md Link to original creator 2026-05-23 13:09:32 +00:00
setup.cfg first commit 2026-02-12 16:28:53 +01:00
setup.py first commit 2026-02-12 16:28:53 +01:00

emulated_roku

Thid code is based on https://github.com/martonperei/emulated_roku.

This library is for emulating the Roku API. Discovery is tested with Logitech Harmony and Android remotes. Only key press / down / up events and app launches (10 dummy apps) are implemented in the RokuCommandHandler callback. Other functionality such as input, search will not work.

Features

  • Emulates Roku External Control Protocol (ECP)
  • SSDP/UPnP discovery support
  • MQTT integration for key press events
  • Customizable app list
  • Docker deployment support

Quick Start

docker-compose up -d

See DOCKER.md for full Docker documentation.

Python Usage

See the example on how to use.

Custom Applications

Application list can be customized with a string in this format:

1:first-app,2:second-app,3:third-app

Which would generate this response:

<apps>
    <app id="1" version="1.0.0">first-app</app>
    <app id="2" version="1.0.0">second-app</app>
    <app id="3" version="1.0.0">third-app</app>
</apps>

MQTT Integration

The handler supports MQTT publishing for key press events with automatic reconnection handling. Configure MQTT settings when initializing:

handler = emulated_roku.EmulatedRokuCommandHandler(
    mqtt_address="192.168.1.100",
    mqtt_port=1883,
    mqtt_user="username",
    mqtt_password="password",
    mqtt_topic="roku/keypress",
    mqtt_reconnect_delay=5,           # Initial reconnection delay in seconds (default: 5)
    mqtt_max_reconnect_delay=300      # Maximum reconnection delay in seconds (default: 300)
)

Key press events are published as JSON:

{
  "event": "keypress",
  "device": "roku_name",
  "key": "VolumeUp"
}

MQTT Reconnection

The MQTT client automatically handles disconnections and reconnects using exponential backoff:

  • Starts with initial delay (default: 5 seconds)
  • Increases delay exponentially on subsequent connection failures
  • Caps at maximum delay (default: 300 seconds / 5 minutes)
  • Connection status is logged for monitoring