If no hugvey is available, override the red light Fix #42

This commit is contained in:
Ruben van de Ven 2019-05-10 19:35:57 +02:00
parent 735a63683d
commit 484542de8d
2 changed files with 20 additions and 1 deletions

View File

@ -232,6 +232,23 @@ class CentralCommand(object):
logger.warn('Stopping light sender')
lightConn._sock.close()
async def redLightController(self):
"""
Every second, check if no hugveys are available. If so, the red light should be
overruled to be on. If any is available, send a 0 to release the override.
"""
currentCode = None
while self.isRunning.is_set():
statusses = [hv.getStatus() for hv in self.hugveys.values()]
lightOn = HugveyState.STATE_AVAILABLE not in statusses
lightCode = 1 if lightOn else 0
if lightCode != currentCode:
self.commandLight('/red', [lightCode])
currentCode = lightCode
await asyncio.sleep(1)
logger.warn('Stopping red light controller')
def instantiateHugvey(self, hugvey_id):
'''
@ -357,6 +374,9 @@ class CentralCommand(object):
self.catchException(self.commandSender()))
self.tasks['lightSender'] = self.loop.create_task(
self.catchException(self.lightSender()))
self.tasks['redLightController'] = self.loop.create_task(
self.catchException(self.redLightController()))
for hid in self.hugvey_ids:
self.tasks['voiceListener'] = self.loop.create_task(
self.catchException(self.voiceListener(hid)))

View File

@ -770,7 +770,6 @@ class Diversion(object):
return
r = self.regex.search(story.currentReply.getText())
print('repeat?', r)
if r is None:
return