diff options
author | Devaev Maxim <[email protected]> | 2020-08-31 03:58:07 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2020-08-31 03:58:07 +0300 |
commit | 9baf507453722d88f116db6f61f80e0e5d569849 (patch) | |
tree | bd695585c7324e9f92c8e31e8fa35791f968482f /kvmd/apps/__init__.py | |
parent | cb1e5c10cb57edd0afaa4bb640b95b1ccb352169 (diff) |
inverted output and initial state
Diffstat (limited to 'kvmd/apps/__init__.py')
-rw-r--r-- | kvmd/apps/__init__.py | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/kvmd/apps/__init__.py b/kvmd/apps/__init__.py index 138e4ecf..5e23f56c 100644 --- a/kvmd/apps/__init__.py +++ b/kvmd/apps/__init__.py @@ -177,24 +177,25 @@ def _patch_dynamic( # pylint: disable=too-many-locals try: mode = valid_gpio_mode(params.get("mode", "")) except Exception: - mode = "" - channel_scheme: Dict = { - "pin": Option(-1, type=valid_gpio_pin), - "mode": Option("", type=valid_gpio_mode), - "title": Option(""), - } - if mode == "input": - channel_scheme["inverted"] = Option(False, type=valid_bool) - else: # output - channel_scheme.update({ - "switch": Option(True, type=valid_bool), - "pulse": { - "delay": Option(0.1, type=valid_float_f0), - "min_delay": Option(0.1, type=valid_float_f01), - "max_delay": Option(0.1, type=valid_float_f01), - }, - }) - scheme["kvmd"]["gpio"]["scheme"][channel] = channel_scheme + pass + finally: + ch_scheme: Dict = { + "pin": Option(-1, type=valid_gpio_pin), + "mode": Option("", type=valid_gpio_mode), + "title": Option(""), + "inverted": Option(False, type=valid_bool), + } + if mode == "output": + ch_scheme.update({ + "initial": Option(False, type=valid_bool), + "switch": Option(True, type=valid_bool), + "pulse": { + "delay": Option(0.1, type=valid_float_f0), + "min_delay": Option(0.1, type=valid_float_f01), + "max_delay": Option(0.1, type=valid_float_f01), + }, + }) + scheme["kvmd"]["gpio"]["scheme"][channel] = ch_scheme return rebuild |