How to pause, go back or delete an image on your Raspberry Pi digital picture frame with a simple Alexa voice command

Sometimes you see a photo on your digital picture frame which you don’t like anymore, and you make a mental note to remove it when you get to your computer next time.

But often you just forget about it and then it comes up again. Wouldn’t it be nice to just say “Alexa, delete this image” instead?

Or you want to pause playback to enjoy a photo for longer or go back to the previous one. Now you can.

In this short article, I will show you how to do it with Pi3D PictureFrame as the image viewer software and Amazon Alexa in combination with Home Assistant as your humble voice servant.

Tested with: Raspberry Pi OS March 2021 version, Raspberry Pi 2, 3, and 4, Pi3D 2.43, PictureFrame 2021.03.20, Home Assistant 2021.3.4, 1080p and 4K displays.

Pi3D PictureFrame and MQTT

You can set Pi3D PictureFrame, my favorite image viewer, to listen to MQTT messages to change certain parameters like display or fading delay and to set up smart filters for specifying a date range.

But what many probably don’t know is that you can also send direct commands like pausing the playback and deleting the currently displayed image.

The basic requirement is that you have an MQTT broker installed or are using a cloud-based MQTT broker.

As the installation of an MQTT on your Raspberry Pi is a matter of one single command, I recommend installing Mosquitto. In my experience, it is also much more reliable than an external service.

In the configuration.yaml, you just need to enable MQTT and specify the IP of your MQTT broker, which, with Mosquitto installed, is simply “localhost“.

mqtt:
  use_mqtt: True
  server: "localhost"
  port: 1883

Creating the scripts in Home Assistant

We are using Home Assistant as the bridge between Alexa and Pi3D. Unfortunately, it is not (yet) possible to send MQTT messages through Alexa directly, so we need this interface through Home Assistant and Nabu Casa. You can read all about it here.

One alternative is to use Node-Red, but there is currently an issue with the latest generation of the Amazon Echo devices. I expect to publish an update here soon, but for the moment, Home Assistant is the way to go.

Pausing the playback

Create a new script in Home Assistant, and call it “Frame Pause Playback”.

Under Sequence to the right, click on “Edit as YAML” (the button with the three dots) and paste this text in the box.

data:
  payload: 'ON'
  topic: homeassistant/switch/picframe_paused/set
service: mqtt.publish

Going to the previous image

Create a new script in Home Assistant, and call it “Frame Previous Image”.

Under Sequence to the right, click on “Edit as YAML” (the button with the three dots) and paste this text in the box.

data:
  payload: 'ON'
  topic: homeassistant/switch/picframe_back/set
service: mqtt.publish

Deleting the currently playing image

Create a new script in Home Assistant, and call it “Frame Delete Image”.

Under Sequence to the right, click on “Edit as YAML” (the button with the three dots) and paste this text in the box.

data:
  payload: 'ON'
  topic: homeassistant/switch/picframe_delete/set
service: mqtt.publish

The “frame/delete” command doesn’t actually delete your image.

It just moves it outside of its current location to a folder called “/home/pi/DeletedPictures” and then moves to the next image in the playlist.

This way, you can always recover any accidentally deleted images.

Testing the script

Test the script by manually triggering the three scripts. Check if your “deleted” photos are showing up in the “pi/DeletedPictures” folder.

Connecting the Home Assistant scripts to Alexa

For a more detailed article on this subject, I recommend reading “Voice control your digital photo frame with Amazon Echo and Home Assistant“.

I assume that you have the Alexa app installed on your mobile phone. Let’s go through the steps:

In the Alexa app, tap on the top-left hamburger menu. Choose “Routines”. Tap on the “+” sign in the upper right to create a new routine.

Enter a routine name for your task, in this case, “Playback Pause”. Click on “When this happens” and choose “Voice”. Enter the Alexa trigger phrase in your language and click “Next” (The examples above are from another Routine, but you get how it works.)

Click on “Add action” and choose “Smart Home” and “Control Scene”. What Alexa calls “Scene” is what is called a “Script” in Home Assistant. Choose the Scene/Script from Home Assistant and tap on “Add”. Finally, save your routine.

Wait a few seconds until the Amazon servers have digested your settings and test the routine by tapping on the “Play” sign on the right of your routine. Your command is now sent to Pi3D on your picture frame. If that works, the voice command will equally work.

Conclusion

Three simple commands that help you to operate your digital picture frame in the most convenient way possible – your voice.

Especially deleting images by voice as you see them has become a feature that we like to use frequently at home to cull those images that may have been nice at the time but are no longer. This way, you have nothing but beautiful memories, nature, or friends & family on your frame.

Is there another command that you would like to see? Let me know!

Was this article helpful?


Thank you for your support and motivation.


Scroll to Top