Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missed arguments and aligned t o latest version of breadlink library #45

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions BlackBeanControl.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!python2
#!python

import broadlink, configparser
import sys, getopt
Expand Down Expand Up @@ -164,7 +164,7 @@
else:
RealTimeout = int(RealTimeout.strip())

RM3Device = broadlink.rm((RealIPAddress, RealPort), RealMACAddress)
RM3Device = broadlink.rm((RealIPAddress, RealPort), RealMACAddress, RealTimeout)
RM3Device.auth()

if ReKeyCommand:
Expand Down Expand Up @@ -194,7 +194,7 @@
sys.exit(2)

if RealCommand == 'n':
if (len(SentCommand) <> 8) or (not all(c in string.hexdigits for c in SentCommand)):
if (len(SentCommand) != 8) or (not all(c in string.hexdigits for c in SentCommand)):
print('Command must be 4-byte hex number.')
sys.exit(2)

Expand All @@ -208,7 +208,7 @@
sys.exit()

if RealCommand == 's':
if (len(SentCommand) <> 12) or (not all(c in string.hexdigits for c in SentCommand)):
if (len(SentCommand) != 12) or (not all(c in string.hexdigits for c in SentCommand)):
print('Command must be 6-byte hex number.')
sys.exit(2)

Expand All @@ -228,7 +228,7 @@
CommandFromSettings = ''

if CommandFromSettings.strip() != '':
DecodedCommand = CommandFromSettings.decode('hex')
DecodedCommand = bytes.fromhex(CommandFromSettings)
RM3Device.send_data(DecodedCommand)
else:
RM3Device.enter_learning()
Expand All @@ -239,7 +239,7 @@
print('Command not received')
sys.exit()

EncodedCommand = LearnedCommand.encode('hex')
EncodedCommand = LearnedCommand.hex()

BlackBeanControlIniFile = open(path.join(Settings.ApplicationDir, 'BlackBeanControl.ini'), 'w')
SettingsFile.set('Commands', SentCommand, EncodedCommand)
Expand Down
21 changes: 7 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,24 @@
# BlackBeanControl - Broadlink RM 3 Mini (aka Black Bean) control script

A simple Python 2 script, which uses python-broadlink package. It can be used for both, learning and sending IR commands
A simple Python 3 script, which uses python-broadlink package. It can be used for both, learning and sending IR commands

### Installation

Before cloning/downloading the script, you should install all dependencies:

Prerequisites for Linux users:

- Install pip package:
* wget https://bootstrap.pypa.io/get-pip.py
* Run get-pip.py
- Install python-dev package: apt-get install python-dev

Prerequisites for Windows users:

- Install Microsoft Visual C++ Compiler for Python 2.7
* Download https://www.microsoft.com/en-us/download/details.aspx?id=44266
* Run VCforPython27.msi
- Install Microsoft Visual C++ Compiler for Python 3.X (choose the version for your platform)
* https://aka.ms/vs/16/release/VC_redist.x64.exe (x64)
* https://aka.ms/vs/16/release/VC_redist.arm64.exe (ARM64)
* https://aka.ms/vs/16/release/VC_redist.x86.exe (x86)
* Run the downloaded installer (VC_redist.{x64 | arm64 | x86}.exe)

Dependencies for Windows/Linux:

- Install configparser package: python -m pip install configparser
- Install broadlink package: python -m pip install broadlink
- Install netaddr package: python -m pip install netaddr
- Install pycrypto package: python -m pip install pycrypto
- Download python-broadlink package - you can find it on the github by the package name (github user: mjg59)
- Unzip it to some local folder and install it: setup.py install

Now you can clone/download BlackBeanControl (in case you download it as archive, unzip it to some local folder).

Expand Down