Skip to content

Instantly share code, notes, and snippets.

@yagop
Forked from danielfaust/samsung_remote.py
Last active January 22, 2016 21:31
Show Gist options
  • Save yagop/c0be9946d476080873b8 to your computer and use it in GitHub Desktop.
Save yagop/c0be9946d476080873b8 to your computer and use it in GitHub Desktop.
#Normal remote keys
#KEY_0
#KEY_1
#KEY_2
#KEY_3
#KEY_4
#KEY_5
#KEY_6
#KEY_7
#KEY_8
#KEY_9
#KEY_UP
#KEY_DOWN
#KEY_LEFT
#KEY_RIGHT
#KEY_MENU
#KEY_PRECH
#KEY_GUIDE
#KEY_INFO
#KEY_RETURN
#KEY_CH_LIST
#KEY_EXIT
#KEY_ENTER
#KEY_SOURCE
#KEY_AD
#KEY_PLAY
#KEY_PAUSE
#KEY_MUTE
#KEY_PICTURE_SIZE
#KEY_VOLUP
#KEY_VOLDOWN
#KEY_TOOLS
#KEY_POWEROFF
#KEY_CHUP
#KEY_CHDOWN
#KEY_CONTENTS
#KEY_W_LINK #Media P
#KEY_RSS #Internet
#KEY_MTS #Dual
#KEY_CAPTION #Subt
#KEY_REWIND
#KEY_FF
#KEY_REC
#KEY_STOP
#Bonus buttons not on the normal remote:
#KEY_TV
#Don't work/wrong codes:
#KEY_CONTENT
#KEY_INTERNET
#KEY_PC
#KEY_HDMI1
#KEY_OFF
#KEY_POWER
#KEY_STANDBY
#KEY_DUAL
#KEY_SUBT
#KEY_CHANUP
#KEY_CHAN_UP
#KEY_PROGUP
#KEY_PROG_UP
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
import time
import socket
import base64
import datetime
src = '192.168.0.86' # ip of remote
mac = '00-AB-11-11-11-11' # mac of remote, can be a fake one
remote = 'python remote' # remote name
dst = '192.168.0.5' # ip of tv
app = 'python' # iphone..iapp.samsung
tv = 'LE32C650' # iphone.LE32C650.iapp.samsung
def push(key):
new = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
new.connect((dst, 55000))
msg = chr(0x64) + chr(0x00) +\
chr(len(base64.b64encode(src))) + chr(0x00) + base64.b64encode(src) +\
chr(len(base64.b64encode(mac))) + chr(0x00) + base64.b64encode(mac) +\
chr(len(base64.b64encode(remote))) + chr(0x00) + base64.b64encode(remote)
pkt = chr(0x00) +\
chr(len(app)) + chr(0x00) + app +\
chr(len(msg)) + chr(0x00) + msg
new.send(pkt)
msg = chr(0x00) + chr(0x00) + chr(0x00) +\
chr(len(base64.b64encode(key))) + chr(0x00) + base64.b64encode(key)
pkt = chr(0x00) +\
chr(len(tv)) + chr(0x00) + tv +\
chr(len(msg)) + chr(0x00) + msg
new.send(pkt)
new.close()
time.sleep(0.1)
def dont_disturb():
print "Mute the TV! \n"
# switch to tv
push("KEY_TV")
# Mute!
push("KEY_MUTE")
# test
# push("KEY_ENTER")
time.sleep(5)
while True:
day = datetime.datetime.now().weekday()
now = datetime.datetime.now().time()
time_max = datetime.time(9,0,0)
time_min = datetime.time(4,0,0)
# De lunes a viernes
if day < 5:
# De 4 a 9 de la mañana
if now > time_min and now < time_max:
dont_disturb()
time.sleep(10)
time.sleep(5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment