Domoticz&BroadLink(博联)连接及控制教程:(一)安装python-broadlink

博联Broadlink RM Pro/Mini、RM Home、MP1、MP2、SP mini等
版面规则
博联Broadlink RM Pro/Mini、RM Home、MP1、MP2、SP mini等
回复
头像
DT27
帖子: 327
注册时间: 周四 3月 30, 2017 08:54
Gender:

Domoticz&BroadLink(博联)连接及控制教程:(一)安装python-broadlink

帖子 DT27 » 周二 5月 23, 2017 14:15

本帖以树莓派为例,默认路径为~(即用户主目录/home/pi/)。
本帖介绍手动编写脚本控制博联设备,仅供大家了解脚本及博联的控制方式。
实际使用建议用插件来控制博联设备,更加方便。
插件使用过程中遇到任何问题都可以在博联专区发帖讨论。

【Domoticz】基于v3.7974 Beta 博联专版
[Domoticz插件]Broadlink MP1/MP2 兼容 鸿雁8340J
[Domoticz插件]Broadlink SP mini
[插件]RM2 RMPro 插件 BroadlinkRM2 v3(增强版)



Domoticz要连接控制博联设备,需要一个名叫python-broadlink的Python项目。
python-broadlink项目地址:https://github.com/mjg59/python-broadlink
python-broadlink安装步骤:
①首先安装Python

代码: 全选

sudo apt-get install python2.7 -y
②然后安装Python包管理工具

代码: 全选

sudo apt-get install python-pip -y
sudo apt-get install python-dev libgmp-dev
③从GitHub网站直接下载项目代码需要用git,所以安装git

代码: 全选

sudo apt-get install git -y
④下载python-broadlink

代码: 全选

git clone https://github.com/mjg59/python-broadlink
这时,运行ls命令会看到当前目录中多了个python-broadlink文件夹。

⑤安装python-broadlink
进入python-broadlink文件夹

代码: 全选

cd python-broadlink
运行以下命令进行安装

代码: 全选

sudo python setup.py install
安装完成。
以上步骤均实践测试通过,如果你遇到任何问题,欢迎跟帖提问。

接下来通过python-broadlink连接并控制博联的各种设备。
博联RM系列万能遥控设备连接及控制方法,如RM mini、RM Home、RM Pro、RM2 Pro等
博联RM Pro获取内置温度传感器数据
博联MP系列智能插排设备连接及控制方法,如MP1、MP2等
博联SP系列智能插座设备连接及控制方法,如SP mini、SP mini3等
上次由 DT27 在 周三 5月 24, 2017 18:02,总共编辑 4 次。

sxren1
帖子: 51
注册时间: 周三 5月 24, 2017 10:04

Re: Domoticz&BroadLink(博联)连接及控制教程:(一)安装python-broadlink

帖子 sxren1 » 周三 5月 24, 2017 10:12

Mp系列插排链接无效了,能否重新做个教程,非常感谢

头像
DT27
帖子: 327
注册时间: 周四 3月 30, 2017 08:54
Gender:

Re: Domoticz&BroadLink(博联)连接及控制教程:(一)安装python-broadlink

帖子 DT27 » 周三 5月 24, 2017 10:41

sxren1 写了:
周三 5月 24, 2017 10:12
Mp系列插排链接无效了,能否重新做个教程,非常感谢
等等哈,昨天才开始写,刚把RM系列写完,马上开始写MP系列。

头像
DT27
帖子: 327
注册时间: 周四 3月 30, 2017 08:54
Gender:

Re: Domoticz&BroadLink(博联)连接及控制教程:(一)安装python-broadlink

帖子 DT27 » 周三 5月 24, 2017 11:00

sxren1 写了:
周三 5月 24, 2017 10:12
Mp系列插排链接无效了,能否重新做个教程,非常感谢
MP1教程已完成:博联MP系列智能插排设备连接及控制方法,如MP1、MP2等

sxren1
帖子: 51
注册时间: 周三 5月 24, 2017 10:04

Re: Domoticz&BroadLink(博联)连接及控制教程:(一)安装python-broadlink

帖子 sxren1 » 周五 5月 26, 2017 22:12

pi@raspberrypi:/ $ sudo apt-get install python2.7 -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
python2.7 is already the newest version.
python2.7 set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 81 not upgraded.
这个是怎么回事,怎么解决啊

头像
DT27
帖子: 327
注册时间: 周四 3月 30, 2017 08:54
Gender:

Re: Domoticz&BroadLink(博联)连接及控制教程:(一)安装python-broadlink

帖子 DT27 » 周六 5月 27, 2017 08:19

sxren1 写了:
周五 5月 26, 2017 22:12
pi@raspberrypi:/ $ sudo apt-get install python2.7 -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
python2.7 is already the newest version.
python2.7 set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 81 not upgraded.
这个是怎么回事,怎么解决啊
直接贴到百度翻译一下啊,提示你python2.7已经安装了,直接继续下一步就行了。

zhijilee
帖子: 16
注册时间: 周五 6月 09, 2017 14:32

Re: Domoticz&BroadLink(博联)连接及控制教程:(一)安装python-broadlink

帖子 zhijilee » 周六 6月 10, 2017 15:17

最后一步功亏一篑阿 :shock: :shock:
pi@raspberrypi:~/python-broadlink $ python setup.py install
running install
error: can't create or remove files in install directory

The following error occurred while trying to add or remove files in the
installation directory:

[Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/test-easy-install-2242.write-test'

The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:

/usr/local/lib/python2.7/dist-packages/

Perhaps your account does not have write access to this directory? If the
installation directory is a system-owned directory, you may need to sign in
as the administrator or "root" account. If you do not have administrative
access to this machine, you may wish to choose a different installation
directory, preferably one that is listed in your PYTHONPATH environment
variable.

For information on other options, you may wish to consult the
documentation at:

https://pythonhosted.org/setuptools/easy_install.html

Please make the appropriate changes for your system and try again.

zhijilee
帖子: 16
注册时间: 周五 6月 09, 2017 14:32

Re: Domoticz&BroadLink(博联)连接及控制教程:(一)安装python-broadlink

帖子 zhijilee » 周六 6月 10, 2017 15:49

是否应该加个sudo...

头像
Admin
网站管理员
帖子: 116
注册时间: 周六 2月 25, 2017 12:47
Gender:

Re: Domoticz&BroadLink(博联)连接及控制教程:(一)安装python-broadlink

帖子 Admin » 周六 6月 10, 2017 16:16

zhijilee 写了:
周六 6月 10, 2017 15:17
最后一步功亏一篑阿 :shock: :shock:
pi@raspberrypi:~/python-broadlink $ python setup.py install
running install
error: can't create or remove files in install directory

The following error occurred while trying to add or remove files in the
installation directory:

[Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/test-easy-install-2242.write-test'

The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:

/usr/local/lib/python2.7/dist-packages/

Perhaps your account does not have write access to this directory? If the
installation directory is a system-owned directory, you may need to sign in
as the administrator or "root" account. If you do not have administrative
access to this machine, you may wish to choose a different installation
directory, preferably one that is listed in your PYTHONPATH environment
variable.

For information on other options, you may wish to consult the
documentation at:

https://pythonhosted.org/setuptools/easy_install.html

Please make the appropriate changes for your system and try again.
楼上说的对,得加sudo,帖子已经修正了

suningwong
帖子: 1
注册时间: 周六 6月 10, 2017 18:57

Re: Domoticz&BroadLink(博联)连接及控制教程:(一)安装python-broadlink

帖子 suningwong » 周六 6月 10, 2017 19:40

我在最后一步遇到错误
ImportError: No module named setuptools
是因为setuptools没有安装,可以采用命令安装
apt-get install -y python-setuptools
然后就可以了!

macongran
帖子: 9
注册时间: 周六 8月 12, 2017 22:27

Re: Domoticz&BroadLink(博联)连接及控制教程:(一)安装python-broadlink

帖子 macongran » 周二 8月 15, 2017 01:58

Installed /usr/local/lib/python2.7/dist-packages/broadlink-0.5-py2.7.egg
Processing dependencies for broadlink==0.5
Searching for pycrypto==2.6.1
Reading https://pypi.python.org/simple/pycrypto/
Best match: pycrypto 2.6.1
Downloading https://pypi.python.org/packages/60/db/ ... 75d4eaf6f8 0f163/pycrypto-2.6.1.tar.gz#md5=55a61a054aa66812daf5161a0d5d7eda
error: Download error for https://pypi.python.org/packages/60/db/ ... 89219e0362 141e75d4eaf6f80f163/pycrypto-2.6.1.tar.gz#md5=55a61a054aa66812daf5161a0d5d7eda: [Errno 101] Network is unreachable

安装到这出错了,咋办,哪里出错了哎。。

冰封紫轩
帖子: 1
注册时间: 周五 3月 23, 2018 21:56

Re: Domoticz&BroadLink(博联)连接及控制教程:(一)安装python-broadlink

帖子 冰封紫轩 » 周一 4月 02, 2018 02:07

pi@raspberrypi:~/python-broadlink $ sudo python setup.py install
running install
error: can't create or remove files in install directory

The following error occurred while trying to add or remove files in the
installation directory:

[Errno 2] No such file or directory: '/usr/local/lib/python2.7/dist-packages/test-easy-install-934.write-test'

The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:

/usr/local/lib/python2.7/dist-packages/

This directory does not currently exist. Please create it and try again, or
choose a different installation directory (using the -d or --install-dir
option).
出问题了。。。。

blindlight
帖子: 98
注册时间: 周四 3月 30, 2017 00:03

Re: Domoticz&BroadLink(博联)连接及控制教程:(一)安装python-broadlink

帖子 blindlight » 周一 4月 02, 2018 09:06

冰封紫轩 写了:
周一 4月 02, 2018 02:07
pi@raspberrypi:~/python-broadlink $ sudo python setup.py install
running install
error: can't create or remove files in install directory

The following error occurred while trying to add or remove files in the
installation directory:

[Errno 2] No such file or directory: '/usr/local/lib/python2.7/dist-packages/test-easy-install-934.write-test'

The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:

/usr/local/lib/python2.7/dist-packages/

This directory does not currently exist. Please create it and try again, or
choose a different installation directory (using the -d or --install-dir
option).
出问题了。。。。

直接

代码: 全选

pip3 install broadlink

aka19801030
帖子: 7
注册时间: 周五 8月 02, 2019 14:22

Re: Domoticz&BroadLink(博联)连接及控制教程:(一)安装python-broadlink

帖子 aka19801030 » 周一 8月 05, 2019 13:25

我的Domoticz和BroadLink RM pro+不在同一个网段,IP地址那里是否要填RM pro的外网地址?路由器要映射哪个端口?
:geek: :geek: :geek: :geek: :D

zhouyao123
帖子: 1
注册时间: 周一 11月 15, 2021 17:45
Gender:

Re: Domoticz&BroadLink(博联)连接及控制教程:(一)安装python-broadlink

帖子 zhouyao123 » 周一 11月 15, 2021 17:50

博主你好,https://github.com/mjg59/python-broadlink
根据地址下载的源码是基于python3的版本,我使用了python2.7.14,下载的broadlink 0.6的版本,笔记本和wifi插座都是在一个路由下,但是socket发送消息始终收不到返回,大概是什么原因呢

回复