@jonnyrider Sure. Here’s the script.
import random, os
import shutil
path = (r'C:/Users/Administrator/Pictures/Slideshow/')
random_image = random.choice([x for x in os.listdir(path)])
picture = os.path.join(path + random_image)
shutil.copyfile(picture, r'C:\Users\Administrator\AppData\Roaming\.homeassistant\www\slide.jpg')
exit()
It picks a random image from the Slideshow folder and then copies it as slide.jpg
in the www folder.
The script is integrated in HA as a shell command
slideshow: 'C:\Users\Administrator\AppData\Roaming\.homeassistant\python_scripts\slideshow.py'
And is run with an automation every 3 minutes.
- id: auto_slideshow
alias: auto_slideshow
description: ''
trigger:
- minutes: /3
platform: time_pattern
condition: []
action:
- data: {}
service: shell_command.slideshow
Afterwards, the image is picked by the local_file camera integration and it’s displayed in the frontend with a picture-entity card.
- platform: local_file
name: Slide
file_path: 'C:\Users\Administrator\AppData\Roaming\.homeassistant\www\slide.jpg'