Closed jaymemaurice closed 11 months ago
I haven't tested any recent version of the add-on on Home Assistant Supervised, so I don't know if it goes wrong there.
This is the script that's being run, so it's not a lot where it can go wrong. If you were to run the following in your terminal...
` readarray -t eth_adapters < <(ifconfig -a | grep -oE '^(enp|eth|eno|wl)[a-z0-9]+')
for adapter in "${eth_adapters[@]}"
do
ipaddr=$(ifconfig "$adapter" | grep 'inet addr' | cut -d: -f2 | awk '{print $1}')
if [ -n "$ipaddr" ]; then
break
fi
done
`
Would there be any faults in that? In init-interface there is a similar sort of script running, so I doubt there would be an issue in this part...
Well... ifconfig has been deprecated long ago... I had to manually install net tools in ubuntu and step through it, it doesn't work.
root@ha01:~# readarray -t eth_adapters < <(ifconfig -a | grep -oE '^(enp|eth|eno|wl)[a-z0-9]+')
root@ha01:~# echo $eth_adapters
enp0s31f6
root@ha01:~# for adapter in "${eth_adapters[@]}"
> do
> ipaddr=$(ifconfig "$adapter" | grep 'inet addr' | cut -d: -f2 | awk '{print $1}'); echo $ipaddr
> if [ -n "$ipaddr" ]; then
> break
> fi
> done
root@ha01:~#
root@ha01:~# ifconfig "enp0s31f6"
enp0s31f6: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
ether 6c:4b:90:50:b1:7d txqueuelen 1000 (Ethernet)
RX packets 210345061 bytes 55969262234 (52.1 GiB)
RX errors 0 dropped 263731 overruns 0 frame 0
TX packets 149523968 bytes 28796360663 (26.8 GiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 16 memory 0xf7200000-f7220000
root@ha01:~# ifconfig|grep -B 1 192\.168\.2
virbr1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.2.45 netmask 255.255.255.0 broadcast 192.168.2.255
--
wlp2s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.254.100 netmask 255.255.255.0 broadcast 192.168.254.255
root@ha01:~#
So it seems that on my home assistant supervised the virbr1 is my main interface. Not sure this is because I am also running KVM or if that's normal for supervised. If I modify your grep adding virbr... it still doesn't work the way you would expect it to since the grep for inet addr
never matches.
root@ha01:~# ifconfig -a | grep -oE '^(enp|eth|eno|wl|virbr)[a-z0-9]+'
enp0s31f6
virbr1
wlp2s0
root@ha01:~# readarray -t eth_adapters < <(ifconfig -a | grep -oE '^(enp|eth|eno|wl|virbr)[a-z0-9]+'); echo $eth_adapters
enp0s31f6
root@ha01:~# readarray -t eth_adapters < <(ifconfig -a | grep -oE '^(enp|eth|eno|wl|virbr)[a-z0-9]+'); echo ${eth_adapters[1]}
virbr1
root@ha01:~# for adapter in "${eth_adapters[@]}"; do ipaddr=$(ifconfig "$adapter" | grep 'inet addr' | cut -d: -f2 | awk '{print $1}');echo $ipaddr; if [ -n "$ipaddr" ]; then break; fi; done
root@ha01:~# ifconfig virbr1|grep 'inet addr'
root@ha01:~# ifconfig virbr1
virbr1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.2.45 netmask 255.255.255.0 broadcast 192.168.2.255
ether a2:5a:13:b7:61:ff txqueuelen 1000 (Ethernet)
RX packets 199724224 bytes 50312714626 (46.8 GiB)
RX errors 0 dropped 273 overruns 0 frame 0
TX packets 148624609 bytes 27973999783 (26.0 GiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0```
root@ha01:~# for adapter in "${eth_adapters[1]}"; do ipaddr=$(ifconfig "$adapter" | grep 'inet' | cut -d: -f2 | awk '{print $2}');echo $ipaddr; if [ -n "$ipaddr" ]; then break; fi; done
192.168.2.45
so ditching ifconfig which must be different on different hosts, the fixed command:
root@ha01:~# for adapter in "${eth_adapters[@]}"; do ipaddr=$(ip addr show dev "$adapter" scope global| awk '/inet/{gsub(/\/.*/,"",$2); print $2}');echo $ipaddr; if [ -n "$ipaddr" ]; then break; fi; done
192.168.2.45
I'm not sure what the point of all this is.... like why is it limiting the interface types?
I'm not sure what the point of all this is.... like why is it limiting the interface types?
I've edited part of some code in init-interface to automatically find the LAN connection to the device with this. Most people don't like configuring their add-on or aren't tech savvy. It shouldn't automatically grab your wireless network or internal Home Assistant IP's. Ifconfig is installed with Home Assistant OS, so it generally isn't an issue.
What the purpose of this part is, is basically trying to get the IP it detected in the other service to make an exception in NGINX so it allows access from that IP address. Basically I could remove all security so it can be accessed from anywhere, but I don't think that's preferable.
What I'd like to do is change it so it makes a list of all local IP's and allows access to those. Something like ip_addresses=$(ip address show | grep 'inet ' | awk '{print $2}') should work for you as well then.
I am not proficient in Bash, so feel free to make suggestions! Surely, we can make it work eventually.
try hostname -I
root@ha01:~# hostname -I
192.168.254.100 192.168.2.45 172.17.0.1 172.30.32.1
and if you want to use | grep "something" | awk "{}" try | awk '/something/{}' instead and save your forks for a cake
and if you want to use | grep "something" | awk "{}" try | awk '/something/{}' instead and save your forks for a cake
Feel free to keep the sass at home. hostname -I doesn't work om HA OS, so it's not an option. I'll take a look at it next week.
But I’m selling t-shirts here:) Thanks for all the work you do.
On Fri, Dec 8, 2023 at 10:49 AM Bepacom B.V. Raalte < @.***> wrote:
and if you want to use | grep "something" | awk "{}" try | awk '/something/{}' instead and save your forks for a cake
Feel free to keep the sass at home. hostname -I doesn't work om HA OS, so it's not an option. I'll take a look at it next week.
— Reply to this email directly, view it on GitHub https://github.com/Bepacom-Raalte/bepacom-HA-Addons/issues/29#issuecomment-1847416305, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJIX5V7DNHPFKTYTK3AGX33YIMZI7AVCNFSM6AAAAABAMFCRSGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNBXGQYTMMZQGU . You are receiving this because you authored the thread.Message ID: @.***>
Try the latest dev version, see if it works now.
It started!
I'll let you know how I get on with it. I am currently using node red in my house to bridge the delta bas to my home assistant. I am interested in this addon for CoV subscription instead of the tight polling I am currently doing.
On Mon, Dec 11, 2023 at 1:51 AM Bepacom B.V. Raalte < @.***> wrote:
Try the latest dev version, see if it works now.
— Reply to this email directly, view it on GitHub https://github.com/Bepacom-Raalte/bepacom-HA-Addons/issues/29#issuecomment-1849426595, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJIX5V5YHCMZYDWDLO73UX3YI2UQBAVCNFSM6AAAAABAMFCRSGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNBZGQZDMNJZGU . You are receiving this because you authored the thread.Message ID: @.***>
Great to hear! Let me know if there are any more issues.
Nginx seems to start when launching from docker run but seems to be unhappy when starting through my supervised home assistant:
Add-on version: 1.1.4 You are running the latest version of this add-on. System: Debian GNU/Linux 11 (bullseye) (amd64 / qemux86-64) Home Assistant Core: 2023.11.3 Home Assistant Supervisor: 2023.11.6 cat /etc/debian_version 11.8
I cannot figure out how to increase the logging to be of any help.
Here are the logs from starting from the addon...
More version info: Core 2023.11.3 Supervisor 2023.11.6 Frontend 20231030.2
Here is trying to start it manually