mirror of
https://github.com/binary-kitchen/doorlockd
synced 2024-12-22 10:24:26 +01:00
doorlockd.py: add doorlock sounds
Signed-off-by: Ralf Ramsauer <ralf@binary-kitchen.de>
This commit is contained in:
parent
8f8db8950b
commit
010563dab4
@ -1,4 +1,3 @@
|
|||||||
- Add sounds
|
|
||||||
- Remove php-fpm
|
- Remove php-fpm
|
||||||
- adjust nginx config
|
- adjust nginx config
|
||||||
- Add proper SSL certificates
|
- Add proper SSL certificates
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
DEBUG = True
|
DEBUG = False
|
||||||
SIMULATE = True
|
SIMULATE = False
|
||||||
RUN_HOOKS = False
|
RUN_HOOKS = True
|
||||||
|
SOUNDS = True
|
||||||
SECRET_KEY = 'foobar'
|
SECRET_KEY = 'foobar'
|
||||||
|
|
||||||
LDAP_CA = './ssl/BKCA.crt'
|
LDAP_CA = './ssl/BKCA.crt'
|
||||||
@ -9,4 +10,11 @@ LDAP_BINDDN = 'cn=%s,ou=people,dc=binary-kitchen,dc=de'
|
|||||||
|
|
||||||
BOOTSTRAP_SERVE_LOCAL = True
|
BOOTSTRAP_SERVE_LOCAL = True
|
||||||
|
|
||||||
SERIAL_PORT = '/dev/ttyS0'
|
SERIAL_PORT = '/dev/ttyAMA0'
|
||||||
|
|
||||||
|
WAVE_EMERGENCY = './sounds/emergency_unlock.wav'
|
||||||
|
WAVE_LOCK = './sounds/lock.wav'
|
||||||
|
WAVE_LOCK_BUTTON = './sounds/lock_button.wav'
|
||||||
|
WAVE_UNLOCK = './sounds/unlock.wav'
|
||||||
|
WAVE_UNLOCK_BUTTON = './sounds/unlock_button.wav'
|
||||||
|
WAVE_ZONK = './sounds/zonk.wav'
|
||||||
|
@ -71,6 +71,14 @@ if 'LDAP_CA' in webapp.config.keys():
|
|||||||
ldap_uri = webapp.config.get('LDAP_URI')
|
ldap_uri = webapp.config.get('LDAP_URI')
|
||||||
ldap_binddn = webapp.config.get('LDAP_BINDDN')
|
ldap_binddn = webapp.config.get('LDAP_BINDDN')
|
||||||
|
|
||||||
|
wave_emergency = webapp.config.get('WAVE_EMERGENCY')
|
||||||
|
wave_lock = webapp.config.get('WAVE_LOCK')
|
||||||
|
wave_lock_button = webapp.config.get('WAVE_LOCK_BUTTON')
|
||||||
|
wave_unlock = webapp.config.get('WAVE_UNLOCK')
|
||||||
|
wave_unlock_button = webapp.config.get('WAVE_UNLOCK_BUTTON')
|
||||||
|
wave_zonk = webapp.config.get('WAVE_ZONK')
|
||||||
|
sounds = webapp.config.get('SOUNDS')
|
||||||
|
|
||||||
# copied from sudo
|
# copied from sudo
|
||||||
eperm_insults = {
|
eperm_insults = {
|
||||||
'Wrong! You cheating scum!',
|
'Wrong! You cheating scum!',
|
||||||
@ -98,6 +106,12 @@ def choose_insult():
|
|||||||
return(sample(eperm_insults, 1)[0])
|
return(sample(eperm_insults, 1)[0])
|
||||||
|
|
||||||
|
|
||||||
|
def playsound(filename):
|
||||||
|
if not sounds:
|
||||||
|
return
|
||||||
|
Popen(['nohup', 'aplay', filename])
|
||||||
|
|
||||||
|
|
||||||
def start_hook(script):
|
def start_hook(script):
|
||||||
if not run_hooks:
|
if not run_hooks:
|
||||||
log.info('Hooks disabled: not starting %s' % script)
|
log.info('Hooks disabled: not starting %s' % script)
|
||||||
@ -183,11 +197,14 @@ class DoorHandler:
|
|||||||
|
|
||||||
def handle_input(self, recv, expect=None):
|
def handle_input(self, recv, expect=None):
|
||||||
if recv == DoorHandler.BUTTON_LOCK_PRESS:
|
if recv == DoorHandler.BUTTON_LOCK_PRESS:
|
||||||
|
playsound(wave_lock_button)
|
||||||
self.state = DoorState.Close
|
self.state = DoorState.Close
|
||||||
logic.emit_status(LogicResponse.ButtonLock)
|
logic.emit_status(LogicResponse.ButtonLock)
|
||||||
elif recv == DoorHandler.BUTTON_UNLOCK_PRESS:
|
elif recv == DoorHandler.BUTTON_UNLOCK_PRESS:
|
||||||
|
playsound(wave_unlock_button)
|
||||||
logic.emit_status(LogicResponse.ButtonUnlock)
|
logic.emit_status(LogicResponse.ButtonUnlock)
|
||||||
elif recv == DoorHandler.BUTTON_EMERGENCY_PRESS:
|
elif recv == DoorHandler.BUTTON_EMERGENCY_PRESS:
|
||||||
|
playsound(wave_emergency)
|
||||||
logic.emit_status(LogicResponse.EmergencyUnlock)
|
logic.emit_status(LogicResponse.EmergencyUnlock)
|
||||||
|
|
||||||
if expect is None:
|
if expect is None:
|
||||||
@ -281,6 +298,13 @@ class Logic:
|
|||||||
|
|
||||||
def request(self, state, credentials):
|
def request(self, state, credentials):
|
||||||
err = self._request(state, credentials)
|
err = self._request(state, credentials)
|
||||||
|
if err == LogicResponse.Success:
|
||||||
|
if self.door_handler.state == DoorState.Open:
|
||||||
|
playsound(wave_unlock)
|
||||||
|
if self.door_handler.state == DoorState.Close:
|
||||||
|
playsound(wave_lock)
|
||||||
|
elif err == LogicResponse.AlreadyLocked or err == LogicResponse.AlreadyOpen:
|
||||||
|
playsound(wave_zonk)
|
||||||
self.emit_status(err)
|
self.emit_status(err)
|
||||||
return err
|
return err
|
||||||
|
|
||||||
|
BIN
doorlockd-new/sounds/emergency_unlock.wav
Normal file
BIN
doorlockd-new/sounds/emergency_unlock.wav
Normal file
Binary file not shown.
BIN
doorlockd-new/sounds/lock.wav
Normal file
BIN
doorlockd-new/sounds/lock.wav
Normal file
Binary file not shown.
BIN
doorlockd-new/sounds/lock_button.wav
Normal file
BIN
doorlockd-new/sounds/lock_button.wav
Normal file
Binary file not shown.
BIN
doorlockd-new/sounds/unlock.wav
Normal file
BIN
doorlockd-new/sounds/unlock.wav
Normal file
Binary file not shown.
BIN
doorlockd-new/sounds/unlock_button.wav
Normal file
BIN
doorlockd-new/sounds/unlock_button.wav
Normal file
Binary file not shown.
BIN
doorlockd-new/sounds/zonk.wav
Normal file
BIN
doorlockd-new/sounds/zonk.wav
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user