Skip to content

Commit

Permalink
Added toggle support
Browse files Browse the repository at this point in the history
  • Loading branch information
gagath committed Jun 3, 2017
1 parent 1cde4d5 commit 1b783a2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ This project adheres to `Semantic Versioning <http://semver.org/>`__.
[Unreleased]
------------

- Added support for toggle command

[2.0] - 2017-05-08
------------------

Expand Down
8 changes: 6 additions & 2 deletions hms_spacestatus/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from hms_spacestatus.spaceapi import SpaceApi


CHANGE_STATUS_COMMANDS = ['open', 'open_silent', 'close', 'close_silent']
CHANGE_STATUS_COMMANDS = ['open', 'open_silent', 'close', 'close_silent', 'toggle', 'toggle_silent']


def get_logger():
Expand Down Expand Up @@ -75,7 +75,11 @@ def query_closure(client, topic, dct):

elif command in CHANGE_STATUS_COMMANDS:
# Check what the user wants to do
will_open = command.startswith('open')
if command.startswith('toggle'):
will_open = not spacestatus.read_state()
else:
will_open = command.startswith('open')

different_state = will_open != spacestatus.read_state()

# Set the internal state and external with bugged SpaceApi
Expand Down

0 comments on commit 1b783a2

Please sign in to comment.