If no hugvey is available, override the red light Fix #42
This commit is contained in:
parent
735a63683d
commit
484542de8d
2 changed files with 20 additions and 1 deletions
|
@ -232,6 +232,23 @@ class CentralCommand(object):
|
||||||
|
|
||||||
logger.warn('Stopping light sender')
|
logger.warn('Stopping light sender')
|
||||||
lightConn._sock.close()
|
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):
|
def instantiateHugvey(self, hugvey_id):
|
||||||
'''
|
'''
|
||||||
|
@ -357,6 +374,9 @@ class CentralCommand(object):
|
||||||
self.catchException(self.commandSender()))
|
self.catchException(self.commandSender()))
|
||||||
self.tasks['lightSender'] = self.loop.create_task(
|
self.tasks['lightSender'] = self.loop.create_task(
|
||||||
self.catchException(self.lightSender()))
|
self.catchException(self.lightSender()))
|
||||||
|
self.tasks['redLightController'] = self.loop.create_task(
|
||||||
|
self.catchException(self.redLightController()))
|
||||||
|
|
||||||
for hid in self.hugvey_ids:
|
for hid in self.hugvey_ids:
|
||||||
self.tasks['voiceListener'] = self.loop.create_task(
|
self.tasks['voiceListener'] = self.loop.create_task(
|
||||||
self.catchException(self.voiceListener(hid)))
|
self.catchException(self.voiceListener(hid)))
|
||||||
|
|
|
@ -770,7 +770,6 @@ class Diversion(object):
|
||||||
return
|
return
|
||||||
|
|
||||||
r = self.regex.search(story.currentReply.getText())
|
r = self.regex.search(story.currentReply.getText())
|
||||||
print('repeat?', r)
|
|
||||||
if r is None:
|
if r is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue