diff --git a/scripts/audio/synth-power.py b/scripts/audio/synth-power.py index bfc50ed..0231c19 100644 --- a/scripts/audio/synth-power.py +++ b/scripts/audio/synth-power.py @@ -5,7 +5,8 @@ import argparse import configparser import os,sys,inspect -currentDir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) +currentDir = os.path.dirname(os.path.abspath( + inspect.getfile(inspect.currentframe()))) parentDir = os.path.dirname(currentDir) sys.path.insert(0, parentDir) from homeassistant import HomeAssistant @@ -44,7 +45,8 @@ def setSynthsPower(state): setHydrasynthPower(state) setMatrixBrutePower(state) -parser = argparse.ArgumentParser(description='Control power state of synthesizers.') +parser = argparse.ArgumentParser( + description='Control power state of synthesizers.') parser.add_argument('-d', '--daw', action='store_true', help='enable DAW mode', dest='daw', default=False, required=False) diff --git a/scripts/homeassistant.py b/scripts/homeassistant.py index ab9592f..ca0fa58 100644 --- a/scripts/homeassistant.py +++ b/scripts/homeassistant.py @@ -133,3 +133,10 @@ class HomeAssistant(object): self.turnOn(entityId) else: self.turnOff(entityId) + + # Toggles power state of a given device. + def togglePower(self, entityId): + if self.getState(entityId)['state'] == 'off': + self.turnOn(entityId) + else: + self.turnOff(entityId)