Skip to content

Instantly share code, notes, and snippets.

@peyanski
Created October 13, 2026 08:40
Show Gist options
  • Select an option

  • Save peyanski/330f94e7b31793b3e015155b63ef9f69 to your computer and use it in GitHub Desktop.

Select an option

Save peyanski/330f94e7b31793b3e015155b63ef9f69 to your computer and use it in GitHub Desktop.
Automatically shuffles every 5 minutes or narrates when the collection image changes.
id: collection_image_narrator
alias: Collection image narrator
description: Automatically shuffles every 5 minutes or narrates when the collection image changes.
mode: restart
triggers:
- trigger: state
entity_id:
- image.media_collection
id: state_changed
- trigger: time_pattern
minutes: "/5"
id: timer_trigger
conditions:
- condition: template
value_template: "{{ states('image.media_collection') not in ['unknown', 'unavailable'] }}"
actions:
# Action 1: If triggered by timer, shuffle to a new image
- choose:
- conditions:
- condition: trigger
id: timer_trigger
sequence:
- action: collection_image.shuffle
target:
entity_id: image.media_collection
- delay:
seconds: 2
# Action 2: Extract EXIF metadata (Can be disabled if you don't want Python!)
- action: shell_command.extract_exif_data
data:
image_file: "{{ state_attr('image.media_collection', 'entity_picture') }}"
response_variable: exif_output
# Action 3: Save local snapshot frame for AI vision task
- action: image.snapshot
target:
entity_id: image.media_collection
data:
filename: /media/collection_snapshot.jpeg
# Action 4: Ask LLM model to narrate the image
- action: ai_task.generate_data
data:
task_name: wall tablet picture narrator
entity_id: ai_task.ollama_ai_task_ministral_3_8b
instructions: >-
Look at this image and write one tiny, friendly line(s) for a wall
tablet. Use EXIF context if available: {{ exif_output.stdout if (exif_output is defined and exif_output.stdout is defined) else 'No EXIF data' }}. Try to
tell from where this picture is place/city based on latitude & longitude
also and when it was taken if there is EXIF data. Use very simple words.
If it is a famous landmark or popular art say the name and what it is.
If you are not sure, say that it is only a guess. Keep it above 200 but
under 255 characters. No markdown.
structure:
caption:
description: One short wall-tablet caption, fact, or riddle.
required: true
selector:
text: null
attachments:
- media_content_id: media-source://media_source/local/collection_snapshot.jpeg
media_content_type: image/jpeg
response_variable: picture_story
# Action 5: Save description to our helper
- action: input_text.set_value
target:
entity_id: input_text.collection_image_story
data:
value: >-
{{ picture_story.data.caption | default('New picture. Tiny robot is thinking.', true) | string | truncate(255, true, '') }}
# Action 6: Show persistent notification
- action: persistent_notification.create
data:
message: "{{ picture_story.data.caption }}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment