wildcards in lua
Posted: Sunday 05 March 2017 18:08
I've got a script for door sensors, I'd like to have one block handle all of the door sensors using wildcards since the naming convention is the same, example:
commandArray = {}
if (devicechanged['BackDoorSwitch (Sensor)'] == 'Open' and otherdevices['Security Switch'] == 'Armed') then
commandArray['SendNotification']='Security Alert! Back Door has been opened!#2'
elseif (devicechanged['BackDoorSwitch (Sensor)'] == 'Open' and otherdevices['Security Switch'] == 'Armed Home') then
commandArray['SendNotification']='Security Alert! Back Door has been opened!#2'
end
return commandArray
can I modify this to look for all sensors named *DoorSwitch and then send an alert with the name of whatever door or is tripped?
commandArray = {}
if (devicechanged['BackDoorSwitch (Sensor)'] == 'Open' and otherdevices['Security Switch'] == 'Armed') then
commandArray['SendNotification']='Security Alert! Back Door has been opened!#2'
elseif (devicechanged['BackDoorSwitch (Sensor)'] == 'Open' and otherdevices['Security Switch'] == 'Armed Home') then
commandArray['SendNotification']='Security Alert! Back Door has been opened!#2'
end
return commandArray
can I modify this to look for all sensors named *DoorSwitch and then send an alert with the name of whatever door or is tripped?