Automatc Change password


I’m tring to create a script to automatic change the users password.
I have a venv installation of Home Assistant Core (On Raspbian):

Actually my script is:

sudo -u homeassistant -H -s
cd /srv/homeassistant/
source bin/activate
python3 -m -venv .
hass --script auth change_password "username" "new_pw"

This works fine, but i always need to restart home assistant to make change effective.

Is there a way to not restart home assistant?
Maybe with an other script to reload the “login infos”?
I think that it could be possible becouse when i change an user password with HomeAssistant GUI i don’t have to restart nothing.


Just out of interest:
Why are you creating a new venv after activating it?

Sorry, i’m not an expert
But also not typing the command
python3 -m -venv .
the problem is the same, I need to restart the server.

Have you tried the person.reload service?

If you change the YAML, you can reload it by calling the person.reload service.

No clue if that helps.

feel free to ignore if you are set on your path, but… why?


But how can i call this service via Command Line?

I need to let people log in only for a limited time.

So i want to change the password when the time is finished

1 Like

Via Rest API.
For example with a python script:

import requests

url = 'http://localhost:8123/api/services/person/reload'

headers = {
    'Authorization': 'Bearer abcdefgh',
    'content-type': 'application/json'

data = '{}'
errors = ''

r =, data=data, headers=headers)
if r.status_code != 200 and r.status_code != 201:
    errors = errors + 'ERROR:' + str(r.status_code)

if errors != '':
1 Like

In the authorization camp I have to put my admin credential?

No, go to your user profile and create a Long-Lived Access Token.

headers = {
    'Authorization': 'Bearer <paste the token here>',
    'content-type': 'application/json'

would this new feature help you at all? I saw it in the release notes and thought of you.