Skip to content

Commit

Permalink
No numeric keypad when code contains asterisk
Browse files Browse the repository at this point in the history
  • Loading branch information
kukulich committed Jan 6, 2021
1 parent 08faf91 commit 836045a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 5 additions & 1 deletion custom_components/jablotron100/alarm_control_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from homeassistant.components.alarm_control_panel import (
AlarmControlPanelEntity,
FORMAT_NUMBER,
FORMAT_TEXT,
SUPPORT_ALARM_ARM_AWAY,
SUPPORT_ALARM_ARM_NIGHT,
)
Expand Down Expand Up @@ -45,7 +46,10 @@ def code_format(self) -> Optional[str]:
else:
code_required = self._jablotron.is_code_required_for_disarm()

return FORMAT_NUMBER if code_required is True else None
if not code_required:
return None

return FORMAT_TEXT if self._jablotron.code_contains_asterisk() is True else FORMAT_NUMBER

@property
def supported_features(self) -> int:
Expand Down
3 changes: 3 additions & 0 deletions custom_components/jablotron100/jablotron.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,9 @@ def is_code_required_for_disarm(self) -> bool:
def is_code_required_for_arm(self) -> bool:
return self._options.get(CONF_REQUIRE_CODE_TO_ARM, DEFAULT_CONF_REQUIRE_CODE_TO_ARM)

def code_contains_asterisk(self) -> bool:
return self._config[CONF_PASSWORD].find("*") != -1

async def initialize(self) -> None:
def shutdown_event(_):
self.shutdown()
Expand Down

0 comments on commit 836045a

Please sign in to comment.