Skip to content

Commit

Permalink
Added siren sound settings.
Browse files Browse the repository at this point in the history
  • Loading branch information
MisterWil committed Aug 21, 2017
1 parent cc4e152 commit e19ff5c
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 20 deletions.
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ Changelog

A list of changes between each release.

0.7.1 (2017-08-21)
^^^^^^^^^^^^^^^^^^
- Added siren settings for Issue #1

0.7.0 (2017-08-21)
^^^^^^^^^^^^^^^^^^
- Wrote tests for setting changes
Expand Down
8 changes: 6 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,12 @@ You can change settings with abodepy either using abode.set_setting(setting, val
+-----------------------+-----------------------------------------------------------------------------+
| final_beep | 0, 3, 4, 5, 6, 7, 8, 9, 10 |
+-----------------------+-----------------------------------------------------------------------------+


| entry | (Siren) 0 for disabled, 1 for enabled |
+-----------------------+-----------------------------------------------------------------------------+
| tamper | (Siren) 0 for disabled, 1 for enabled |
+-----------------------+-----------------------------------------------------------------------------+
| confirm | (Siren) 0 for disabled, 1 for enabled |
+-----------------------+-----------------------------------------------------------------------------+

Development and Testing
=======================
Expand Down
13 changes: 13 additions & 0 deletions abodepy.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@ def set_setting(self, setting, value, area='1', validate_value=True):
elif setting in CONST.SOUND_SETTINGS:
url = CONST.SOUNDS_URL
data = self._sound_settings(area, setting, value, validate_value)
elif setting in CONST.SIREN_SETTINGS:
url = CONST.SIREN_URL
data = self._siren_settings(setting, value, validate_value)

return self.send_request(method="put", url=url, data=data)

Expand Down Expand Up @@ -259,6 +262,16 @@ def _sound_settings(area, setting, value, validate_value):

return {'area': area, setting: value}

@staticmethod
def _siren_settings(setting, value, validate_value):
"""Will validate siren settings and values, returns data packet."""
if validate_value:
if value not in CONST.SETTING_DISABLE_ENABLE:
raise AbodeException(ERROR.INVALID_SETTING_VALUE,
CONST.SETTING_DISABLE_ENABLE)

return {'action': setting, 'option': value}

def send_request(self, method, url, headers=None,
data=None, is_retry=False):
"""Send requests to Abode."""
Expand Down
57 changes: 39 additions & 18 deletions helpers/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

MAJOR_VERSION = 0
MINOR_VERSION = 7
PATCH_VERSION = '0'
PATCH_VERSION = '1'

__version__ = '{}.{}.{}'.format(MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION)

Expand Down Expand Up @@ -138,11 +138,19 @@ def PANEL_MODE_URL(area, mode):
SETTING_FINAL_BEEPS = 'final_beep'

SOUND_SETTINGS = [SETTING_DOOR_CHIME, SETTING_WARNING_BEEP,
SETTING_ENTRY_BEEP_AWAY, SETTING_EXIT_BEEP_AWAY, SETTING_ENTRY_BEEP_HOME,
SETTING_EXIT_BEEP_HOME, SETTING_CONFIRM_SOUND, SETTING_ALARM_LENGTH,
SETTING_ENTRY_BEEP_AWAY, SETTING_EXIT_BEEP_AWAY,
SETTING_ENTRY_BEEP_HOME, SETTING_EXIT_BEEP_HOME,
SETTING_CONFIRM_SOUND, SETTING_ALARM_LENGTH,
SETTING_FINAL_BEEPS]

ALL_SETTINGS = PANEL_SETTINGS + AREA_SETTINGS + SOUND_SETTINGS
SETTING_SIREN_ENTRY_EXIT_SOUNDS = "entry"
SETTING_SIREN_TAMPER_SOUNDS = "tamper"
SETTING_SIREN_CONFIRM_SOUNDS = "confirm"

SIREN_SETTINGS = [SETTING_SIREN_ENTRY_EXIT_SOUNDS, SETTING_SIREN_TAMPER_SOUNDS,
SETTING_SIREN_CONFIRM_SOUNDS]

ALL_SETTINGS = PANEL_SETTINGS + AREA_SETTINGS + SOUND_SETTINGS + SIREN_SETTINGS

'''
SETTING VALUES
Expand All @@ -169,14 +177,19 @@ def PANEL_MODE_URL(area, mode):
SETTING_ENTRY_EXIT_DELAY_4MIN = '240'

ALL_SETTING_ENTRY_EXIT_DELAY = [SETTING_ENTRY_EXIT_DELAY_DISABLE,
SETTING_ENTRY_EXIT_DELAY_10SEC, SETTING_ENTRY_EXIT_DELAY_20SEC,
SETTING_ENTRY_EXIT_DELAY_30SEC, SETTING_ENTRY_EXIT_DELAY_1MIN,
SETTING_ENTRY_EXIT_DELAY_2MIN, SETTING_ENTRY_EXIT_DELAY_3MIN,
SETTING_ENTRY_EXIT_DELAY_10SEC,
SETTING_ENTRY_EXIT_DELAY_20SEC,
SETTING_ENTRY_EXIT_DELAY_30SEC,
SETTING_ENTRY_EXIT_DELAY_1MIN,
SETTING_ENTRY_EXIT_DELAY_2MIN,
SETTING_ENTRY_EXIT_DELAY_3MIN,
SETTING_ENTRY_EXIT_DELAY_4MIN]

VALID_SETTING_EXIT_AWAY = [SETTING_ENTRY_EXIT_DELAY_30SEC,
SETTING_ENTRY_EXIT_DELAY_1MIN, SETTING_ENTRY_EXIT_DELAY_2MIN,
SETTING_ENTRY_EXIT_DELAY_3MIN, SETTING_ENTRY_EXIT_DELAY_4MIN]
SETTING_ENTRY_EXIT_DELAY_1MIN,
SETTING_ENTRY_EXIT_DELAY_2MIN,
SETTING_ENTRY_EXIT_DELAY_3MIN,
SETTING_ENTRY_EXIT_DELAY_4MIN]

SETTING_SOUND_OFF = 'none'
SETTING_SOUND_LOW = 'normal'
Expand All @@ -185,8 +198,9 @@ def PANEL_MODE_URL(area, mode):
ALL_SETTING_SOUND = [SETTING_SOUND_OFF, SETTING_SOUND_LOW, SETTING_SOUND_HIGH]

VALID_SOUND_SETTINGS = [SETTING_DOOR_CHIME, SETTING_WARNING_BEEP,
SETTING_ENTRY_BEEP_AWAY, SETTING_EXIT_BEEP_AWAY, SETTING_ENTRY_BEEP_HOME,
SETTING_EXIT_BEEP_HOME, SETTING_CONFIRM_SOUND]
SETTING_ENTRY_BEEP_AWAY, SETTING_EXIT_BEEP_AWAY,
SETTING_ENTRY_BEEP_HOME, SETTING_EXIT_BEEP_HOME,
SETTING_CONFIRM_SOUND]

SETTING_ALARM_LENGTH_DISABLE = '0'
SETTING_ALARM_LENGTH_1MIN = '60'
Expand All @@ -206,13 +220,20 @@ def PANEL_MODE_URL(area, mode):
SETTING_ALARM_LENGTH_15MIN = '900'

ALL_SETTING_ALARM_LENGTH = [SETTING_ALARM_LENGTH_DISABLE,
SETTING_ALARM_LENGTH_1MIN, SETTING_ALARM_LENGTH_2MIN,
SETTING_ALARM_LENGTH_3MIN, SETTING_ALARM_LENGTH_4MIN,
SETTING_ALARM_LENGTH_5MIN, SETTING_ALARM_LENGTH_6MIN,
SETTING_ALARM_LENGTH_7MIN, SETTING_ALARM_LENGTH_8MIN,
SETTING_ALARM_LENGTH_9MIN, SETTING_ALARM_LENGTH_10MIN,
SETTING_ALARM_LENGTH_11MIN, SETTING_ALARM_LENGTH_12MIN,
SETTING_ALARM_LENGTH_13MIN, SETTING_ALARM_LENGTH_14MIN,
SETTING_ALARM_LENGTH_1MIN,
SETTING_ALARM_LENGTH_2MIN,
SETTING_ALARM_LENGTH_3MIN,
SETTING_ALARM_LENGTH_4MIN,
SETTING_ALARM_LENGTH_5MIN,
SETTING_ALARM_LENGTH_6MIN,
SETTING_ALARM_LENGTH_7MIN,
SETTING_ALARM_LENGTH_8MIN,
SETTING_ALARM_LENGTH_9MIN,
SETTING_ALARM_LENGTH_10MIN,
SETTING_ALARM_LENGTH_11MIN,
SETTING_ALARM_LENGTH_12MIN,
SETTING_ALARM_LENGTH_13MIN,
SETTING_ALARM_LENGTH_14MIN,
SETTING_ALARM_LENGTH_15MIN]

SETTING_FINAL_BEEPS_DISABLE = '0'
Expand Down
34 changes: 34 additions & 0 deletions tests/test_abode_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,3 +357,37 @@ def tests_sound_settings(self, m):
with self.assertRaises(abodepy.AbodeException):
self.abode.set_setting(const.SETTING_FINAL_BEEPS,
"foobar")

@requests_mock.mock()
def tests_siren_settings(self, m):
"""Check that device panel siren settings are working."""
m.post(const.LOGIN_URL, text=mresp.login_response())
m.post(const.LOGOUT_URL, text=mresp.LOGOUT_RESPONSE)
m.get(const.SETTINGS_URL, text=mdev.door_contact_device())
m.get(const.PANEL_URL, text=mresp.panel_response())
m.put(const.SIREN_URL, text=mresp.SETTINGS_OK_RESPONSE)

try:
self.abode.set_setting(const.SETTING_SIREN_ENTRY_EXIT_SOUNDS,
const.SETTING_ENABLE)

self.abode.set_setting(const.SETTING_SIREN_CONFIRM_SOUNDS,
const.SETTING_ENABLE)

self.abode.set_setting(const.SETTING_SIREN_TAMPER_SOUNDS,
const.SETTING_ENABLE)

except abodepy.AbodeException:
self.fail("set_setting() raised AbodeException unexpectedly")

with self.assertRaises(abodepy.AbodeException):
self.abode.set_setting(const.SETTING_SIREN_ENTRY_EXIT_SOUNDS,
"foobar")

with self.assertRaises(abodepy.AbodeException):
self.abode.set_setting(const.SETTING_SIREN_CONFIRM_SOUNDS,
"foobar")

with self.assertRaises(abodepy.AbodeException):
self.abode.set_setting(const.SETTING_SIREN_TAMPER_SOUNDS,
"foobar")

0 comments on commit e19ff5c

Please sign in to comment.