From a6e93564bad8aa45a394a6471e4e1f96111f9880 Mon Sep 17 00:00:00 2001 From: Igor Barcik Date: Fri, 19 Jun 2026 12:00:57 +0200 Subject: [PATCH] feat(tv-remote-control): add Samsung TV remote control program - Add `program.py` implementing async MDC client to manage TV power state and display ID - Add `requirements.txt` with `python-samsung-mdc` dependency --- tv-remote-control/program.py | 28 ++++++++++++++++++++++++++++ tv-remote-control/requirements.txt | 1 + 2 files changed, 29 insertions(+) create mode 100644 tv-remote-control/program.py create mode 100644 tv-remote-control/requirements.txt diff --git a/tv-remote-control/program.py b/tv-remote-control/program.py new file mode 100644 index 0000000..f4a9046 --- /dev/null +++ b/tv-remote-control/program.py @@ -0,0 +1,28 @@ +import asyncio +from samsung_mdc import MDC + + +async def main(ip, display_id): + async with MDC(ip, verbose=True) as mdc: + # First argument of command is always display_id + status = await mdc.status(display_id) + print(status) # Result is always tuple + + if status[0] != MDC.power.POWER_STATE.ON: + # Command arguments are always Sequence (tuple, list) + await mdc.power(display_id, [MDC.power.POWER_STATE.ON]) + await mdc.close() # Force reconnect on next command + await asyncio.sleep(15) + + await mdc.display_id(display_id, [MDC.display_id.DISPLAY_ID_STATE.ON]) + # You may also use names or values instead of enums + await mdc.display_id(display_id, ['ON']) # same + await mdc.display_id(display_id, [1]) # same + + if True: + await mdc.power(display_id, [MDC.power.POWER_STATE.OFF]) + await mdc.close() # Force reconnect on next command + + +# If you see "Connected" and timeout error, try other display_id (0, 1) +asyncio.run(main('10.184.27.132', 1)) diff --git a/tv-remote-control/requirements.txt b/tv-remote-control/requirements.txt new file mode 100644 index 0000000..73a5518 --- /dev/null +++ b/tv-remote-control/requirements.txt @@ -0,0 +1 @@ +python-samsung-mdc