How to programmatically change a user's password

Hello. My task is: to temporarily grant access to home assistant for one user, for example for 1 day. After that, the user should lose his right to enter the XA website.
As an idea, I think, is it possible to generate new passwords for this user every day? I want to transfer passwords via API from CRM. Or are there other ways to implement this?