Added device toggling

This commit is contained in:
Christian Colglazier 2020-11-26 16:28:35 -05:00
parent 80946e9761
commit ee8d5dbce9
2 changed files with 11 additions and 2 deletions

View File

@ -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)

View File

@ -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)