Regenerated image not shown in dashboard

I’m using Crestron NVX HDMI over IP. These units have a preview image, which I want to integrate in Home Assistant for troubleshooting purposes.
The images are shown using https and login details, like:
https://user:[email protected]/preview/preview_270px.jpeg
This works in a browser (and on my MacBook if I validate the insecure certificates). To get around the certificate issue, I (actually AI) created a docker container with gunicorn which is an http server where you can add an https query like:
http://dockermachineip:dockermachineport/image.jpeg?url=https://user:[email protected]/preview/preview_270px.jpeg

if I put the above address in a browser, I get the requested image. If I put this in home-assistant, it can’t show the image (home-assistant app on my MacBook).

How am I able to troubleshoot the issue to finally get the preview images in HA?

a @ in the url is often interpreted as a login with username:password prefixed.
In your case that means x.x.x.x is the site HA might try to connect to and the text between http:// and @ is then somehow divided into the username and password, which will of course not work.
Either rewrite the url on the gunicorn server or try to rewrite the @ to an url encoded value.

Where do you “put it” ? , i assume a Card, but which :wink:

I tried both Picture Card and Picture-Glance Card

any “”“code”“” to share ?

AI came up with these:

app.py:

from flask import Flask, request, send_file
import requests
from io import BytesIO

app = Flask(__name__)

@app.route('/image.jpeg')
def get_image():
    url = request.args.get('url')
    if not url:
        return "URL parameter is missing", 400
    try:
        # Fetch the image from the insecure server, ignoring SSL verification
        response = requests.get(url, verify=False)
        response.raise_for_status()
        img_bytes = BytesIO(response.content)
        # You can dynamically detect MIME type if needed; here assuming JPEG
        return send_file(img_bytes, mimetype='image/jpeg')
    except requests.exceptions.RequestException as e:
        return f"Error fetching image: {e}", 500

if __name__ == '__main__':
    # Not used directly when running with Gunicorn
    pass

requirements.txt:

Flask
requests
gunicorn

Dockerfile:

# Use an official Python runtime as a parent image
FROM python:3.11-slim

# Set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

# Set working directory
WORKDIR /app

# Install dependencies
RUN pip install --upgrade pip
COPY requirements.txt .
RUN pip install -r requirements.txt

# Copy project
COPY . .

# Expose port
EXPOSE 5054

# Run the app
CMD ["gunicorn", "-w", "6", "-b", "0.0.0.0:5054", "app:app"]

Then when using the syntax in the opening post, on a browser it will show the https image

AI, You are kidding right ? … firstly, i mend in HA, what have you tried, i.e Why didn’t you succeed with fetching the Pic directly from source ?, And why did it neither work from your “extensional” docker-install-server ?

The original URL works in HA, IF:
I grab the insecure certificate from the unit and put it as a trusted certificate on my MacBook.
I want to get rid of this (I’m not able to trust the certificate on all pc’s/touchpanels I’m showing an HA dashboard on) and am thus using a “converter” through a docker container. For a browser, this works. But in HA trying to show an image, it doesn’t.

Yes, you said so, and i asked What have you tried ? In HA
Have you read up upon the multiple various ways you can show an external Pic ?, I mean in the Official HA Docs
Below is some examples
Generic Camera - Home Assistant .
Picture entity card - Home Assistant .
Template - Home Assistant .
And don’t forget i.e verify_ssl: False If needed ( When using Template#Image )
You could also try with your Container and a Markup-webpage card(HTML-Tags)
Native Webpage card - Home Assistant . Or Markdown card - Home Assistant .
OR some of “other” choices of HTML-Cards from i.e HACS

Note, you can also choose to “import/store” the image in i.e under your /www or other “local-storage” in HA, and update it, in the “interval” of your choice ( And fetch it from there/locally ,in Your Card)

I find it quit obvious that Your AI might have giving you a “Task” just to mess up your head

1 Like

I was not aware of the Generic Camera functionality.
It indeed does work now without the docker workaround.

1 Like

Yeah i get that it’s not the “first” option one would think about, for “showing a picture”, i think i just knew because one of my “old” custom:integrations used this
Great that it works for You also !