From 8a3b8e070b07d35897b6c83ebe2468043aeaf267 Mon Sep 17 00:00:00 2001 From: Ruben van de Ven Date: Fri, 14 Jun 2019 15:54:32 +0200 Subject: [PATCH] Fix red light status for looping story --- hugvey/central_command.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) 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