I want to implement some functions of HA.
And I can call the Restful API via python, but I need some advanced functions.
So I try to call the supervisor API via python and curl like below:
requests.exceptions.ConnectionError: HTTPConnectionPool(host='supervisor', port=80): Max retries exceeded with url: /core/api (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fb372011280>: Failed to establish a new connection: [Errno -2] Name or service not known'))
The error of curl will return:
curl: (6) Could not resolve host: supervisor
I follow the document Home Assistant Core and Supervisor API Access
I have already installed Home Assistant Supervised and get the supervisor token, but if I add either of “homeassistant_api: true” or “hassio_api: true” in configuration.yaml - the configuration will checker fails.
Any help would be appreciated! It seems like there are some steps that I’m missing to enable the Supervisor API to be called.
There is something being served by port 80 in the supervisor container:
nmap supervisor
Starting Nmap 7.92 ( https://nmap.org ) at 2022-09-06 18:00 NZST
Nmap scan report for supervisor (172.30.32.2)
Host is up (0.000016s latency).
rDNS record for 172.30.32.2: hassio
Not shown: 999 closed tcp ports (reset)
PORT STATE SERVICE
80/tcp open http
MAC Address: 02:42:AC:1E:20:02 (Unknown)
Yes, I can use Supervisor API via SSH, but I want to expose its API externally and using python to call it, so I use remote API addon to get supervisor token and try to call it by using curl for the test, if it can work, then I can develop my own add-on in next step, then I can implement my project. According to this dev say in here temporarily expose its API externally on a dev system like Then it will listen on a port on the host and proxy requests made through it to the supervisor API., it seems like it can work, but I stuck here…
It have to install remote API addon, follow the step below this document.
And this add-on must based on Home Assistant Supervised rather Home Assistant Container
It works!
So it has to use the IP of hassio without the port,
I’m an idiot to use the IP of docker and add the port to it.
You’re really something! Thank you for your help.
I have no idea whether it will change or not when the home-assistant restart or reinstall, maybe I can extract IP by bash to avoid the inconsistency when I need to call API. I think the big problem for me is how to get the supervisor token by myself without the remote API addon.