Remove duplicated options handling in SimpliSafe (#41806)

* Remove duplicated options handling in SimpliSafe

* Incorrect property name
This commit is contained in:
Aaron Bach 2020-10-15 10:36:04 -06:00 committed by GitHub
parent 368bc0c34b
commit db7c16162d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 18 deletions

View file

@ -119,11 +119,11 @@ class SimpliSafeAlarm(SimpliSafeEntity, AlarmControlPanelEntity):
@property
def code_format(self):
"""Return one or more digits/characters."""
if not self._simplisafe.options.get(CONF_CODE):
if not self._simplisafe.config_entry.options.get(CONF_CODE):
return None
if isinstance(self._simplisafe.options[CONF_CODE], str) and re.search(
"^\\d+$", self._simplisafe.options[CONF_CODE]
):
if isinstance(
self._simplisafe.config_entry.options[CONF_CODE], str
) and re.search("^\\d+$", self._simplisafe.config_entry.options[CONF_CODE]):
return FORMAT_NUMBER
return FORMAT_TEXT
@ -140,10 +140,10 @@ class SimpliSafeAlarm(SimpliSafeEntity, AlarmControlPanelEntity):
@callback
def _is_code_valid(self, code, state):
"""Validate that a code matches the required one."""
if not self._simplisafe.options.get(CONF_CODE):
if not self._simplisafe.config_entry.options.get(CONF_CODE):
return True
if not code or code != self._simplisafe.options[CONF_CODE]:
if not code or code != self._simplisafe.config_entry.options[CONF_CODE]:
LOGGER.warning(
"Incorrect alarm code entered (target state: %s): %s", state, code
)