I have setup a custom API that I host on my local network but I cannot seem to get any data back from that call. I have created an entry on my rpi : /etc/hosts so that I can call the api like: http://solar.local/. When I try a curl from the terminal of home assistant http://solar.local a json is returned:
I have turned on level debug and I see updating from solar.local but no data fetched…
What can be the reason for not getting any data from a very simple rest request?
I can add that no traffic is hitting my API since I log all requests, it seems like the rest requests cannot reach my local api for some reason.
I cannot see any errors in the log soI guess that something in the home assistant environment is blocking requests to my lan. I guess running curl from my raspberry is not enough to test if I can reach my API.
I use the home assistant raspberry pi 4 image when I installed quite awhile ago…
Hi, thanks for helping out !
I already have the resource: http://solar.local, just could not include in the message since it was
interpreted as links which I was not allowed to add since being new in the forum.
I cannot see any calls to my API either so the request does not reach my API for some reason.
The strange thing is that I can curl using the Terminal add on in HA, that works fine…
I actually tried to setup a docker container temporarily with just the rest and there it works like
expected o nothing seems to be wrong with the call (it is a very simple call).
I just needed to add a hostname to /etc/hosts all worked in the docker container.
I wonder why this doesn’t work in the RPI 4 installation ?
Please paste the entire code you’re now using. If the forum still restricts you from doing this, post a screenshot of it. Have you now removed the IP test sensor? I note that you left the “External IP” name in your new sensor, which might cause issues if you have two with the same name.
I have now exposed the same API on the internet using ngrok and by using an address on the internet the exakt same API works.
I can curl the API curl http://solar.local using the terminal addon in ha, but it seems like the context where the platform: rest is requesting the url does not reach my API on my lan for some reason.
Do I need to whitelist lan-ipaddresses, strange since exposing the same api on the internet makes it work?
Have anybody seen this behaviour before?
Hello, thanks.
I have tried to use both lan ip and /etc/hosts entry all works using curl but it does not reach the api
when requested via the platform: rest integration.
Should the request work if I can curl the address using the terminal add on in homeassistant OS?
Or ssh into the rpi4 and using curl http://solar.local which works.
The api call works fine if I host the same api on the internet using ngrok.com so
the parsing of the result works as well.
The problem is to reach the API on my lan from the rest platform.
I do not know if the platform rest runs in another context compared to a curl on my RPI4-server (ss)?
I have read up a bit more on the Home assistant OS installation on my RPI4 and it seems like the problem is not the configuration in HA or the API but the local name resolution.
Can this be due to the coreDNS of Home Assistant OS that is preventing access to my local lan resources? I suspect that the Platform: rest is running in a context where my local resources cannot be reached…
hello all!
Solved this myself, it was related to dns resolution and mDNS .local address that messed everything up…
Everything is now working like it should when it comes to API rest calls so the problem was not configuration of the ha configuration or my API but rather network related…
I installed a local dns-server to properly manage dns-names…
I cannot use an ipaddress since my API is hosted in a Kubernetes kluster with an ingress that expects a hostname and not an ip.
Maybe a bit over the top but I am also learning how to setup a proper Kubernetes infra…