Re: Anleitung: Broadlink ohne RM Bridge nutzen (Linux)
Verfasst: Do 13. Apr 2017, 10:16
okay... hat geklappt....
am Editor lags.
Vielen Dank
am Editor lags.
Vielen Dank
Das inoffizielle deutsche Alexa und Echo Forum.
https://www.alefo.de/forum/
Code: Alles auswählen
#!/usr/bin/python3.4
#Script to locate Broadlink devices on local network by Graeme Brown Dec 23 2016
#These must be set up using the Broadlink app first!
import broadlink
import time
print ("************************************************")
print ("Using python library created by Matthew Garrett")
print ("https://github.com/mjg59/python-broadlink")
print ("************************************************")
print ("Scanning network for Broadlink devices....")
mydevices = broadlink.discover(timeout=5)
print ("Found " + str(len(mydevices )) + " broadlink devices")
time.sleep(1)
print ("...............")
for index, item in enumerate(mydevices):
mydevices[index].auth()
ipadd = mydevices[index].host
ipadd = str(ipadd)
print ("Device " + str(index + 1) +" Host address = " + ipadd[1:19])
macadd = ''.join(format(x, '02x') for x in mydevices[index].mac[::-1])
macadd = str(macadd)
mymacadd = macadd[:2] + " " + macadd[2:4] + " " + macadd[4:6] + " " + macadd[6:8] + " " + macadd[8:10] + " " + macadd[10:12]
print ("Device " + str(index + 1) +" MAC address = " + mymacadd)
print ("...............")
Code: Alles auswählen
#!/usr/bin/python3.4
import broadlink
import time
import sys
import binascii
device = broadlink.rm(host=("<your RM3 IP address>",80), mac=bytearray.fromhex("<your RM3 mac>"))
print ("Connecting to Broadlink device....")
device.auth()
time.sleep(1)
print ("Connected....")
codeName = input("Please Enter Code Name e.g. tvOff ")
time.sleep(1)
print ("When Broadlink white led is lit press the button on your remote within 5 seconds")
device.host
device.enter_learning()
time.sleep(5)
ir_packet = device.check_data()
#convert code to hex
myhex = str(binascii.b2a_hex(ir_packet));
if ir_packet == None:
print ("No button press read - quitting")
sys.exit()
else:
# record learned hex code to file
f = open(codeName +".txt",'w')
f.write(myhex)
f.close()
Code: Alles auswählen
#!/usr/bin/python3.4
import broadlink
import time
import sys
import binascii
try:
fileName = sys.argv[1]
except IndexError:
fileName = 'null'
if fileName == 'null':
print ("Error - no file name parameter suffixed")
sys.exit()
else:
device = broadlink.rm(host=("<your RM3 IP address>",80), mac=bytearray.fromhex("<your RM3 mac>"))
print ("Connecting to Broadlink device....")
device.auth()
time.sleep(1)
print ("Connected....")
time.sleep(1)
device.host
file = open(fileName, 'r')
myhex = file.read()
device.send_data(bytearray.fromhex(myhex));
print ("Code Sent....")
Hast du das Modul broadlink installiert? (mit python setup.py install)eyeq2020 hat geschrieben: ↑Mi 26. Apr 2017, 18:15 Hallo,
ich habe das script nun in einen anderen Ordner installiert. Da komme ich einen Schritt weiter. Ich kann das script ausführen aber es kommt dieser Fehler
Traceback (most recent call last):
File "./search-bl.sh", line 6, in <module>
import broadlink
Ich habe das im start script stehen
#!/usr/bin/python
#Script to locate Broadlink devices on local network by Graeme Brown Dec 23 2016
#These must be set up using the Broadlink app first!
import broadlink
import time
print "************************************************"
print "Using python library created by Matthew Garrett"
print "https://github.com/mjg59/python-broadlink"
print "************************************************"
print "Scanning network for Broadlink devices...."
mydevices = broadlink.discover(timeout=5)
print "Found " + str(len(mydevices )) + " broadlink devices"
time.sleep(1)
print "..............."
for index, item in enumerate(mydevices):
mydevices[index].auth()
ipadd = mydevices[index].host
ipadd = str(ipadd)
print "Device " + str(index + 1) +" Host address = " + ipadd[1:19]
macadd = ''.join(format(x, '02x') for x in mydevices[index].mac[::-1])
macadd = str(macadd)
Grüße
eyeq
Code: Alles auswählen
This is huge! Thanks to aptalca for creating an arm based Docker container for the Raspberry Pi (and Odroid C2!) that allows ha-bridge to run inside the LibreELEC Docker add-on!
First thing you need to do is ensure your Raspberry Pi LibreELEC has a static IP address so you always know how to get to the ha-bridge web interface.
Kodi > Programs > LibreELEC configuration > Connections then select your active connection (LAN or Wi-Fi) and use the context menu to select ‘Edit’.
Scroll to IPV4 and change your IP address settings so they are static by using the Manual settings. Of course, you could always create a DHCP lease in your router if you are savvy with that and that is the better way to go.
If you have more than one media player, I recommended settings them with static IP’s next to each other like xxx.xxx.xxx.201, xxx.xxx.xxx.202 etc. In that way, (if you use Android) you can use the excellent SSH Button app by David Grootendorst to create buttons to easily reboot Kodi from your phone or tablet if Kodi ever hangs. Sadly, I have not found a IOS app that’s as nice.
Second thing you need to do (IMPORTANT) is change the web server port that Kodi is using as the default is port 80 which ha-bridge needs to use in order to be compatible with Google Home.
Kodi > Settings > Services > Control > Web server and change the port to 8080 (or whatever you like) as long as it’s not 80.
Now you can go ahead and get the Docker add-on for LibreELEC made by the devs at LE.
Kodi > Add-ons > Install from repository > LibreELEC Add-ons > Services > Docker
Once installed, use the context menu to edit the settings in Docker if you want Kodi to pop-up notifications when your Docker container starts, stops or otherwise farts. Docker > Settings > Notifications. Either select ‘All’ or ‘Custom’.
Code: Alles auswählen
docker build -t habridge .
Code: Alles auswählen
FROM armv7/armhf-ubuntu
VOLUME ["/config"]
RUN export DEBCONF_NONINTERACTIVE_SEEN=true DEBIAN_FRONTEND=noninteractive && \
apt-get update && \
apt-get install -y \
python-setuptools && \
apt-get install -y \
software-properties-common python-software-properties build-essential python-dev && \
apt-get install -y curl && \
echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" | tee /etc/apt/sources.list.d/webupd8team-java.list && \
echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list && \
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886 && \
apt-get update && \
echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections && \
apt-get install -y \
wget oracle-java8-installer oracle-java8-set-default && \
usermod -u 99 nobody && \
usermod -g 100 nobody && \
mkdir -p /etc/my_init.d && \
mkdir -p /home/broadlink
COPY firstrun.sh /etc/my_init.d/firstrun.sh
COPY python-broadlink /usr/local/broadlink/python-broadlink
#COPY search-bl.sh /config
#COPY learn-bl.sh /config
#COPY send-bl.sh /config
RUN cd /usr/local/broadlink/python-broadlink && python /usr/local/broadlink/python-broadlink/setup.py install
RUN chmod +x /etc/my_init.d/firstrun.sh
Code: Alles auswählen
#!/bin/bash
#Get docker env timezone and set system timezone
echo "setting the correct local time"
echo $TZ > /etc/timezone
export DEBCONF_NONINTERACTIVE_SEEN=true DEBIAN_FRONTEND=noninteractive
dpkg-reconfigure tzdata
cd /config
if [ ! -z $VERSION ]; then
echo "Manual version override:" $VERSION
else
#Check the latest version on github
VERSION="$(curl -sX GET https://api.github.com/repos/bwssytems/ha-bridge/releases/latest | grep 'tag_name' | cut -d\" -f4)"
VERSION=${VERSION:1}
echo "Latest version on bwssystems github repo is" $VERSION
fi
if [ ! -f /config/ha-bridge-"$VERSION".jar ]; then
echo "Installing version '$VERSION'"
wget https://github.com/bwssytems/ha-bridge/releases/download/v"$VERSION"/ha-bridge-"$VERSION".jar
else
echo "Using existing version '$VERSION'"
fi
echo "Setting correct permissions"
chown -R nobody:users /config
ADDPARAM="-Dupnp.config.address=$SERVERIP -Dserver.port=$SERVERPORT"
echo -e "Parameters used:\nServer IP : $SERVERIP\nServer Port : $SERVERPORT"
echo "Starting Home Automation Bridge"
java -jar $ADDPARAM ha-bridge-"$VERSION".jar 2>&1 | tee /config/ha-bridge.log
Das erstellte Dockerimage taggen:docker cp search-bl.sh habridge:/config/search-bl.sh
docker cp learn-bl.sh habridge:/config/learn-bl.sh
docker cp send-bl.sh habridge:/config/send-bl.sh
Code: Alles auswählen
docker tag habridge name/repository
Code: Alles auswählen
docker run -d -t -i --name="habridge" --restart=always --net="host" -e SERVERIP="IP-Adresse des Pi's" -e SERVERPORT="80" -v /storage/downloads/habridge:/config:rw -v /etc/localtime:/etc/localtime:ro name/repository /bin/bash /etc/my_init.d/firstrun.sh
Code: Alles auswählen
docker exec -i -t habridge python /config/learn-bl.sh