How to trigger a Home Assistant script through Alexa and make your Raspberry Pi picture frame do (just about) anything

The image viewer Pi3D PictureFrame, Home Assistant, and Amazon Alexa is a match made in heaven when it comes to magically control your images on the wall.

Almost whatever you want to your digital photo frame to do, you can do by simple voice commands of your choosing.

In this article, I will show you how to do it with Pi3D PictureFrame as the image viewer software and Amazon Alexa combined 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

Pi3D PictureFrame and MQTT

Pi3D PictureFrame since the latest 2021 version can change many different parameters with a simple MQTT message. You can also find these commands in the PictureFrame 2021 wiki.

Provided that your picture frame is called “picframe” in configuration.yaml, these are the MQTT commands and the possible payloads.

- display on/off: homeassistant/switch/picframe_display/set, ON,OFF
- paused on/off: homeassistant/switch/picframe_paused/set, ON,OFF
- shuffle on/off: homeassistant/switch/picframe_shuffle/set, ON,OFF
- back: homeassistant/switch/picframe_back/set, ON
- next: homeassistant/switch/picframe_next/set, ON
- name text on/off: homeassistant/switch/picframe_name_toggle/set, ON,OFF
- date text on/off: homeassistant/switch/picframe_date_toggle/set, ON,OFF
- location text on/off: homeassistant/switch/picframe_location_toggle/set, ON,OFF
- directory text on/off: homeassistant/switch/picframe_directory_toggle/set, ON,OFF
- title text on/off: homeassistant/switch/picframe_title_toggle/set, ON,OFF
- caption text on/off: homeassistant/switch/picframe_caption_toggle/set, ON,OFF
- all text off: homeassistant/switch/picframe_text_off/set, ON # yes that is confusing!
- text refresh: homeassistant/switch/picframe_text_refresh/set, ON
- delete: homeassistant/switch/picframe_delete/set, ON
- directory: picframe/directory, string matching directory name
- date_from: picframe/date_from, string YYYY/MM/DD or number representing unix timestamp or zero length string to remove constraint
- date_to: picframe/date_to, string YYYY/MM/DD or number as above
- fade_time: picframe/fade_time, number
- time_delay: picframe/time_delay, number
- brightness: picframe/brightness, float 0.0 to 1.0
- location_filter: picframe/location_filter, string matching any part of geolocation description
- tags_filter: picframe/tags_filter, string matching tags
- stop: picframe/stop, message not used - just stops

Among the latest additions is the ability to show a text overlay with information on the image’s date and location. Especially if you don’t want to permanently show the information, being able to trigger it with a simple voice command is most convenient.

The basic requirement is that you have an MQTT broker installed. If you followed my instructions in the original Pi3D article, you will have installed the MQTT broker Mosquitto already.

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

  use_mqtt: True
  server: "localhost"

Creating the scripts in Home Assistant

Home Assistant is used 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.

I will show you two examples for scripts. Once you have understood the logic, you can create your own custom scripts for any other commands.

Show the date and location of an image

Create a new script in Home Assistant, and call it “Pi3D Show Date and Location ON”.

Note: Insert the right mqtt topics and payloads as shown above. The screenshots below are from an older version. Everything else if still the same.

Under Sequence to the right, fill in the information as shown here.

The reason why I introduced a one second wait period is to avoid any hick-up by sending MQTT messages too fast in a row.

The above script will show the date and location information for 60 seconds every time an image comes up.

Turning off the information overlay

Create a new script in Home Assistant, and call it “Pi3D Turn Text OFF”.

Under Sequence to the right, fill in the information as shown here.

The above script will turn off the display of any photo information.

Testing the script

Test the scripts by manually triggering the two scripts in Home Assistant by clicking on the Play Button to the left of the script name.

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 lower top-right icon “More”. Choose “Routines”. Tap on the “+” sign in the upper right to create a new routine.

Enter a name for your routine (this is not the voice command yet). Tap on “When this happens”, select “Voice”.

Enter the Alexa voice command. Add “Action” and choose “Smart Home”. Tap on “Control scene” (Scenes in Alexa are the scripts in Home Assistant).

Choose the script/scene that you created in Home Assistant. Hit “Save”, and “Next”.

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 PictureFrame 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