Anrolosia / Shopping-List-with-Grocy

A Shopping list integration with Grocy for Home Assistant
MIT License
41 stars 1 forks source link

Grocy url access with name is not working #40

Closed Tugado closed 4 months ago

Tugado commented 4 months ago

I have grocy and Home Assistant in two containers. When I create the integration in home assistant, I get an invalid url error:

image

No error on home assistant logs so I believe it is a field validation, is it possible?

Inside Home Assistant Container its resolver the name correctly:

/config $ nslookup grocy Server: 127.0.0.11 Address: 127.0.0.11#53

Non-authoritative answer: Name: grocy Address: 172.20.0.22

If I try to create the integration with the ip, it works perfectly fine.

image image

The problem is that when I recreate the container for some reason, the fixed ip changes so I want to use name instead.

Anrolosia commented 4 months ago

Hello @Tugado ! So, yeah, there is a validation on the url, should be a domain, or localhost, or an ip as you can see here: https://github.com/Anrolosia/Shopping-List-with-Grocy/blob/fe8db054ddfe799ca9cb35846bacf2d86dc5a545/custom_components/shopping_list_with_grocy/config_flow.py#L200-L209

Could you play a bit with your HA container host_file to define a hostname which will redirect to your "grocy" container? like grocy.local grocy, or something like that?

Tugado commented 4 months ago

Thanks! With the fixed IP Addres in host_file did the trick:

/config # echo "grocy grocy.local" >> /etc/hosts /config # ping grocy.local ping: bad address 'grocy.local'

/config # echo "172.20.0.22 grocy.local" >> /etc/hosts /config # ping grocy.local -c1 PING grocy.local (172.20.0.22): 56 data bytes 64 bytes from 172.20.0.22: seq=0 ttl=64 time=1.193 ms

image

image

I'll seek to set up a definitive solution but it definitely works. Thanks for the help.

Anrolosia commented 4 months ago

Nice :) So you could automate the creation of the container to add that line with the new ip address in your hosts file. I will let the ticket here open if you need some help, let me know when we could close it. Thanks