FrancescoM
(Francesco)
November 25, 2021, 1:05pm
1
Hi
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.
Thanks
VDRainer
(🍻)
November 25, 2021, 5:43pm
2
Just out of interest:
Why are you creating a new venv after activating it?
FrancescoM
(Francesco)
November 26, 2021, 2:20pm
3
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.
VDRainer
(🍻)
November 26, 2021, 9:00pm
4
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.
Dolores
November 27, 2021, 1:35am
5
feel free to ignore if you are set on your path, but… why?
Thanks,
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 = requests.post(url, data=data, headers=headers)
if r.status_code != 200 and r.status_code != 201:
errors = errors + 'ERROR:' + str(r.status_code)
if errors != '':
print(errors)
1 Like
FrancescoM
(Francesco)
December 7, 2021, 12:42pm
9
In the authorization camp I have to put my admin credential?
VDRainer
(🍻)
December 7, 2021, 4:14pm
10
No, go to your user profile and create a Long-Lived Access Token.
headers = {
'Authorization': 'Bearer <paste the token here>',
'content-type': 'application/json'
}
Dolores
December 14, 2021, 2:23am
11
would this new feature help you at all? I saw it in the release notes and thought of you.