home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.68k stars 30.81k forks source link

Generic camera not working with Yr SVG image #110626

Open fatuuse opened 9 months ago

fatuuse commented 9 months ago

The problem

It's not possible to add an Yr SVG image in the integration config page. Error: URL returned image

https://www.yr.no/en/content/1-72837/meteogram.svg

Did work earlier with images from Yr in yaml.

Also broken with example in integration page. "Weather graph from yr.no Still Image URL: https://www.yr.no/en/content/1-72837/meteogram.svg Instructions on how to locate the SVG for your location are available at developer.yr.no"

What version of Home Assistant Core has the issue?

core-2024.2.1

What was the last working version of Home Assistant Core?

?

What type of installation are you running?

Home Assistant Container

Integration causing the issue

Generic Camera

Link to integration documentation on our website

https://www.home-assistant.io/integrations/generic

home-assistant[bot] commented 9 months ago

Hey there @davet2001, mind taking a look at this issue as it has been labeled with an integration (generic) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `generic` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign generic` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


generic documentation generic source (message by IssueLinks)

fatuuse commented 9 months ago

Working with mjpeg camera. https://www.home-assistant.io/integrations/mjpeg/

davet2001 commented 9 months ago

Hi @fatuuse, yes, this was identified before and was there are PR to resolve it #80810.

But it was declined with a preference to use a separate image entity #90564.

From what I can see, you can't add that via the integrations page. You may be able to use a picture or picture entity card for what you are trying to do.

Generic is a bit of a strange integration that used to be a multi-tool but is now mostly targeting cameras. I made a push to improve it significantly (UI, preview, URL checking, error messages), after I saw people having so much trouble setting up cameras. But I'm ok if those improvements migrate to improve other integrations that replace it.

For me the general takeaway was that 'generic' is not the best choice for something that only produces still images.

I think the reason generic camera is failing but mjpeg camera is not, is that generic is checking the image validity, but mjpeg is not.

The URL you linked starts with <?xml but the below checking code does not have a case to spot that, so deems the image invalid (I expect that is causing the error you stated, even though I could not see "URL returned image" in any of the error messages).

https://github.com/home-assistant/core/blob/fd0f093299c9ea3229de1c7eb4639cd44d0e3ba9/homeassistant/components/generic/config_flow.py#L133C1-L146C15

rocket-plane commented 7 months ago

So I'm little bit confused. My goal is to include the yr.no svg image in my dashboard as fullpage image. As mentioned in this Thread the example "https://www.yr.no/en/content/1-72837/meteogram.svg" does not work with generic camera.

But what is the alternative? How can I create such a image entity ?

P.S. The example in the documentation should be changed in a way that states that this in not possible. It would be nice if the altrnative way would also be mentioned there.

davet2001 commented 7 months ago

But what is the alternative? How can I create such an image entity ?

You could use a picture card if you want this SVG on a dashboard.

P.S. The example in the documentation should be changed in a way that states that this in not possible. It would be nice if the altrnative way would also be mentioned there.

Yes, I agree. If we are not intending to support all types of SVG here we should use something else as an example.

rocket-plane commented 5 months ago

The problem with the picture card is, that it does not reload frequently. Like this my weather forecast is sometimes 1-2 days old. I would expect it to reload let's say every 4 or 6 hours. Using the iframe card has similar issues. (The Dashboard is shown on a dedicated wall mounted tablet which does nothing else. The Software I'm using is FullyKiosk)

issue-triage-workflows[bot] commented 2 months ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

davet2001 commented 2 months ago

I think this should stay open as it's not really resolved yet.

rocket-plane commented 2 months ago

I kind of found a solution. I'm currently using the "MJPEG IP Camera Integration" and entered the yr.no URL in the fields "MJPEG-URL" and "Standbild-URL" (probably "still image url"). That shows a resizing window which refreshes regularly. I don't know if it has other drawbacks.

The mininum to resolve this issue would be to remove the yr.svg section from the generic camera documentation. It is missleading. Better would be to add the section to the MJPEG IP Camera documentation. Best would be to have a special and intuitively named Integration for that.

d95andek commented 4 weeks ago

Found this after failing to solve the problem of updating Yr datagrams. Tried the example for the Generic Camera. "MJPEG IP Camera Integration" did not work for me. However https://github.com/dimagoltsman/refreshable-picture-card did work. I find it strange that:

  1. The documentation for Generic Camera has an example that does not work.
  2. There is no solution for this kind of semi static image within the HA Core. The integration I used should not be necessary. A refresh interval for the PictureCard would be optimal.