而旧版又不能学习后自动新建设备。
所以修改了新版插件,既能够自动创建设备,又支持多段开关等。
安装方法:
Domoticz版本要求3.8xxx以上,broadlink版本0.5。
首先安装broadlink模块,直接运行下面命令安装:
代码: 全选
sudo pip3 install broadlink==0.5
文件放进去后先不要重启Domoticz,继续看使用方法。
使用方法:
①首先,如果你你需要多段开关,需要编辑plugin.py,按下方方法编辑,添加插件后,会自动创建一个多段开关。
在114行中插入下方代码,按中文提示修改成你需要的多端开关,也可以不修改,创建后再编辑。注意代码缩进,一个缩进是四个空格。
代码: 全选
if ( 10 not in Devices):
Options = { "LevelActions" :"||||" , #多段开关有几个动作就写几个|
"LevelNames" :"Off|Up|Down|Mode|On" , #多段开关各动作名称
"LevelOffHidden":"false",
"SelectorStyle" :"0"
}
Domoticz.Device(Name="多段开关名字", Unit=10, TypeName="Selector Switch", Switchtype=18, Image=12, Options=Options, Used=1).Create()
代码: 全选
sudo service domoticz.sh restart
如果日志里出现类似
或者Module Import failed: ' Name: pyaes'
的错误,运行下面几条命令(不一定哪条好用,Python版本要改成你自己的),然后重启domoticz试试。Module Import failed: ' Name: broadlink‘
代码: 全选
sudo cp -r /usr/local/lib/python3.4/dist-packages/Crypto/ /usr/lib/python3.4/
代码: 全选
sudo cp -r /usr/local/lib/python3.4/dist-packages/broadlink /usr/lib/python3.4/
代码: 全选
sudo cp -r /usr/local/lib/python3.4/dist-packages/broadlink-0.5-py3.4.egg/broadlink /usr/lib/python3.4/
代码: 全选
sudo cp -r /usr/local/lib/python3.4/dist-packages/pyaes /usr/lib/python3.4/
⑤学习遥控按键,点击Learn按钮,这时RM设备的指示灯应该常亮,按下遥控按键,如果学习到按键指示灯会马上灭掉,Domoticz日志中也会显示出相应信息,其中就有按键的编码信息,如果学习的是多段开关中的按键,直接把编码信息保存下来。如果学习的是独立开关的编码,按下Save按钮,插件会自动创建一个开关,还会在domoticz/plugins/BroadlinkRM2/目录中自动创建一个类似BroadlinkRM2-5-2.ini的配置文件,该文件的文件名中5是BroadlinkRM2插件的硬件IDX(硬件列表中查看),2是刚自动创建的开关的unit(设备列表中查看),所有配置文件第一个数字都是一样的,都是BroadlinkRM2硬件的IDX。
⑥多段开关及普通开关配置文件修改方法:多段开关是在插件添加时自动创建的,配置文件需要自己建,文件名规则“BroadlinkRM2-5-10.ini”,其中的5是BroadlinkRM2硬件的IDX,10是多段开关的unit。
多段开关BroadlinkRM2-5-10.ini文件示例:
代码: 全选
[DEFAULT]
hardwareid = 5
pluginkey = BroadlinkRM2
pluginname = RMPro
customname =
unit = 10
pluginfolder = /home/pi/domoticz/plugins/BroadlinkRM2/
[Device]
mac = B4430DC739EC
host = 192.168.123.230
[LearnedCode]
Off = 26007a002710290f0d2a2810290f0d2b0d2b0d2b0d2b0d2b0d2b27ec290e290f0d2a290f290f0d2b0d2b0d2b0d2b0d2b0d2b28ec2810290e0e2a2710290f0e2a0d2b0d2b0d2b0d2b0d2b28ec280f290f0d2a290f290f0d2b0d2b0d2b0d2b0d2b0d2b28eb290f290e0e2a2810290e0e2a0d2b0d2b0d2b0d2b0d2b29000d050000000000000000000000000000
10 = 26007a00280f290f0d2a2810290f290f0d2b0d2b0d2b0d2b280f29eb280f290f0d2a290f290f290f0d2b0d2b0d2b0d2a290f29ec280f290f0d2a290f290f290e0e2a0d2b0d2b0d2b281029eb280f2a0e0d2b280f290f290f0d2b0d2b0d2b0d2b280f2aea290f290e0e2a280f290f290f0d2b0d2b0d2b0d2b281029000d050000000000000000000000000000
20 = 26008200280f290f0d2a290f290f290f0d2b0d2b0d2b280f290f0e0001062810290e0d2b280f290f290f0d2b0d2b0d2b280f2a0e0e000107290e2a0e0d2b280f290f290f0d2b0d2b0d2b280f2a0e0e000106290f290f0d2a2810290f290e0e2a0d2b0d2b290f290f0d000107290f290e0e2a280f2a0e290f0e2a0d2b0d2b2810290f0d000d05000000000000
30 = 26009c00280f290f0d2a290f290f0d2b0d2b0d2b0d2a290f0e2a0d000106290f290e0e2a2810290f0d2a0e2a0e2a0e2a28100e2a0c000108290f290e0e2a2810290e0e2a0e2a0e2a0d2b28100e2a0d0001062810290e0e2a2810290e0e2a0d2b0d2b0d2b290f0e2a0d000106290f290e0e2a280f290f0e2a0c2c0d2b0d2b290f0d2b0d000107280f290f0d2a290f290f0d2b0d2b0c2c0d2b27110d2a0e000d05000000000000000000000000
40 = 26007a002710290f0d2a2810290f0d2b0d2b0d2b0d2b0d2b0d2b27ec290e290f0d2a290f290f0d2b0d2b0d2b0d2b0d2b0d2b28ec2810290e0e2a2710290f0e2a0d2b0d2b0d2b0d2b0d2b28ec280f290f0d2a290f290f0d2b0d2b0d2b0d2b0d2b0d2b28eb290f290e0e2a2810290e0e2a0d2b0d2b0d2b0d2b0d2b29000d050000000000000000000000000000
普通开关BroadlinkRM2-5-4.ini示例:
代码: 全选
[DEFAULT]
pluginname = RMPro
customname = 客厅灯
pluginkey = BroadlinkRM2
hardwareid = 5
pluginfolder = /home/pi/domoticz/plugins/BroadlinkRM2/
unit = 4
[Device]
mac = B4430DC739EC
host = 192.168.123.230
[LearnedCode]
On = 7800d000081a081a091a1909091a1909081a1a08091a081a081b081a081a0919091a19091a091909081a091a081a081b081a081a0800010a091a081a081a1a09081a1a08091a1909091a081a081a091a081a081a081a1a0919091a09081a081b081a081a081a091a0800010a0919091a081a1a09081a1a08091a1909081a0919091a081b071a091a081a1a0919091a09081a081a081b081a081a081b0800010a081b081a081a1a09081a190909191a09081a091a081a09190919091a09191a0919091a09081a081a091a081a081a091a080005dc0000000000000000
Off = 7800d000081a081a091a1909091a1909081a1a08091a081a081b081a081a0919091a19091a091909081a091a081a081b081a081a0800010a091a081a081a1a09081a1a08091a1909091a081a081a091a081a081a081a1a0919091a09081a081b081a081a081a091a0800010a0919091a081a1a09081a1a08091a1909081a0919091a081b071a091a081a1a0919091a09081a081a081b081a081a081b0800010a081b081a081a1a09081a190909191a09081a091a081a09190919091a09191a0919091a09081a081a091a081a081a091a080005dc0000000000000000
先吃午饭,哪里不清楚的直接回帖提问。