diff --git a/hugvey/central_command.py b/hugvey/central_command.py index 19d8d1f..b56deaf 100644 --- a/hugvey/central_command.py +++ b/hugvey/central_command.py @@ -246,9 +246,12 @@ class CentralCommand(object): """ currentCode = None while self.isRunning.is_set(): - statusses = [hv.getStatus() for hv in self.hugveys.values()] - lightOn = HugveyState.STATE_AVAILABLE not in statusses +# statusses = [hv.getStatus() for hv in self.hugveys.values()] +# lightOn = HugveyState.STATE_AVAILABLE not in statusses + statusses = [hv.isAvailable() for hv in self.hugveys.values()] + lightOn = True not in statusses lightCode = 1 if lightOn else 0 + print("LIGHT", lightCode) if lightCode != currentCode: self.commandLight('/red', [lightCode]) currentCode = lightCode @@ -450,6 +453,14 @@ class HugveyState(object): def __del__(self): self.logger.warn("Destroying hugvey object") + + def isAvailable(self): + if self.command.config['story']['loop']: + if self.status == self.STATE_RUNNING and self.story: + if self.story.currentMessage: + if self.story.currentMessage.id == self.story.startMessage.id: + return True + return self.status == self.STATE_AVAILABLE def getStatus(self): return self.status