Skip to content

Add delayed-off support for authbox outputs.#61

Open
brianbeck-google wants to merge 3 commits intogoogle:masterfrom
brianbeck-google:delayed-off
Open

Add delayed-off support for authbox outputs.#61
brianbeck-google wants to merge 3 commits intogoogle:masterfrom
brianbeck-google:delayed-off

Conversation

@brianbeck-google
Copy link
Copy Markdown

This allows each output pin to have a configured delay between the abort button being pressed and the pin being disabled. This supports scenarios such as keeping ventilation on longer after a tool has been deactivated.

Tested:

  • Added unit tests for delayed off and reauth during delay timer. All tests pass
  • Physical hardware: confirmed that previous config file (with no changes, no delay section) continues working as before (all outputs immediately turn off)
  • Physical hardware: confirmed that outputs stay on during delay and turn off after delay (tested delays 10s, 180s)
  • Physical hardware: confirmed that deauth and then reauth during the delay timer period leaves the device continuously on with no interruption

This commit was generated in part with Gemini 3.1 Pro. Prompt:

Write a plan to add the ability to control the two outputs separately,
specifically keeping one output alive for a configurable duration after
the "off" behavior is triggered.

In two_button.ini the parameter `enable_output` currently toggles both
`Relay:ActiveHigh:29` and `Relay:ActiveHigh:31`.  The logic to read
these parameters is in  two_button.py

It is critical that all changes be backwards compatible - that is, after
the change, the old version of the config should trigger the same
behavior as today (trigger both outputs out and on at the same time).
There should be new syntax options that allow using this new behavior.

The code should handle the case where someone triggers an `abort` and
then triggers an `on_button_down` before the timer expires.  In this
case, the output should remain continuously on.

* Add a new optional parameter for how long to keep Relay:ActiveHigh:31
  after the service is disabled.  This duration should be specified in
  seconds.
  * In the `abort` function in two_button.py, instead of immediately
    turning all options off, if a delay >0 is configured, a timer should
    be started.  When the timer expires that output should be disabled

* Update the makefile to run them against all python files.
* Fix syntax error in requirements_dev.txt (trailing period).
* Update flake8 to v5.
* Fix broken imports in unit tests
* Run `make format` to get all files into a lint-clean state in preparation for future work.
* Fix errors called out by `make lint`

Fixes google#59

Tested:

```
make setup
python -m unittest
make format
make lint
```
This allows each output pin to have a configured delay between the abort
button being pressed and the pin being disabled. This supports scenarios
such as keeping ventilation on longer after a tool has been deactivated.

Tested:
* Added unit tests for delayed off and reauth during delay timer. All
  tests pass
* Physical hardware: confirmed that previous config file (with no
  changes, no delay section) continues working as before (all outputs
  immediately turn off)
* Physical hardware: confirmed that outputs stay on during delay and
  turn off after delay (tested delays 10s, 180s)
* Physical hardware: confirmed that deauth and then reauth during the
  delay timer period leaves the device continuously on with no
  interruption

This commit was generated in part with Gemini 3.1 Pro.  Prompt:

```
Write a plan to add the ability to control the two outputs separately,
specifically keeping one output alive for a configurable duration after
the "off" behavior is triggered.

In two_button.ini the parameter `enable_output` currently toggles both
`Relay:ActiveHigh:29` and `Relay:ActiveHigh:31`.  The logic to read
these parameters is in  two_button.py

It is critical that all changes be backwards compatible - that is, after
the change, the old version of the config should trigger the same
behavior as today (trigger both outputs out and on at the same time).
There should be new syntax options that allow using this new behavior.

The code should handle the case where someone triggers an `abort` and
then triggers an `on_button_down` before the timer expires.  In this
case, the output should remain continuously on.

* Add a new optional parameter for how long to keep Relay:ActiveHigh:31
  after the service is disabled.  This duration should be specified in
  seconds.
  * In the `abort` function in two_button.py, instead of immediately
    turning all options off, if a delay >0 is configured, a timer should
    be started.  When the timer expires that output should be disabled
```
@brianbeck-google
Copy link
Copy Markdown
Author

This PR is significantly easier to review if diffed against a version of the codebase with the Linter run:

https://github.com/brianbeck-google/makerspace-auth/compare/lint...brianbeck-google:makerspace-auth:delayed-off?expand=1

As such I encourage reviewing and merging #60 prior to reviewing this change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant