Netatmo Health Home Coach Refresh token

Hi everyone,

I’ve been trying to integrate Netatmo Health Home Coach onto Home Assistant. I followed the instructions from Home Assistant website as well as the solution posted here:
https://community.home-assistant.io/t/no-support-for-netatmo-healthy-home-coach/25401/2

I have managed to display Netatmo data on my home assistant. Since the access token for Netatmo server expires every 3 hours, I have written a python script to request a new token together with an automation file(which you can check in the link above) to execute the python script every 3 hours.

However, I do not know how to read the new access token and write into my configuration.yaml file.

My refresh token code:

import requests

payload = {‘grant_type’: ‘refresh_token’,
‘refresh_token’: ‘my_refresh_token’,
‘client_id’:“my_id”,
‘client_secret’: “my_client_secret”,
‘scope’: ‘read_homecoach’}
try:
response = requests.post(“https://api.netatmo.com/oauth2/token”, data=payload)
response.raise_for_status()
access_token=response.json()[“access_token”]
print(“Your access token is:”, access_token)
except requests.exceptions.HTTPError as error:
print(error.response.status_code, error.response.text)

Thank you!