From 94d892d7efcc6408a67934c68f2b66e7d8432e2d Mon Sep 17 00:00:00 2001 From: obaby Date: Mon, 4 Dec 2017 15:28:57 +0800 Subject: [PATCH] Update econtrol-db-dump.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复部分button没有数据导致的异常 --- econtrol-db-dump.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/econtrol-db-dump.py b/econtrol-db-dump.py index 61bfee9..c98e5f9 100644 --- a/econtrol-db-dump.py +++ b/econtrol-db-dump.py @@ -1,4 +1,5 @@ import sqlite3 as lite +from binascii import hexlify # This script will "parse" the broadlink e-Control Android application database and dump the IR / RF codes for selected accessories into a text file which can be later used with broadlink-python to send the codes to the RM PRO hub # You need to get the "rmt.db" file from your (rooted) android device or emulator (ARM), the file is located in "/data/data/com.broadlink.rmt/databases/rmt.db" and put it in the same folder as this script. @@ -48,7 +49,14 @@ for i in range(0, len(buttonIDS)): cur.execute("SELECT irCode FROM codeTable where buttonId=" + str(buttonIDS[i])) - code = cur.fetchone()[0] - result = "Button Name: " + buttonNames[i] + "| Button ID: " + str(buttonIDS[i]) + " | Code: " + str(code).encode('hex') + "\n" + #print str((cur.fetchall()[0])[0]).encode('hex') + #fix for code None error by obaby + code = cur.fetchone() + if code: + cod = code[0] + else: + continue + hexlify(cod) + result = "Button Name: " + buttonNames[i] + "| Button ID: " + str(buttonIDS[i]) + " | Code: " + str(cod).encode('hex') + "\n" codesFile.writelines(result.encode('utf-8')) codesFile.close()