Notifications with Video Attachments on iOS

Hi there,

Today I installed the new iOS app and really wanted to try out the new features straight away.
Among other things, how to send a short video, as announced in the release notes for 4.2.
So far I have been using the ip cam binding to save a 5 sec video in tmpfs and then send it via Telegram after creating this video, but when I try to change this rule to cloud notification I fail miserably.

rule "kamera-3"
//Mail mit 5 Sekunden MP4 von Haustuer verschicken wenn bewegung
when
    Item Kamera_Haustuer_MP4_Recording changed to 0
then
    if( Mail_Cam_Eingang_Bewegung.state==ON ) {
    val videoFilePath = "file:///tmpfs/cam_front/ipcamera.mp4"
    val caption = "Bewegung an der Haustür"

    val telegramAction_1 = getActions("telegram", "telegram:telegramBot:Andreas")
    telegramAction_1.sendTelegramVideo(videoFilePath, caption)

    val telegramAction_2 = getActions("telegram", "telegram:telegramBot:Manu")
    telegramAction_2.sendTelegramVideo(videoFilePath, caption)
    Mail_Cam_Eingang_Bewegung.sendCommand(OFF)
    }
end

I was trying to place the path to the tmpfs file in the rule, but it only shows text:

sendNotification("xxx@icloud.com", "Bewegung an der Haustür", "motion", "Motion Tag", "Bewegung erkannt", "motion-id-1234", "///tmpfs/cam_front/ipcamera.mp4", null, null, null, null)

I also tried this:

sendNotification("xxx@icloud.com", "Bewegung an der Haustür", "motion", "Motion Tag", "Bewegung erkannt", "motion-id-1234", "http://192.168.1.206:8080/ipcamera/Haustuer/snapshots.mjpeg", null, null, null, null)

But this of course only works locally and gives me a live view but not the recorded video.

I cannot figure out how to fetch the last video recorded and saved to file:///tmpfs/cam_front/ipcamera.mp4, maybe somebody can assist me.

THX in advance.

BR Andreas

Typically web servers can only see files places in a very specific director or set of directories. This is a security feature. You don’t want anyone who can access the web server to be able to access all the files on your host machine.

For OH, that directory is $OH_CONF/html which can be accessed through http[s]://<path to OH instance>/static/<name of file>.

I’ve not experimented with video attachements on notifications but I’m almost certain that the actual video is not actually passed as part of that notification. Instead a URL is passed, and that URL needs to be accessible from the device receiving the notification.

In short, file://tmpfs/cam_front/ipcamera.mp4 is neither made accessible by being in the html folder nor is that URL a path to a file that exists on your phone.

1 Like

Yes, what you wrote makes perfect sense, I hadn’t thought about the web server thing.

As far as I can remember, tmpfs has advantages in that it is also ZRAM managed and therefore doesn’t put as much strain on the SD card.

Therefore, I would be reluctant to save the video files in another directory.

What would be interesting to know is why it works with the Telegram binding, since I’m accessing the videos from tmpfs, and whether this function can also be used somehow with the cloud notification.

The Telegram binding isn’t a web server. Bindings do not have the same limitations as the Jetty web server built into OH.

And I’m pretty certain that Telegram sends the actual video as part of the message, not just a link to it.

You probably know more about this than I do.

Yes, that’s right, with Telegram binding a video is sent instead of just a link.
But I want to achieve the same thing via the IOS notification, but I probably misunderstood the announcement about OH 4.2:

  • Media Attachments
    • Add images (or a short video on iOS) from an external URL or openHAB image item

Images and video (which i have not tried, but should work) need to be accessible via an external URL that your iOS device can access (think from a web browser), we send the URL as part of the message and the mobile app downloads the image/video data and attaches it to the message. OH Image items work similarly, but instead of downloading from an external URL, it talks to your openhab server to get the data. You can’t actually send media in a push notification as they have a max size of 4kb, its up to the mobile app to produce the media.

Ok that explains why this version only worked locally:

sendNotification("xxx@icloud.com", "Bewegung an der Haustür", "motion", "Motion Tag", "Bewegung erkannt", "motion-id-1234", "http://192.168.1.206:8080/ipcamera/Haustuer/snapshots.mjpeg", null, null, null, null)

But then why did this notification only open a web browser with a live video?

May I ask you to show me your rule for a notification with a image.

Because you set your link to a mjpeg as the onClickAction field, not as the mediaAttachmentUrl field

From openHAB Cloud Connector - System Integrations | openHAB

  • sendNotification(emailAddress, message, icon, tag, title, referenceId, onClickAction, mediaAttachmentUrl, actionButton1, actionButton2, actionButton3)

  • onClickAction: The action to be performed when the user clicks on the notification. Specified using the action syntax.

Also a mjpeg is a streaming format, not video file, so thats not going to work as an attachment, it would only support short video clips. I’m not sure how live video would be added to a push notification on iOS.

Here is your example, with the addition that the openhab logo from wikipedia would be attached to the message.

sendNotification("xxx@icloud.com", "Bewegung an der Haustür", "motion", "Motion Tag", "Bewegung erkannt", "motion-id-1234", "http://192.168.1.206:8080/ipcamera/Haustuer/snapshots.mjpeg", "https://upload.wikimedia.org/wikipedia/commons/thumb/0/07/OpenHAB_logo_2.svg/541px-OpenHAB_logo_2.svg.png", null, null, null)

Ah, thanks for the tip. Now I can send an image via an image item.

sendNotification("xxx@icloud.com", "Bewegung an der Haustür", "motion", null, "Bewegung erkannt", null, "ui:/basicui/app?w=00040009&sitemap=Andi", "item:Kamera_Haustuer_liveImg", null, null, null)

I guess I could no longer store the videos in tmpfs but in the HTML folder and add this folder to ZRAM by creating an entry in /etc/ztab, then it should be accessible, my videos are no longer then 5 sec, so it could work.

Another question I have concerns the onClickaction - the way I have currently integrated it, it takes me to the desired page, but the display is now like in a web browser and not like a classic sitemap in the iOS app. - Can this be adjusted?