The script (is just a small edit on the original idealarmhelpers just the devices are remarked or changed)
Code: Select all
--[[
Edit this file suit your needs
Place this file in the dzVents scripts folder using the name ideAlarmConfig.lua
See https://github.com/allan-gam/ideAlarm/wiki/configuration
After editing, always verify that it's valid LUA at http://codepad.org/ (Mark your paste as "Private"!!!)
--]]
local _C = {}
-- ideAlarm Custom helper functions. These functions will be called if they exist.
_C.helpers = {
alarmZoneNormal = function(domoticz, alarmZone)
-- Normal is good isn't it? We don't have to do anything here.. We could but..
end,
alarmZoneArming = function(domoticz, alarmZone)
-- You can define something to happen here.
-- This function will be called when arming and waiting for the exit delay.
-- If the exit delay is 0 seconds, this function will not be called.
end,
alarmZoneTripped = function(domoticz, alarmZone)
-- A sensor has been tripped but there is still no alert
-- We should inform whoever tripped the sensor so he/she can disarm the alarm
-- before a timeout occurs and we get an alert
-- In this example we turn on the kitchen lights if the zones name
-- is 'My Home' but we could also let Domoticz speak a message or something.
--local trippedSensors = alarmZone.trippedSensors(domoticz, 1) -- Can be used if we need to.
if alarmZone.name == 'Thuis' then
-- Let's do something here
domoticz.devices('DIM-Keuken').dimTo(100)
domoticz.devices('DIM-PlafondWK').dimTo(100)
end
end,
alarmZoneError = function(domoticz, alarmZone)
-- An error occurred for an alarm zone. Maybe a door was open when we tried to
-- arm the zone. Anyway we should do something about it.
domoticz.notify('Alarm Zone Error!',
'There was an error for the alarm zone ' .. alarmZone.name,
domoticz.PRIORITY_HIGH)
end,
alarmZoneArmingWithTrippedSensors = function(domoticz, alarmZone, armingMode)
-- Tripped sensors have been detected when arming. If canArmWithTrippedSensors has been set
-- to true in the configuration file for the zone, arming will proceed,
-- if not, then the alarmZoneError function will be called subsequently and arming will not occur.
local msg = ''
local isArming = true
local trippedSensors = alarmZone.trippedSensors(domoticz, 0, armingMode, isArming)
for _, sensor in ipairs(trippedSensors) do
if msg ~= '' then msg = msg..' and ' end
msg = msg..sensor.name
end
if msg ~= '' then
msg = 'Open sections in '..alarmZone.name..'. '..msg
domoticz.notify('Open sections when arming',
msg .. alarmZone.name,
domoticz.PRIORITY_HIGH)
end
end,
alarmZoneAlert = function(domoticz, alarmZone, testMode)
local msg = 'Intrusion detected in zone '..alarmZone.name..'. '
local oneMinute = 1
for _, sensor in ipairs(alarmZone.trippedSensors(domoticz, oneMinute)) do
msg = msg..sensor.name..' tripped @ '..sensor.lastUpdate.raw..'. '
end
if not testMode then
domoticz.notify('Alarm Zone Alert!',
msg, domoticz.PRIORITY_HIGH)
else
domoticz.log('(TESTMODE IS ACTIVE) '..msg, domoticz.LOG_INFO)
end
end,
alarmArmingModeChanged = function(domoticz, alarmZone)
-- The arming mode for a zone has changed. We might want to be informed about that.
local zoneName = alarmZone.name
local armingMode = alarmZone.armingMode(domoticz)
domoticz.notify('Arming mode change',
'The new arming mode for ' .. zoneName .. ' is ' .. armingMode,
domoticz.PRIORITY_LOW)
-- Buy a Fibaro Wall Plug 2 and configure it to display red when off, green when on
-- You can then use it as in alarm arming mode indicator!
if armingMode == domoticz.SECURITY_DISARMED then
-- domoticz.devices('Alarm Status Indicator').switchOff() -- Green light on
--else
-- domoticz.devices('Alarm Status Indicator').switchOn() -- Red light on
end
end,
alarmNagOpenSensors = function(domoticz, alarmZone, nagSensors, lastValue)
if alarmZone.name == 'Thuis' then
if #nagSensors == 0 and lastValue > 0 then
domoticz.log('The previously reported sections are now closed! Good work!', domoticz.LOG_INFO)
elseif #nagSensors > 0 then
local msg = ''
for _, sensor in ipairs(nagSensors) do
if msg ~= '' then msg = msg..' and ' end
msg = msg..sensor.name
end
msg = 'Open sections in zone: '..alarmZone.name..'. '..msg
domoticz.log(msg, domoticz.LOG_INFO)
end
end
end,
alarmOpenSensorsAllZones = function(domoticz, alarmZones)
-- Toggle the big red lamp if there are any open sensors in 'My House'
for _, alarmZone in ipairs(alarmZones) do
if alarmZone.name == 'Thuis' then
--if (alarmZone.openSensorCount > 0) then
-- domoticz.devices('Big Red Lamp').switchOn()
--elseif (alarmZone.openSensorCount == 0) then
-- domoticz.devices('Big Red Lamp').switchOff()
--end
end
end
end,
}
return _C
test script and output
Code: Select all
return {
active = true,
on = {
devices = {
'0-Test'
}
},
execute = function(domoticz, device)
if (device.name == '0-Test' and device.state == 'On') then
domoticz.devices('DIM-Keuken').dimTo(100) end
end
}
Code: Select all
2017-12-09 09:00:17.675 User: xxxxxxx initiated a switch command (741/0-Test/On)
2017-12-09 09:00:17.684 (Dummy) Light/Switch (0-Test)
2017-12-09 09:00:17.792 dzVents: Info: Handling events for: "0-Test", value: "On"
2017-12-09 09:00:17.792 dzVents: Info: ------ Start internal script: 0-Test: Device: "0-Test (Dummy)", Index: 741
2017-12-09 09:00:17.793 dzVents: Info: ------ Finished 0-Test
2017-12-09 09:00:17.824 OpenZWave: Domoticz has send a Switch command!, Level: 99, NodeID: 50 (0x32)
2017-12-09 09:00:17.830 (Z-wave) Light/Switch (DIM-Keuken)
idealarmdebug
Code: Select all
2017-12-09 09:03:25.005 dzVents: Info: Handling events for: "Achterdeur motion", value: "Closed"
2017-12-09 09:03:25.005 dzVents: Info: ideAlarm V2.1.1: ------ Start external script: ideAlarm.lua: Device: "Achterdeur motion (Z-wave)", Index: 724
2017-12-09 09:03:25.006 dzVents: Debug: ideAlarm V2.1.1: Triggered by device: Achterdeur motion, device state is: Closed
2017-12-09 09:03:25.006 dzVents: Info: ideAlarm V2.1.1: triggerType sensor
2017-12-09 09:03:25.007 dzVents: Debug: ideAlarm V2.1.1: Device-adapter found for Voordeur motion: Switch device adapter
2017-12-09 09:03:25.007 dzVents: Debug: ideAlarm V2.1.1: Processing device-adapter for Voordeur motion: Switch device adapter
2017-12-09 09:03:25.008 dzVents: Debug: ideAlarm V2.1.1: Device-adapter found for Voordeur Arming Mode: Text device
2017-12-09 09:03:25.008 dzVents: Debug: ideAlarm V2.1.1: Processing device-adapter for Voordeur Arming Mode: Text device
2017-12-09 09:03:25.009 dzVents: Debug: ideAlarm V2.1.1: Device-adapter found for Achterdeur Arming Mode: Text device
2017-12-09 09:03:25.010 dzVents: Debug: ideAlarm V2.1.1: Processing device-adapter for Achterdeur Arming Mode: Text device
2017-12-09 09:03:25.010 dzVents: Info: ideAlarm V2.1.1: ------ Finished ideAlarm.lua
2017-12-09 09:03:25.357 (Dummy) General/Text (Achterdeur Status)
2017-12-09 09:03:25.574 dzVents: Info: Handling events for: "Achterdeur Status", value: "Timed out"
2017-12-09 09:03:25.575 dzVents: Info: ideAlarm V2.1.1: ------ Start external script: ideAlarm.lua: Device: "Achterdeur Status (Dummy)", Index: 736
2017-12-09 09:03:25.575 dzVents: Debug: ideAlarm V2.1.1: Triggered by device: Achterdeur Status, device state is: Timed out
2017-12-09 09:03:25.575 dzVents: Info: ideAlarm V2.1.1: triggerType status
2017-12-09 09:03:25.575 dzVents: Debug: ideAlarm V2.1.1: Deal with alarm status changes for zone Achterdeur
2017-12-09 09:03:25.577 dzVents: Debug: ideAlarm V2.1.1: Device-adapter found for Achterdeur Arming Mode: Text device
2017-12-09 09:03:25.577 dzVents: Debug: ideAlarm V2.1.1: Processing device-adapter for Achterdeur Arming Mode: Text device
2017-12-09 09:03:25.577 dzVents: Debug: ideAlarm V2.1.1: Constructed timed-command: 736|0|Alert TRIGGER
2017-12-09 09:03:25.577 dzVents: Info: ideAlarm V2.1.1: Achterdeur new status: Alert immediately
2017-12-09 09:03:25.578 dzVents: Debug: ideAlarm V2.1.1: Device-adapter found for DIM-PlafondWK: Switch device adapter
2017-12-09 09:03:25.578 dzVents: Debug: ideAlarm V2.1.1: Processing device-adapter for DIM-PlafondWK: Switch device adapter
2017-12-09 09:03:25.579 dzVents: Debug: ideAlarm V2.1.1: Device-adapter found for DIM-Keuken: Switch device adapter
2017-12-09 09:03:25.580 dzVents: Debug: ideAlarm V2.1.1: Processing device-adapter for DIM-Keuken: Switch device adapter
2017-12-09 09:03:25.580 dzVents: Info: ideAlarm V2.1.1: ------ Finished ideAlarm.lua
2017-12-09 09:03:25.715 dzVents: Info: Handling events for: "Achterdeur Status", value: "Alert"
2017-12-09 09:03:25.716 dzVents: Info: ideAlarm V2.1.1: ------ Start external script: ideAlarm.lua: Device: "Achterdeur Status (Dummy)", Index: 736
2017-12-09 09:03:25.716 dzVents: Debug: ideAlarm V2.1.1: Triggered by device: Achterdeur Status, device state is: Alert
2017-12-09 09:03:25.716 dzVents: Info: ideAlarm V2.1.1: triggerType status
2017-12-09 09:03:25.717 dzVents: Debug: ideAlarm V2.1.1: Deal with alarm status changes for zone Achterdeur
2017-12-09 09:03:25.718 dzVents: Debug: ideAlarm V2.1.1: Device-adapter found for Achterdeur Arming Mode: Text device
2017-12-09 09:03:25.718 dzVents: Debug: ideAlarm V2.1.1: Processing device-adapter for Achterdeur Arming Mode: Text device
2017-12-09 09:03:25.719 dzVents: Debug: ideAlarm V2.1.1: Device-adapter found for Achterdeur motion: Switch device adapter
2017-12-09 09:03:25.719 dzVents: Debug: ideAlarm V2.1.1: Processing device-adapter for Achterdeur motion: Switch device adapter
2017-12-09 09:03:25.719 dzVents: !Info: ideAlarm V2.1.1: Turning on noise for zone Achterdeur
2017-12-09 09:03:25.720 dzVents: Debug: ideAlarm V2.1.1: Device-adapter found for DIM-PlafondWK: Switch device adapter
2017-12-09 09:03:25.720 dzVents: Debug: ideAlarm V2.1.1: Processing device-adapter for DIM-PlafondWK: Switch device adapter
2017-12-09 09:03:25.720 dzVents: Debug: ideAlarm V2.1.1: Constructed timed-command: On
2017-12-09 09:03:25.721 dzVents: Debug: ideAlarm V2.1.1: Constructed timed-command: On NOTRIGGER
2017-12-09 09:03:25.721 dzVents: Debug: ideAlarm V2.1.1: Constructed timed-command: Off
2017-12-09 09:03:25.721 dzVents: Debug: ideAlarm V2.1.1: Constructed timed-command: Off AFTER 300 SECONDS
2017-12-09 09:03:25.721 dzVents: Debug: ideAlarm V2.1.1: Constructed timed-command: Off AFTER 300 SECONDS NOTRIGGER
2017-12-09 09:03:25.722 dzVents: Debug: ideAlarm V2.1.1: Device-adapter found for DIM-Keuken: Switch device adapter
2017-12-09 09:03:25.722 dzVents: Debug: ideAlarm V2.1.1: Processing device-adapter for DIM-Keuken: Switch device adapter
2017-12-09 09:03:25.722 dzVents: Debug: ideAlarm V2.1.1: Constructed timed-command: On
2017-12-09 09:03:25.722 dzVents: Debug: ideAlarm V2.1.1: Constructed timed-command: On NOTRIGGER
2017-12-09 09:03:25.722 dzVents: Debug: ideAlarm V2.1.1: Constructed timed-command: Off
2017-12-09 09:03:25.723 dzVents: Debug: ideAlarm V2.1.1: Constructed timed-command: Off AFTER 300 SECONDS
2017-12-09 09:03:25.723 dzVents: Debug: ideAlarm V2.1.1: Constructed timed-command: Off AFTER 300 SECONDS NOTRIGGER
2017-12-09 09:03:25.725 dzVents: Info: ideAlarm V2.1.1: ------ Finished ideAlarm.lua