trigger /hugvey_fade on block/unblock

This commit is contained in:
Ruben van de Ven 2019-08-26 08:47:04 +02:00
parent 2cd47470de
commit efd5298e45
2 changed files with 12 additions and 3 deletions

View file

@ -515,7 +515,9 @@ class HugveyState(object):
# if the story is looping, light should not go off when the story starts # if the story is looping, light should not go off when the story starts
if status != self.STATE_RUNNING or self.command.config['story']['loop'] is False: if status != self.STATE_RUNNING or self.command.config['story']['loop'] is False:
lightOn = status in [self.STATE_AVAILABLE, self.STATE_PAUSE] lightOn = status in [self.STATE_AVAILABLE, self.STATE_PAUSE]
self.setLightStatus(lightOn) intensity = self.command.config['light']['on_intensity'] if lightOn else self.command.config['light']['off_intensity']
duration = self.command.config['light']['fade_duration_id']
self.transitionLight(intensity, duration)
self.eventLogger.info(f"status: {self.status}") self.eventLogger.info(f"status: {self.status}")
@ -726,9 +728,13 @@ class HugveyState(object):
self.command.commandLight('/hugvey', [self.lightId, self.lightStatus]) self.command.commandLight('/hugvey', [self.lightId, self.lightStatus])
def transitionLight(self, intensity, duration): def transitionLight(self, intensity, duration):
"""
Intensity: 0-255
duration: an integer between 0-92 indicating the lanbox fade times
"""
self.lightIntensity = intensity self.lightIntensity = intensity
self.logger.log(LOG_BS, f"Send /hugvey_fade {self.lightIntensity} {duration}") self.logger.log(LOG_BS, f"Send /hugvey_fade {self.lightIntensity} {duration}")
self.command.commandLight('/hugvey_fade', [self.lightId, intensity, duration]) self.command.commandLight('/hugvey_fade', [self.lightId, intensity, int(duration)])
def setLightId(self, id): def setLightId(self, id):
""" """
@ -785,7 +791,7 @@ class HugveyState(object):
port = self.command.config['web']['port'] port = self.command.config['web']['port']
resuming = False resuming = False
if Story.hugveyHasSavedState(self.id): if Story.hugveyHasSavedState(self.lightId):
self.logger.info(f"Recovering from state :-)") self.logger.info(f"Recovering from state :-)")
self.story = Story.loadStoryFromState(self) self.story = Story.loadStoryFromState(self)
resuming = True resuming = True

View file

@ -36,5 +36,8 @@ web:
light: light:
ip: "192.168.178.15" ip: "192.168.178.15"
port: 7400 port: 7400
on_intensity: 150
off_intensity: 0
fade_duration_id: 37
story: story:
loop: true loop: true