08.07.2020, 10:50
(This post was last modified: 08.07.2020, 10:59 by fleeceable.)
Hello!
Here is my updated communication script. Maybe this helps someone...
It allows to see zone status, get info about areas (if there is trouble in some area and if area is open or not), arm/disarm etc...
Also it polls every minute area status.
Residential script (EVO192 communication, sleep interval 0 seconds):
User library:
Script name: guardAreaStatus
Script name: guardZoneStatus
Resident script for communication check (EVO192 Communication check, sleep interval 10s):
Here is UI:
Here is my updated communication script. Maybe this helps someone...
It allows to see zone status, get info about areas (if there is trouble in some area and if area is open or not), arm/disarm etc...
Also it polls every minute area status.
Residential script (EVO192 communication, sleep interval 0 seconds):
Code:
require('user.guardZoneStatus')
require('user.guardAreaStatus')
if not port then
require('serial')
port = serial.open('/dev/RS232', { baudrate = 9600, parity = 'none', databits = '8', stopbits = '1'})
port:flush()
line = ''
end
control_house_security_ga = '10/1/0' --area1 security status group address
control_woodstorage_security_ga = '10/1/1' --area2 security status group address
security_code = '1234'
char = port:read(1, 1)
--log(char)
if char then
if char == '\r' then
line = line:trim()
--log(line)
event = string.sub(line,1,2)
-- log(event)
if event == 'G0' then
eventnr = tonumber(string.sub(line,6,-5))
area = tonumber(string.sub(line,10,-1))
eventngr = tonumber(string.sub(line,2,4))
if zone == nil then
zone = 255255
end
guardzonefunction(eventngr,eventnr,area)
elseif event == 'RA' then
area = tonumber(string.sub(line,3,5))
securitystatus_1 = string.sub(line,6,6)
areastatus_1 = string.sub(line,7,7)
areastatus_2 = string.sub(line,8,8)
areastatus_3 = string.sub(line,9,9)
areastatus_4 = string.sub(line,10,10)
areastatus_5 = string.sub(line,11,11)
areastatus_6 = string.sub(line,12,12)
guardareafunction(area,securitystatus_1,areastatus_1,areastatus_2,areastatus_3,areastatus_4,areastatus_5,areastatus_6 )
end
line = ''
else
line = line .. char
end
else
request = grp.getvalue('32/5/0') --scheduled script changes object to true every minute. !!!ADD SCHEDULED SCRIPT!!!
if request then
port:write('RA001\r') --send area1 status request command
os.sleep(0.5)
port:write('RA002\r') --send area2 status request command
grp.update('32/5/0', false)
end
house_arm_disarm = grp.getvalue(control_house_security_ga) --1-Arm; 2-Force arm; 3-Stay arm; 4-Instant arm; 5-Disarm
if house_arm_disarm == 1 then
port:write('AA001A'..security_code..'\r')
grp.update(control_house_security_ga, 0)
elseif house_arm_disarm == 2 then
port:write('AA001F'..security_code..'\r')
grp.update(control_house_security_ga, 0)
elseif house_arm_disarm == 3 then
port:write('AA001S'..security_code..'\r')
grp.update(control_house_security_ga, 0)
elseif house_arm_disarm == 4 then
port:write('AA001I'..security_code..'\r')
grp.update(control_house_security_ga, 0)
elseif house_arm_disarm == 5 then
port:write('AD001'..security_code..'\r')
grp.update(control_house_security_ga, 0)
end
woodstorage_arm_disarm = grp.getvalue(control_woodstorage_security_ga) --1-Arm; 2-Force arm; 3-Stay arm; 4-Instant arm; 5-Disarm
if woodstorage_arm_disarm == 1 then
port:write('AA002A'..security_code..'\r')
grp.update(control_woodstorage_security_ga, 0)
elseif woodstorage_arm_disarm == 2 then
port:write('AA002F'..security_code..'\r')
grp.update(control_woodstorage_security_ga, 0)
elseif woodstorage_arm_disarm == 3 then
port:write('AA002S'..security_code..'\r')
grp.update(control_woodstorage_security_ga, 0)
elseif woodstorage_arm_disarm == 4 then
port:write('AA002I'..security_code..'\r')
grp.update(control_woodstorage_security_ga, 0)
elseif woodstorage_arm_disarm == 5 then
port:write('AD002'..security_code..'\r')
grp.update(control_woodstorage_security_ga, 0)
end
end
User library:
Script name: guardAreaStatus
Code:
function guardareafunction(areanumber, areastatus, areastatus1, areastatus2, areastatus3, areastatus4, areastatus5, areastatus6 ) --what must be process RA001DOONOOO; RA - Request area; 001 - Area number; D - Disarmed/Armed/Force armed/Stay armed/Instant armed; O - Zone in memory/Ok; O - Troube/Ok; N - Not ready/Ok; O - In programming/Ok; O - In alarm/Ok; O - Strobe/Ok
house_area_status_ga = '10/0/0'
woodstorage_area_status_ga = '10/0/1'
house_area_trouble_ga = '10/3/0'
woodstorage_area_trouble_ga = '10/3/1'
house_area_not_ready_ga = '10/3/2'
woodstorage_area_not_ready = '10/3/3'
house_area_alarm_ga = '10/2/0'
woodstorage_area_alarm_ga = '10/2/1'
if areastatus == 'D' then
if areanumber == 1 then
grp.write(house_area_status_ga, 0)
elseif areanumber == 2 then
grp.write(woodstorage_area_status_ga, 0)
end
elseif areastatus == 'A' then
if areanumber == 1 then
grp.update(house_area_status_ga, 1)
elseif areanumber == 2 then
grp.update(woodstorage_area_status_ga, 1)
end
elseif areastatus == 'F' then
if areanumber == 1 then
grp.update(house_area_status_ga, 2)
elseif areanumber == 2 then
grp.update(woodstorage_area_status_ga, 2)
end
elseif areastatus == 'S' then
if areanumber == 1 then
grp.update(house_area_status_ga, 3)
elseif areanumber == 2 then
grp.update(woodstorage_area_status_ga, 3)
end
elseif areastatus == 'I' then
if areanumber == 1 then
grp.update(house_area_status_ga, 4)
elseif areanumber == 2 then
grp.update(woodstorage_area_status_ga, 4)
end
end
if areastatus2 == 'T' then
if areanumber == 1 then
grp.update(house_area_trouble_ga, true)
elseif areanumber == 2 then
grp.update(woodstorage_area_trouble_ga, true)
end
elseif areastatus2 == 'O' then
if areanumber == 1 then
grp.update(house_area_trouble_ga, false)
elseif areanumber == 2 then
grp.update(woodstorage_area_trouble_ga, false)
end
end
if areastatus3 == 'N' then
if areanumber == 1 then
grp.update(house_area_not_ready_ga, true)
elseif areanumber == 2 then
grp.update(woodstorage_area_not_ready, true)
end
elseif areastatus3 == 'O' then
if areanumber == 1 then
grp.update(house_area_not_ready_ga, false)
elseif areanumber == 2 then
grp.update(woodstorage_area_not_ready, false)
end
end
if areastatus5 == 'A' then
if areanumber == 1 then
grp.update(house_area_alarm_ga, true)
elseif areanumber == 2 then
grp.update(woodstorage_area_alarm_ga, true)
end
elseif areastatus5 == 'O' then
if areanumber == 1 then
grp.update(house_area_alarm_ga, false)
elseif areanumber == 2 then
grp.update(woodstorage_area_alarm_ga, false)
end
end
end
Code:
function guardzonefunction( eventgroup,eventnumber,areanumber)
guardZones = {
[255255] = 'An empty zone has arrived',
[01] = 'Tehnoruum PIR.',
[02] = '1k Trepihall PIR.',
[03] = 'Kontor PIR.',
[04] = 'Esik PIR.',
[05] = 'Elutuba PIR.',
[06] = 'Magamistuba PIR.',
[07] = 'Garderoob PIR.',
[08] = 'Kuur PIR.',
[09] = 'Mona PIR ',
[10] = 'Cara PIR ',
[11] = '2k Trepihall PIR ',
[12] = 'Tehnoruumi Suits ',
[13] = '1 Trepihall Suit ',
[14] = 'Kontori Suits ',
[15] = 'Esiku Suits ',
[16] = 'Elutoa Suits ',
[17] = 'Magamistoa Suits ',
[18] = 'Garderoob Suits',
[19] = 'Mona Suits',
[20] = 'Cara Suits',
[21] = '2 Trepihall Suit',
[22] = '2k Elutoa Suits',
[23] = 'Kuuri Uks',
[24] = 'Kontori Aken',
[25] = 'Peauks',
[26] = 'Köögi Aken.',
[27] = 'Terrassi Uks',
[28] = '1k Vannitoa Uks',
[29] = '1k Vannitoa Aken',
[30] = 'Magamistoa Aken',
[31] = 'Kuuri Aken',
[32] = 'Mona 1 Aken',
[33] = 'Cara 1 Aken',
[34] = '2k Vannitoa Aken',
[35] = '2k Elutuba M',
[36] = 'Mona 2 Aken',
[37] = 'Cara 2 Aken',
[38] = 'Valvekilp',
}
house_area_status_ga = '10/0/0'
woodstorage_area_status_ga = '10/0/1'
house_area_alarm_ga = '10/2/0'
woodstorage_area_alarm_ga = '10/2/1'
house_area_exit_delay_ga = '10/0/2'
house_area_entry_delay_ga = '10/0/3'
woodstorage_area_exit_delay_ga = '10/0/4'
woodstorage_area_entry_delay_ga = '10/0/5'
if eventgroup == 0 or eventgroup == 1 then
if eventgroup == 0 then
grp.update('10/4/'..eventnumber, false)
elseif eventgroup == 1 then
grp.update('10/4/'..eventnumber, true)
end
elseif eventgroup == 13 then
if areanumber == 1 then
grp.update(house_area_status_ga, 0)
elseif areanumber == 2 then
grp.update(woodstorage_area_status_ga, 0)
end
elseif eventgroup == 64 then
if eventnumber == 0 then
if areanumber == 1 then
grp.update(house_area_status_ga, 1)
elseif areanumber == 2 then
grp.update(woodstorage_area_status_ga, 1)
end
elseif eventnumber == 1 then
if areanumber == 1 then
grp.update(house_area_status_ga, 2)
elseif areanumber == 2 then
grp.update(woodstorage_area_status_ga, 2)
end
elseif eventnumber == 2 then
if areanumber == 1 then
grp.update(house_area_status_ga, 3)
elseif areanumber == 2 then
grp.update(woodstorage_area_status_ga, 3)
end
elseif eventnumber == 3 then
if areanumber == 1 then
grp.update(house_area_status_ga, 4)
elseif areanumber == 2 then
grp.update(woodstorage_area_status_ga, 4)
end
elseif eventnumber == 4 or eventnumber == 5 or eventnumber == 6 or eventnumber == 7 then
if areanumber == 1 then
grp.update(house_area_alarm_ga, true)
elseif areanumber == 2 then
grp.update(woodstorage_area_alarm_ga, true)
end
end
elseif eventgroup == 65 then
if eventnumber == 1 then
if areanumber == 1 then
grp.update(house_area_exit_delay_ga, true)
elseif areanumber == 2 then
grp.update(woodstorage_area_exit_delay_ga, true)
end
elseif eventnumber == 2 then
if areanumber == 1 then
grp.update(house_area_entry_delay_ga, true)
elseif areanumber == 2 then
grp.update(woodstorage_area_entry_delay_ga, true)
end
elseif eventnumber == 0 then
if areanumber == 1 then
grp.update(house_area_entry_delay_ga, false)
grp.update(house_area_exit_delay_ga, false)
elseif areanumber == 2 then
grp.update(woodstorage_area_entry_delay_ga, false)
grp.update(woodstorage_area_exit_delay_ga, false)
end
end
end
end
Code:
last_timestamp = grp.find("10/0/0").updatetime --Area1 status (status is polled every minute from security system)
communication_error = grp.getvalue('10/3/4')
now = os.microtime()
if (now - last_timestamp) >= 120 then --if object hasn't updated on last 120s then generate communication error
if communication_error == false then
grp.update('10/3/4', true)
end
else
if grp.getvalue('10/3/4')==true then
grp.update('10/3/4', false)
end
end
Here is UI: