fixed learnfile switch and python3 compatibility (#247)
This commit is contained in:
parent
ef66997953
commit
45e26fda23
1 changed files with 5 additions and 2 deletions
|
@ -4,6 +4,8 @@ import broadlink
|
|||
import sys
|
||||
import argparse
|
||||
import time
|
||||
import base64
|
||||
import codecs
|
||||
|
||||
TICK = 32.84
|
||||
IR_TOKEN = 0x26
|
||||
|
@ -120,7 +122,7 @@ if args.send:
|
|||
data = durations_to_broadlink(parse_durations(' '.join(args.data))) \
|
||||
if args.durations else bytearray.fromhex(''.join(args.data))
|
||||
dev.send_data(data)
|
||||
if args.learn:
|
||||
if args.learn or args.learnfile:
|
||||
dev.enter_learning()
|
||||
data = None
|
||||
print("Learning...")
|
||||
|
@ -135,7 +137,8 @@ if args.learn:
|
|||
else ''.join(format(x, '02x') for x in bytearray(data))
|
||||
if args.learn:
|
||||
print(learned)
|
||||
print("Base64: " + base64.b64encode(learned.decode("hex")))
|
||||
decode_hex = codecs.getdecoder("hex_codec")
|
||||
print("Base64: " + str(base64.b64encode(decode_hex(learned)[0])))
|
||||
if args.learnfile:
|
||||
print("Saving to {}".format(args.learnfile))
|
||||
with open(args.learnfile, "w") as text_file:
|
||||
|
|
Loading…
Reference in a new issue