You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using the latest version of Alarmo (latest version can be found here)
I checked for similar existing requests (both open and closed) before posting.
Alarmo Version
v1.10.7
HA Version
2024.11.3
Bug description
Calls to alarmo.disarm can take several seconds if there are multiple codes/users defined. I'm seeing ~6s for 13 users/codes.
How long it takes depends on which user's code is being checked.
I suspect this is because this code checks users in sequence. If the supplied code belongs to a user that's far down in the list (depending on order in which they were added?), a lot of bcrypt.checkpw() iterations are performed sequentially, which can be slow especially if running on an RPi.
Perhaps something like this could work?
def async_authenticate_user(self, code: str, user_id: str = None):
users = ...
def check_pw(user):
if not user[const.ATTR_ENABLED]:
continue
elif not user[ATTR_CODE] and not code:
return user
if bcrypt.checkpw(code.encode("utf-8"), base64.b64decode(user[ATTR_CODE]):
return user
with multiprocessing.Pool() as p:
for user in p.imap(check_pw, users.itervalues()):
if user: return user
return
Checklist
Alarmo Version
v1.10.7
HA Version
2024.11.3
Bug description
Calls to
alarmo.disarm
can take several seconds if there are multiple codes/users defined. I'm seeing ~6s for 13 users/codes.How long it takes depends on which user's code is being checked.
I suspect this is because this code checks users in sequence. If the supplied code belongs to a user that's far down in the list (depending on order in which they were added?), a lot of
bcrypt.checkpw()
iterations are performed sequentially, which can be slow especially if running on an RPi.Perhaps something like this could work?
Similar report
Steps to reproduce
Relevant log output
No response
The text was updated successfully, but these errors were encountered: