URL for random image

I really like the randomisation of images on the home screen. I would like to extend that to external dashboards by allowing them to request a random image from Photostructure. I’ve had a wee search and couldn’t see this available.

Ideally I could use Home Assistant or something similar to display a random photo or set of photos from today in history (this might be be a different feature!) on a dashboard.

Neat idea!

To work with your dashboard, what would that URL need to return?

  1. A fully-formed HTML document with just one image?
  2. A 302 redirect to an image?

(Can point me to any docs? I could only find this abandoned plugin, and /r/homeassistant didn’t have any leads)

In any event, this seems to warrant a new API endpoint (/api/pick maybe?), supporting the following parameters:

{
  reducer?: "sq" | "fit" // optional, defaults to "fit"
  width?: number // optional, defaults to 1920 (for an FHD screen)
  q?: string // optional search query: see <https://photostructure.com/faq/search/>
}

like:

http://localhost:1787/api/pick?width=1920&q=date:2018

Possible option 3: an image directly? Not sure.

Options for implementing in Home Assistant might be:

or even just the picture entity with the image attribute set: Picture Entity Card - Home Assistant

A sample one:

show_state: true
show_name: true
camera_view: live
type: picture-entity
entity: camera.wyze_v3_rtsp_test_cam
image: https://demo.home-assistant.io/stub_config/bedroom.png
camera_image: camera.wyze_v3_rtsp_test_cam

I would be comfortable just writing a basic web page that called the image or iframe and then opened that in a browser on a tablet. If I could use my own JavaScript to work out the search parameters to feed the API, that’s very flexible but plenty of work for lots of people I suppose.

Maybe something like:

http://localhost:1787/api/pick?width=1920&q=date:(todayinhistory) # this one is either multiple images from previous years with the same day/month as today, or a random year in history
http://localhost:1787/api/pick?width=1920&q=date:(currentyear-3) # this one is whatever was happening 3 years ago
http://localhost:1787/api/pick # this one is totally random

@devon, You’re using Home Assistant too? Thweet!

Home Assistant user here as well. This would be a pretty cool feature (although rather niche), I have a tablet in my hallway at home as a control pad that could use this.

image

1 Like

Yup, me too!

I had another idea for an evolution of this feature request. By submitting a search, we could specify which picture to serve - options being “random”, “oldest”, “newest”, “most popular”, and whatever else makes sense.

Search

Sort criteria are already supported by the search endpoint, so this isn’t any additional code (!!) :+1:

(other than “most popular”… what would that be based off of? views maybe? (fwiw I don’t track views currently!))

1 Like

Good question! Maybe this is harder.

Out there ideas:

  • weight favo[u]rites higher
  • keep track of views
  • implement multi-user (!!!) and combine metrics above
  • implement some kind of analysis engine that works out if the shot is in focus and weights those higher
  • implement some kind of analysis engine that lets you weight for people or landscapes or something else.

Here’s an example of a “today in history” idea being developed for the Photos app in Nextcloud for interest: