霍尼韦尔(Ademco)正在开发流行的VISTA安全系统,其范围从简单的VISTA-10到功能丰富的VISTA-250。 VISTA-128 / 250多功能安全系统包含一个RS232端口,您可以将其集成到任何其他系统中。我得到的任务是:“要将VISTA-10 L安全系统集成到Fibaro家庭自动化系统中,您需要通过一个移动应用程序同时控制照明和车库门并武装房屋。”粗略研究VISTA-10 L,结果发现根本没有UART。幸运的是,公司www.alarmdecoder.com在美国互联网的广阔范围内被发现,它是模拟控制面板操作的开发板。该板具有3个连接选项:USB,RS-232,Raspberry Pi的UART屏蔽。我为Raspberry Pi选择了AD2Pi防护罩。
AD2Pi板连接到控制面板的端子,对于安全系统,它是另一个控制和显示面板。
远程控制和显示(控制面板)接线图很简单:AD2Pi | VISTA控制面板 |
-- | 4-键盘接地(-) |
+ | 5-键盘密码(+) |
DI | 6-数据输入键盘 |
做 | 7-数据到键盘 |

将AD2Pi连接到VISTA控制面板后,我们继续使用该软件。AlarmDecoder可让您完全控制和监视安全系统。1)安装python alarmdecoder库
alarmdecoder允许您以解析的形式接收所有系统消息,发送控制和配置命令。pip install alarmdecoder
或从gitgit clone https://github.com/nutechsoftware/alarmdecoder.git
cd alarmdecoder
python setup.py install
2)安装ser2sock-串行到套接字重定向器
ser2sock允许您远程连接到串行端口,这不仅对于使用Raspberry Pi控制安全系统是必要的,而且还可以直接从任何其他计算机/设备控制安全系统。git clone https://github.com/nutechsoftware/ser2sock.git
此处的安装详细信息:https : //github.com/nutechsoftware/ser2sock3)AD2Pi开发板设置
首先,您需要配置AD2Pi板,以便将所有感兴趣的事件传达给我们。通过minicom连接到AD2Pi串行端口,然后输入“!”以进入配置模式。请注意,虚拟控制面板的地址必须为31,LRR必须为Y,并且地址ffffffff处的掩码即 接收所有人的消息。sudo minicom -d /dev/ttyAMA0
在控制面板上,您需要激活通过LRR / GSM发送消息的功能,然后我们才能知道哪个用户已被撤防并设防。
4)检查系统性能
运行ser2sock并监听端口10000:sudo /etc/init.d/ser2sock start
nc localhost 10000
必须查看来自系统的消息:
5)处理来自安全系统的消息

Python脚本将消息从AlarmDecoder发送到Home Center 2自动化控制器
import json
import base64
import time
from time import gmtime, strftime
import requests
from requests.auth import HTTPBasicAuth
from alarmdecoder import AlarmDecoder
from alarmdecoder.devices import SocketDevice
HOSTNAME = 'localhost'
PORT = 10000
username = "admin"
password = "admin"
def main():
"""
Example application that prints messages from the panel to the terminal.
"""
try:
device = AlarmDecoder(SocketDevice(interface=(HOSTNAME, PORT)))
device.on_message += handle_message
device.on_lrr_message += handle_lrr_message
with device.open():
while True:
time.sleep(1)
except Exception, ex:
print 'Exception:', ex
def handle_message(sender, message):
"""
Handles message events from the AlarmDecoder.
"""
print message.text
jsonData = {"value":message.text}
requests.put('http://10.0.1.43/api/globalVariables/AlarmStatus', json = jsonData, auth=HTTPBasicAuth(username, password))
def handle_lrr_message(sender, message):
"""
Handles message events from the AlarmDecoder.
"""
lrr_message = message.event_data + " " + message.event_type
print lrr_message
jsonData = {"value":lrr_message}
requests.put('http://10.0.1.43/api/globalVariables/AlarmUsers', json = jsonData, auth=HTTPBasicAuth(username, password))
if __name__ == '__main__':
main()
为了处理该消息,我编写了一个小的python脚本,将其置于自动加载状态。该脚本连接到ser2sock服务,接收来自该服务的消息,然后将其发送到Home Center 2自动化控制器,在该控制器上,我处理这些消息,将其显示在虚拟设备中,并发送有关安全系统状态的推送通知。6)用于管理Home Center 2警报系统的小部件
在Home Center 2中,我创建了一个虚拟设备,您可以使用该设备以不同的方式进行布防,撤防,并显示系统状态以及有关设置或撤防人员的信息。要布防或撤防,您只需要发送带有布防/撤防代码的TCP请求即可。
Lua脚本,用于处理来自alarmdecoder的消息
securityStatus = fibaro:getGlobalValue('AlarmStatus')
lastSecurityStatus = fibaro:getGlobalValue('lastSecurityStatus')
if (lastSecurityStatus ~= securityStatus) then
fibaro:call(108, "setProperty", "ui.Label1.value", os.date("%x %X ") .. securityStatus)
fibaro:setGlobal('lastSecurityStatus',securityStatus)
fibaro:debug(fibaro:getValue(108, 'ui.Label1.value'))
end
alarmUsers = fibaro:getGlobalValue('AlarmUsers')
lastAlarmUsers = fibaro:getGlobalValue('lastAlarmUsers')
if (lastAlarmUsers ~= alarmUsers) then
fibaro:setGlobal('lastAlarmUsers',alarmUsers)
userID = string.sub(alarmUsers, 3, 3)
event = string.sub(alarmUsers, 5)
if userID == "4" then
userID = "Raspberry"
elseif userID == "3" then
userID = ""
elseif userID == "2" then
userID = ""
end
if event == "ARM_AWAY" then
event = " "
elseif event == "ARM_STAY" then
event = " "
elseif event == "OPEN" then
event = " "
end
fibaro:call(108, "setProperty", "ui.Label2.value", event .. " " .. userID)
fibaro:debug(fibaro:getValue(108, 'ui.Label2.value'))
fibaro:call(100, "sendPush", fibaro:getValue(108, 'ui.Label2.value'))
fibaro:call(25, "sendPush", fibaro:getValue(108, 'ui.Label2.value'))
end
还需要在Home Center 2上创建几个全局变量,这些全局变量存储系统和用户的当前状态。
控制面板上显示的所有信息:撤防/布防,传感器触发,传感器电量低,切换到备用电源等,都可以进行处理并将其发送到自动化系统以采取进一步的措施。所有Home Center 2设备都将广播到homebridge,您可以使用Siri的语音助手进行布防和撤防。Alarmdecoder的主板可与任何自动化系统一起使用,详细的文档和便捷的API可让您方便快捷地将安全系统集成到任何智能家居中!