本脚本用于不方便在路由器中查看设备时,通过手动扫描获取博联设备ip及mac地址。
首先请查看Domoticz&BroadLink(博联)连接及控制教程:(一)安装python-broadlink
新建scanBroadlink.py
代码: 全选
sudo nano scanBroadlink.py
代码: 全选
#!/usr/bin/python
# -*- coding: UTF-8 -*-
#Script to locate Broadlink devices on local network by Graeme Brown Dec 23 2016
#请先使用博联APP配置添加设备。
import broadlink
import time
print "************************************************"
print "Using python library created by Matthew Garrett"
print "https://github.com/mjg59/python-broadlink"
print "************************************************"
print "扫描局域网中的Broadlink设备...."
mydevices = broadlink.discover(timeout=5)
print "找到" + str(len(mydevices )) + "个broadlink设备"
time.sleep(1)
print "..............."
for index, item in enumerate(mydevices):
mydevices[index].auth()
ipadd = mydevices[index].host
ipadd = str(ipadd)
print "设备 " + str(index + 1) +" IP地址 = " + 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 "设备 " + str(index + 1) +" MAC地址 = " + mymacadd
print "..............."
代码: 全选
sudo python ./scanBroadlink.py