Script updated for CredoID v4.3.74
This commit is contained in:
parent
988a149f18
commit
09fb0d28d4
|
@ -1,9 +1,15 @@
|
|||
import re
|
||||
from System import Guid
|
||||
import threading
|
||||
|
||||
#for elevator use, access level must have floors in access level name
|
||||
#outputs name must be dec number represnting floor
|
||||
#output number represents the floor
|
||||
#device with modules must be assigned to single elevator
|
||||
#OUTPUT_ON_TIME represents output on time in seconds
|
||||
|
||||
OUTPUT_ON_TIME = 8
|
||||
|
||||
allOutputs = context.get_outputs()
|
||||
|
||||
def on_event(event):
|
||||
accessGranted = Guid("891adc81-6991-44c2-8aa4-f7a0792f77f5")
|
||||
|
@ -11,14 +17,28 @@ def on_event(event):
|
|||
return
|
||||
floorsList = set()
|
||||
accessLevels = context.get_user_access_levels(event.userId)
|
||||
for accessLevel in accessLevels.Result:
|
||||
for accessLevelPermission in context.get_access_level_permissions(accessLevel.AccessLevelId):
|
||||
for accessLevel in accessLevels:
|
||||
for accessLevelPermission in context.get_access_level_permissions(accessLevel.accessLevelId):
|
||||
controller = context.get_readers(accessLevelPermission.doorId)
|
||||
if event.deviceId == controller[0].deviceId:
|
||||
floors = re.findall(r'\d+', accessLevel.Name)
|
||||
floorsList.update(floors)
|
||||
floors = re.findall(r'\d+', accessLevel.name)
|
||||
deviceOutputs = [output for output in allOutputs if output.deviceId == controller[0].deviceId]
|
||||
|
||||
for output in deviceOutputs:
|
||||
if str(output.outputNumber) in floors:
|
||||
floorsList.update([output.name])
|
||||
else:
|
||||
continue
|
||||
turn_outputs_on(floorsList)
|
||||
t = threading.Timer(OUTPUT_ON_TIME, turn_outputs_off, [floorsList])
|
||||
t.start()
|
||||
|
||||
def turn_outputs_off(outputs):
|
||||
for output in outputs:
|
||||
context.turn_output_off(output)
|
||||
|
||||
def turn_outputs_on(outputs):
|
||||
for output in outputs:
|
||||
context.turn_output_on(output)
|
||||
|
||||
|
||||
for floor in floorsList:
|
||||
context.turn_timed_output_on(floor)
|
Loading…
Reference in New Issue