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

Broken camera if not an absolute path #363

Closed
Hawk84r opened this issue Jul 3, 2024 · 16 comments
Closed

Broken camera if not an absolute path #363

Hawk84r opened this issue Jul 3, 2024 · 16 comments
Assignees
Labels
bug Something isn't working enhancement New feature or request

Comments

@Hawk84r
Copy link

Hawk84r commented Jul 3, 2024

Creality K1, rooted (using Fluidd mostly), Helper script, 2 cameras

When cameras are defined as relative path, like "/webcam/?action=stream" integration defaults url to http://{url}/webcam/?action=stream which doesn't make any sense for K1 as it has default UI at :80 and cameras, configured in moonraker would not make a valid path for default web server. You can remove it via helper script, but most don't. I prefer to make only necessary modifications for one.
It is fixed by:

  1. adding CONF_PORT to from .const import
  2. changing line 103 of camera.py from self.url = f"http://{config_entry.data.get(CONF_URL)}" to self.url = f"http://{config_entry.data.get(CONF_URL)}:{config_entry.data.get(CONF_PORT)}"
  3. changing line 128 from self.url = config_entry.data.get(CONF_URL) to self.url = config_entry.data.get(CONF_URL) + ":" + config_entry.data.get(CONF_PORT)
    home-assistant_2024-07-03T06-39-19.112Z.log
@marcolivierarsenault
Copy link
Owner

that is a nice fix, I will give it a try. Not much bandwith to work on the integration just now, but will eventually take a look

@marcolivierarsenault marcolivierarsenault added bug Something isn't working enhancement New feature or request labels Jul 13, 2024
@marcolivierarsenault
Copy link
Owner

@Hawk84r have you tried to use the manual camera and set the port in it?

@Hawk84r
Copy link
Author

Hawk84r commented Jul 16, 2024

@Hawk84r have you tried to use the manual camera and set the port in it?

If you mean something like :4408/path without URL - that sure doesn't work. Full URL with port works fine. Until you have a use case of local/remote access - setting a URL hard then is not an option. And not setting URL hard is generally better practice imho.

@marcolivierarsenault
Copy link
Owner

Full URL with port works fine.

yes this is what I meant

Until you have a use case of local/remote access

I am not sure I understand this?

@marcolivierarsenault marcolivierarsenault self-assigned this Jul 16, 2024
@Hawk84r
Copy link
Author

Hawk84r commented Jul 16, 2024

I am not sure I understand this?

Diffirent URLs for accessing from inside my LAN and from outside (internet, city LAN, work etc.) or accessing by IP address. I personally prefer to have options without the need to change any settings on end devices.

@marcolivierarsenault
Copy link
Owner

so if the option page had a port config it would work?

@Hawk84r
Copy link
Author

Hawk84r commented Jul 16, 2024

so if the option page had a port config it would work?

It already does. If you enter full URL it just uses it with or without a port. My problem is if you use just the relative URL e.g. /some/path instead of http://somesite:4408/some/path script as it is now assumes that what should be given to HA is http://somesite/some/path instead of using actual machine URL provided in config (e.g. http://somesite:4408).
And to clarify, as my head must have been half in bed - changing this default behavior for me makes sense as I use fluidd from different addresses in different cases and thru apps like Octoapp and setting URL of cameras relative is the only way to make it work across all possible scenarios. For example - Octoapp will not accept full path URL for cameras at all.

@marcolivierarsenault
Copy link
Owner

is the port you want to use for the camera the same port you want for accessing the rest of the API?

@Hawk84r
Copy link
Author

Hawk84r commented Jul 17, 2024

is the port you want to use for the camera the same port you want for accessing the rest of the API?

That is correct.

@marcolivierarsenault
Copy link
Owner

ok that should be doable

@marcolivierarsenault
Copy link
Owner

ok so in normal setup, (not K1)

  • The moonraker API is access via port 7125
  • The camera stream and thumbnail file are access via the port 80.

So they don't use the same port, I am thinking about adding a port config option that would be used only for the camera/thumbnail

would that work for you

Just to validate, what is the URL you use to see the webcam via your web browser. For me it's

http://192.168.x.x/webcam/?action=stream

if I do this in chrome, I can see the stream What about you?

@Hawk84r
Copy link
Author

Hawk84r commented Jul 17, 2024

http://192.168.x.x/webcam/?action=stream

if I do this in chrome, I can see the stream What about you?

Sure can't on :80. http://192.168.x.x:4408/webcam/?action=stream is the one for me. So yes, port selection for camera/snap should do the trick.

@marcolivierarsenault
Copy link
Owner

marcolivierarsenault commented Jul 17, 2024 via email

@Hawk84r
Copy link
Author

Hawk84r commented Jul 17, 2024

We

But it would not work if you use this port to recover thumbnail images? Or it would? Marc-Olivier

Sure works now with fix in my first post, so I don't see why not.

@marcolivierarsenault
Copy link
Owner

Can you try newest version 1.3.0 it allows to configure custom port for the camera and thumbnail (in the configure option)

@marcolivierarsenault
Copy link
Owner

☝️ try this and reopen if needed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants