Notification problem: Can't receive Images when in mobile network

Hi Folks,

I’m running a rule to receive an image on from my frontdoor camera on my iphone when someone is ringing. It works perfectly fine when I’m at home in my local wifi, but when I’m in mobile network the notification won’t show a preview either the image when tapping on it.

Here’s my configuration:

Item:

Image  FtpImage1 "Haustür" <camera> (SemGrCorridorEGCam) { channel="ftpupload:imagereceiver:images1:image_Haustuer" }

Rule:

executeCommandLine("/etc/openhab/scripts/image.sh") 
       
sendNotification("xxx.yyy@zzz.de","Es klingelt!", null, null, "Haustür", "img1", null, "https://xxx.yyy.zz:443/static/FtpImage1.png", null, null, null)

I use a script to store the image locally from a ftp image-item. The image is reachable from mobile network through ddns.

Any successions why its not working in mobile network?

I assume this is the public IP address of your home network? Why not use the ddns domain name instead?

Your reverse proxy is configured to forward all standard HTTPS traffic to your OH instance? You can bring up that URL exactly as entered in the call to sendNotification when your phone is only connected to the mobile network and get the image?

Have you tried a relative URL? That’s the best way to reference an image in the $OH_CONF/html on sitemaps and MainUI. I’ve not tried it with notifications but would expect it to work the same.

static/FtpImage1.png

Hi Rich,

thank you for your quick reply.

Its the ddns domain.

I’ve configured the reverse proxy from openhabian, can you spot a mistake?

  GNU nano 5.4                                      /etc/nginx/sites-enabled/openhab *                                             
##################################
6# openHABian NGINX Configuration #
##################################




  GNU nano 5.4                                      /etc/nginx/sites-enabled/openhab                                               
  GNU nano 5.4                                      /etc/nginx/sites-enabled/openhab                                         M     
 }

## Reverse Proxy to openHAB
server {
#    listen                          80;
   listen                          443 ssl;
    server_name                     xxx.yyy.zz;
   add_header                      Strict-Transport-Security "max-age=31536000; includeSubDomains";

    # Cross-Origin Resource Sharing.
    add_header 'Access-Control-Allow-Origin' '*' always; # make sure that also a 400 response works
    add_header 'Access-Control-Allow_Credentials' 'true' always;
    add_header 'Access-Control-Allow-Headers' 'Authorization,Accept,Origin,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-Wi>
    add_header 'Access-Control-Allow-Methods' 'GET,POST,OPTIONS,PUT,DELETE,PATCH' always;
    add_header Set-Cookie X-OPENHAB-AUTH-HEADER=1;

## Secure Certificate Locations
   ssl_certificate                 /etc/letsencrypt/live/xxx.yyy.zz/fullchain.pem;
   ssl_certificate_key             /etc/letsencrypt/live/xxx.yyy.zz/privkey.pem;

    location / {
        proxy_http_version                      1.1;
        proxy_pass                              http://localhost:8080/;
        proxy_set_header Host                   $http_host;
        proxy_set_header X-Real-IP              $remote_addr;
        proxy_set_header X-Forwarded-For        $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto      $scheme;
        proxy_read_timeout 3600;

        proxy_set_header Authorization "";

## Password Protection
       auth_basic                              "Username and Password Required";
       auth_basic_user_file                    /etc/nginx/.htpasswd;
    }

## Let's Encrypt webroot location
   location /.well-known/acme-challenge/ {
       root                                    /var/www/xxx.yyy.zz;
   }
}

# vim: filetype=conf

Yes, works from my iphone when in mobile network.

Yes, also not working.

I neither use nor recommend exposing OH to the internet through a reverse proxy, so I don’t think I can offer a lot more in terms of advice.

If I were to guess, whatever subsystem on your phone that is displaying the notification is not authorized to access the page. You have basic auth enabled in the reverse proxy config and I don’t know if OH allows access to static without authorization too (I think it doesn’t).

Stuff like this is one of the major reasons myopenhab.org exists. Your iOS app will already be authorized to access that URL if you were using it instead of a reverse proxy and exposing your LAN to the internet.

And don’t you need myopenhab.org to do notifications in the first place? What’s the reverse proxy for? You already need myopenhab.org to deliver the notifications, so why not configure your iOS app to use it and then use the myopenhab address (https://home.myopenhab.org/static/FtpImage1.png) in the notification?

Why even expose yourself and take the risk of running and maintaining a reverse proxy in the first place?

Another approach would be to figure out how to get the image into an Image Item. See How to set the image content of an image item - #2 by Wolfgang_S for how to get started with that.

My previous setup was using myopenhap.org and also using an Image-Item in the notification rule. But since this did not work I tried workaround by ddns.

I receive the image via FTP-Binding and an Image-Item. Then I store the image locally out of the Image-Item by script.

Maybe its kind of encoding problem?

If you already have the binary of the image in an Image Item, why not just use that?

  • mediaAttachmentUrl: The URL of the media attachment to be displayed with the notification. This can either be a fully qualified URL, prefixed with http:// or https:// and reachable by the client device, a relative path on the user’s openHAB instance starting with /, or an image item with the format item:MyImageItem

Emphasis added.

Very likely since the Image Item is going to hold the image as a base64 encoded String, not the actual raw png bindary bits. It needs to be transcoded from base64 to binary before you can just save it as a file and have it be useable as a png.

It takes a bit of coding to make that work.

But you don’t need to. Just use the Item in the first place and OH will do the necessary transcoding.

That’s what I figured out so far:

Works in local network:

sendNotification("xxx.yyy@zzz.de","Es klingelt!", "camera", null, "Haustür", null, null, "item:FtpImage1", null, null, null)

Works also in local network:

sendNotification("xxx.yyy@zzz.de","Es klingelt!", null, null, "Haustür", "img1", null, "http://oh_ip_adr:8080/static/Image1.png", null, null, null)

Doesn’t work in local network:

sendNotification("xxx.yyy@zzz.de","Es klingelt!", null, null, "Haustür", null, null, "/static/Image1.png", null, null, null)

None of them working in mobile network.

I know others do this routinely so all I know is it should be possible. But I’ve never done it myself and am out of ideas as to what could be wrong. Based on the docs, if the actual image in the an Image Item it should work. :person_shrugging:

For me, the image item works in all networks, including mobile.
Using the beta of the iOS app.

Finally the latest ios app update solved it

1 Like