From efd5298e45d7cc3008d1659f4d9fd74b82fe1ff9 Mon Sep 17 00:00:00 2001 From: Ruben van de Ven Date: Mon, 26 Aug 2019 08:47:04 +0200 Subject: [PATCH] trigger /hugvey_fade on block/unblock --- hugvey/central_command.py | 12 +++++++++--- server_config.yml | 3 +++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/hugvey/central_command.py b/hugvey/central_command.py index 11c6ba8..9ed2cf3 100644 --- a/hugvey/central_command.py +++ b/hugvey/central_command.py @@ -515,7 +515,9 @@ class HugveyState(object): # 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: 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}") @@ -726,9 +728,13 @@ class HugveyState(object): self.command.commandLight('/hugvey', [self.lightId, self.lightStatus]) def transitionLight(self, intensity, duration): + """ + Intensity: 0-255 + duration: an integer between 0-92 indicating the lanbox fade times + """ self.lightIntensity = intensity 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): """ @@ -785,7 +791,7 @@ class HugveyState(object): port = self.command.config['web']['port'] resuming = False - if Story.hugveyHasSavedState(self.id): + if Story.hugveyHasSavedState(self.lightId): self.logger.info(f"Recovering from state :-)") self.story = Story.loadStoryFromState(self) resuming = True diff --git a/server_config.yml b/server_config.yml index fc9d76e..6eb46cf 100644 --- a/server_config.yml +++ b/server_config.yml @@ -36,5 +36,8 @@ web: light: ip: "192.168.178.15" port: 7400 + on_intensity: 150 + off_intensity: 0 + fade_duration_id: 37 story: loop: true \ No newline at end of file