[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Home Assistant Fusion UI #1185

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

joaovictor-local
Copy link
Contributor
@joaovictor-local joaovictor-local commented Jul 3, 2024

App Submission

App name

Home Assistant Fusion UI

256x256 SVG icon

logo

Gallery images

preview

@joaovictor-local joaovictor-local changed the title add fusion Add Home Assistant Fusion UI Jul 3, 2024
@joaovictor-local joaovictor-local marked this pull request as ready for review July 4, 2024 12:09
@marciasmedia
Copy link

Nice :)

@sharknoon
Copy link
Contributor

And here is another fantastic submission of @joaovictor-local 🎉 Thank you so much for your hard work on bringing new apps to umbrelOS!

I have some suggestions:

  • Maybe we can replace the UMBREL_LOCAL_IP with NETWORK_IP, as this environment variable will automatically be set by umbrelOS. See an example here. I know this is hard to find, because it isn't documented. If that turns out to be working, we can skip the exports.sh file altogether 😀
  • Consider adding the app_proxy infront of the application, as it enhances security by only redirecting HTTP traffic. Fusion UI probably has its own authentication, so you could disable the Proxy Authentication with PROXY_AUTH_ADD: "false"
  • Do we need network_mode: bridge? I always thought, this is the default, but I could be wrong

Great work on reducing the user permissions to 1000:1000!

@joaovictor-local
Copy link
Contributor Author
joaovictor-local commented Jul 5, 2024

@sharknoon Thank you @sharknoon :)

  1. I just tried but it didn't worked because NETWORK_IP returns the docker internal IP that is not accessible for the client browser, but we can use DEVICE_DOMAIN_NAME instead of exporting the network IP. I hope they add some new integration options, I am not a fan of oauth for this this scenario. The best implementation for me would be something that would allow us to only need auth_proxy.
image
ha-fusion usage oauth
  1. I also tried to use the app_proxy but it breaks the camera widget/object with 503 gateway time out, and I think it is because that would be the moment where ha-fusion should be using NETWORK_IP for it's internal request but it's not possible to define at the moment.
  app_proxy:
    environment:
      APP_HOST: home-assistant-fusion_web_1
      APP_PORT: 5050
      PROXY_AUTH_ADD: "false"
  1. You are right, it didn't. I will remove.

Co-authored-by: sharknoon <frank.josua@gmail.com>
@sharknoon
Copy link
Contributor

Thank you for your implementations 😀 If using the proxy causes connection issues, then I also think we do not need to use it. Especially because this app has it's own authentication.

Does your camera work now if you are using DEVICE_DOMAIN_NAME instead of your the ip address?

@nmfretz
Copy link
Contributor
nmfretz commented Aug 29, 2024

Nice work @joaovictor-local!

I just tested and we are almost there. @sharknoon was on the right track with using NETWORK_IP... suuuuuper close, but what we want here is GATEWAY_IP:

  • NETWORK_IP is the network/subnet identifier (e.g., 10.21.0.0) which used here is just specifying the start of the Docker network IP range.

  • GATEWAY_IP is the actual IP address of the Docker network’s gateway (e.g., 10.21.0.1), which is what we want.

I just tried but it didn't worked because NETWORK_IP returns the docker internal IP that is not accessible for the client browser, but we can use DEVICE_DOMAIN_NAME instead of exporting the network IP.

^ So for this, the browser isn't making a direct request to NETWORK_IP (or GATEWAY_IP in our case now). Instead it is making a request to something like http://umbrel.local:5023/api/.... The actual communication between fusion api and home-assistant will use the internal docker IP.


I've tested with HASS_URL: http://${GATEWAY_IP}:8123 by streaming a video file over HTTP from my laptop and connecting via Home Assistant:

image image

Can you please change the HASS_URL to HASS_URL: http://${GATEWAY_IP}:8123 and give it a test?

We'll get the gallery assets prepared in the meantime.

@nmfretz
Copy link
Contributor
nmfretz commented Sep 12, 2024

@joaovictor-local @sharknoon I'm actually wrong about GATEWAY_IP fixing our issue.
It does fix the camera issue, BUT it completely messes up the initial HA access request which occurs via the Browser and so must be umbrel.local:8123. I missed this when I was playing around, because I had already installed HA-Fusion and given it access to HA, so it never had to try this again.

HASS_URL is used for this:
http://umbrel.local:8123/auth/authorize?response_type=code&redirect_uri=<token>
image

If we use GATEWAY_IP then we the Browser tries to access http:/10.21.0.1:8123/auth/authorize?response_type=code&redirect_uri=<token> which obviously won't work.

Apologies for missing this @joaovictor-local, I see you were getting at something similar here: #1185 (comment)

So we're stuck using HASS_URL: http://${DEVICE_DOMAIN_NAME}:8123 but then have issues connecting to cameras:

Error occurred while trying to proxy: umbrel.local:5023/api/camera_proxy/camera.192_168_4_71?token=1baf2552af54b4c921d4ebc29b246122060e3265d12481fe73b4cb73d770c2de&date=1726039586464

Interestingly, I just tried testing this commit 98515b2 @joaovictor-local where you're using the local IP and the camera works using this, BUT unfortunately you have to be accessing HA-Fusion from <your-local-ip>:5023 for HA-Fusion to work at all. If you are accessing from http://umbrel.local:5023 then you'd be hit with CORS errors. This is an issue because the vast majority of people will be accessing HA-Fusion from http://umbrel.local:5023.

Copy link

🎉   Linting finished with no errors or warnings   🎉

Thank you for your submission! This is an automated linter that checks for common issues in pull requests to the Umbrel App Store.

Please review the linting results below and make any necessary changes to your submission.

Linting Results

Severity File Description
ℹ️ home-assistant-fusion-ui/docker-compose.yml External port mapping "5023:5050":
Port mappings may be unnecessary for the app to function correctly. Docker's internal DNS resolves container names to IP addresses within the same network. External access to the web interface is handled by the app_proxy container. Port mappings are only needed if external access is required to a port not proxied by the app_proxy, or if an app needs to expose multiple ports for its functionality (e.g., DHCP, DNS, P2P, etc.).

Legend

Symbol Description
Error: This must be resolved before this PR can be merged.
⚠️ Warning: This is highly encouraged to be resolved, but is not strictly mandatory.
ℹ️ Info: This is just for your information.

@nmfretz
Copy link
Contributor
nmfretz commented Sep 12, 2024

@sharknoon @joaovictor-local I managed to get it working. Can you please give it a test as well?

I pushed some changes to finalize the submission, but the main commit with the fix is 798dba6, which adds

extra_hosts:
      - "${DEVICE_DOMAIN_NAME}:${APP_HAFUSION_MACHINE_IP}"

This adds a hostname:ip mapping to the /etc/hosts file in the container and solves our issue.

I tested, and this solution works even when accessing HA-Fusion over Tailscale

@sharknoon
Copy link
Contributor

@nmfretz I have tested it on my Raspberry Pi and it works perfectly fine :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants