marcolivierarsenault / moonraker-home-assistant

Home Assistant integration for Moonraker, Klipper and Mainsail
https://moonraker-home-assistant.readthedocs.io
MIT License
266 stars 29 forks source link

Broken camera if not an absolute path #363

Closed Hawk84r closed 3 months ago

Hawk84r commented 5 months ago

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 commented 4 months ago

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 commented 4 months ago

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

Hawk84r commented 4 months ago

@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 commented 4 months ago

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?

Hawk84r commented 4 months ago

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 commented 4 months ago

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

Hawk84r commented 4 months ago

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 commented 4 months ago

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

Hawk84r commented 4 months ago

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 commented 4 months ago

ok that should be doable

marcolivierarsenault commented 4 months ago

ok so in normal setup, (not K1)

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 commented 4 months ago

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 commented 4 months ago

But it would not work if you use this port to recover thumbnail images?

Or it would?

Marc-Olivier Arsenault

Le mer. 17 juill. 2024 à 08:39, Hawk84r @.***> a écrit :

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.

— Reply to this email directly, view it on GitHub https://github.com/marcolivierarsenault/moonraker-home-assistant/issues/363#issuecomment-2233225625 or unsubscribe https://github.com/notifications/unsubscribe-auth/AAUDC2SUO5MEU6BWJBSVXNTZMZQYXBFKMF2HI4TJMJ2XIZLTSWBKK5TBNR2WLJDUOJ2WLJDOMFWWLO3UNBZGKYLEL5YGC4TUNFRWS4DBNZ2F6YLDORUXM2LUPGBKK5TBNR2WLJDUOJ2WLJDOMFWWLLTXMF2GG2C7MFRXI2LWNF2HTAVFOZQWY5LFUVUXG43VMWSG4YLNMWVXI2DSMVQWIX3UPFYGLAVFOZQWY5LFVI2TAOBUHAZTKMRTHCSG4YLNMWUWQYLTL5WGCYTFNSBKK5TBNR2WLKRVGA4DIOBTGUZDKNFENZQW2ZNJNBQXGX3MMFRGK3FMON2WE2TFMN2F65DZOBS2YSLTON2WKQ3PNVWWK3TUUZ2G64DJMNZZJAVEOR4XAZNKOJSXA33TNF2G64TZUV3GC3DVMWUTKOJUGAYDONJRGKBKI5DZOBS2K2LTON2WLJLWMFWHKZNKGIZTQNZYGMYDKNRQQKSHI6LQMWSWYYLCMVWKK5TBNR2WLKRVGA4DIOBTGUZDGOECUR2HS4DFUVWGCYTFNSSXMYLMOVS2UNJQHA2DQMZVGI2TJJ3UOJUWOZ3FOKTGG4TFMF2GK . You are receiving this email because you commented on the thread.

Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub .

Hawk84r commented 4 months ago

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 commented 3 months ago

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

marcolivierarsenault commented 3 months ago

☝️ try this and reopen if needed