Hey everyone!
I’ve been using Facebook profile images for some time as the profile images of the persons in my HomeAssistant setup. Since last month (September 2020) there is a new API for retrieving this. Before this you could just use a simple URL that includes the facebook profile id. Now you need to create an App on the Facebook developer website, retrieve an access key and finally do a GET request (with the person id and the access key) to get the URL to the profile image I want.
The request is URL is like this: https://graph.facebook.com/{graph_api_version, I use: v8.0}/{person_id}/picture?type=large&redirect=false&access_token={access_token}
This returns the following JSON string:
{
"data": {
"height": 320,
"is_silhouette": false,
"url": "{Direct_URL_to_Profile_image}",
"width": 321
}
}
The url property is this string contains the direct url to the image file. I have the feeling this URL changes over time so therefore I would like to extract this url (automatically) and use it in the customize.yaml file as follows:
person.pieter_jan_buntinx:
entity_picture: {facebook_PF_URL}
I’ve looked into using templates for this, using the from_json
filter would definitely work. But I have not found out how I can retrieve this JSON message from an URL. Does anybody have any experience doing this?
Many thanks,
Pieter-Jan