Fix red light status for looping story
This commit is contained in:
parent
417b3d9361
commit
8a3b8e070b
1 changed files with 13 additions and 2 deletions
|
@ -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
|
||||
|
@ -451,6 +454,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
|
||||
|
||||
|
|
Loading…
Reference in a new issue