Last active
May 29, 2018 14:19
-
-
Save jutikorn/2b81b51d306a443217dd6e2025dcca67 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask | |
import broadlink | |
app = Flask(__name__) | |
TV_POWER_BUTTON = b'&\x00x\x00\x00\x01*\x93\x14\x11\x14\x11\x146\x14\x11\x14\x11\x14\x12\x14\x11\x14\x11\x146\x146\x14\x11\x146\x145\x146\x146\x146\x14\x11\x14\x11\x14\x11\x146\x14\x11\x14\x12\x14\x11\x14\x11\x146\x146\x145\x14\x12\x145\x146\x146\x145\x14\x00\x055\x00\x01)I\x14\x00\x0cL\x00\x01+H\x15\x00\x0cM\x00\x01*H\x14\x00\x0cS\x00\x01*H\x14\x00\x0cH\x00\x01*H\x15\x00\x0cL\x00\x01,G\x15\x00\r\x05' | |
devices = broadlink.discover(timeout=5, local_ip_address='192.168.1.171') # local_ip_address is my raspberryPi IP | |
if(is_devices_found()): | |
devices[0].auth() | |
def is_devices_found(): | |
return len(devices) > 0 and devices[0].auth() | |
@app.route("/", methods=['GET', 'POST']) | |
def tv_powerbutton(): | |
if(is_devices_found()): | |
devices[0].send_data(TV_POWER_BUTTON) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment