power: Add 'initial_state' option for GPIO devices

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Arksine 2020-12-25 19:31:03 -05:00
parent f91e425463
commit 76ccc8b3e1
1 changed files with 2 additions and 1 deletions

View File

@ -164,7 +164,8 @@ class GpioDevice:
f"Unable to init {pin}. Make sure the gpio is not in "
"use by another program or exported by sysfs.")
raise config.error("Power GPIO Config Error")
self.set_power("off")
initial_state = config.getboolean('initial_state', False)
self.set_power("on" if initial_state else "off")
def _parse_pin(self, config):
pin = cfg_pin = config.get("pin")