Skip to content

Commit

Permalink
Merge pull request #135 from tykeal/larger_pins
Browse files Browse the repository at this point in the history
Refactor: Cleanup random code generation
  • Loading branch information
tykeal authored Oct 4, 2022
2 parents f73b957 + 97064c9 commit 4dd8cb3
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions custom_components/rental_control/sensors/calsensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,7 @@ def _generate_door_code(self) -> str:
elif generator == "static_random":
# If the description changes this will most likely change the code
random.seed(self._event_attributes["description"])
max_l = []
i = 0
while i < code_length:
max_l.append("9")
i += 1
max_range = int("".join(max_l))
max_range = int("9999".rjust(code_length, "9"))
ret = str(random.randrange(1, max_range, code_length)).zfill(code_length)

if ret is None:
Expand Down

0 comments on commit 4dd8cb3

Please sign in to comment.