diff --git a/hugvey/central_command.py b/hugvey/central_command.py index 75fb60a..2f27175 100644 --- a/hugvey/central_command.py +++ b/hugvey/central_command.py @@ -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))) diff --git a/hugvey/story.py b/hugvey/story.py index 994ae98..0c269ab 100644 --- a/hugvey/story.py +++ b/hugvey/story.py @@ -770,7 +770,6 @@ class Diversion(object): return r = self.regex.search(story.currentReply.getText()) - print('repeat?', r) if r is None: return