Alarm

From Domoticz
Jump to: navigation, search

Purpose

This script is a simple alarm.

This script has been taken from here

Dependencies - hardware / software / operating system

This script will work on all type of hardware / software / operating system.

Domoticz Setup - switches, variables, version

TBC

Installation instructions

Copy this script in your domoticz\scripts\lua\ folder.

Script with comments

local sensor  = 'Bedroom 1 - Motion'
local sensor2 = 'Hall - Motion'
local sensor3 = 'Living Room - Motion'

local sensor_out = 'Presence Detected'
local sensor_out2 = 'Security Panel'

commandArray = {}

function timedifference (s)
 year = string.sub(s, 1, 4)
 month = string.sub(s, 6, 7)
 day = string.sub(s, 9, 10)
 hour = string.sub(s, 12, 13)
 minutes = string.sub(s, 15, 16)
 seconds = string.sub(s, 18, 19)
 t1 = os.time()
 t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
 difference = os.difftime (t1, t2)
 return difference
end

if ((devicechanged[sensor] == 'On') or (devicechanged[sensor2] == 'On') or (devicechanged[sensor3] == 'On')) then
print('Presence from PIR') 
commandArray[sensor_out]='On'

--commandArray['SecPanel']='Arm Home'
--else
--commandArray['Security Panel']='Disarm'
 
end


--if(devicechanged[sensor_out] == 'On') then
--commandArray[sensor_out2]='Arm Home'
--end

--commandArray['SecPanel']='Arm Home'
--commandArray['SecPanel']='Disarm'
--commandArray['SecPanel']='Arm Away'

return commandArray

Example of use (if relevant) i.e. output files / screen displays

N/A