[Solved] Cannot add Image to Notifications to >1 recipient device

Keeping this here to help others as I could not find code examples anywhere. ChatGPT, Deepseek, and Claude 3 could not fix after 2 hours a trying them. Google’s Gemini fixed it first shot.

Code is different to attach an image to a notification for the built-in HA service when there are more-than-one recipient.

Code that works for a single (or group) entity…

          default:
          - service: notify.{{ notify_group_target }}
            data:
              title: !input notification_title
              message: !input notification_message
              data:
                channel: !input notification_channel
                group: !input notification_group
                color: !input notification_color
                image: '{{ snapshot_access_file_path }}'
                clickAction: !input data_clickaction_url
                # video: !input notification_video
                sticky: !input notification_sticky
                alert_once: !input notification_alert_once
                notification_icon: !input notification_icon
                ttl: 0
                priority: high
                attachment:
                  url: '{{ snapshot_access_file_path }}'
                  content_type: JPEG
                url: !input data_clickaction_url
                push:
                  sound:
                    name: !input notification_sound
                    volume: !input notification_volume
                    critical: '{{ iif(notification_critical, 1, 0) }}'
                actions:
                - action: '{{ action_type }}'
                  title: '{{ action_title }}'
                  uri: '{{ action_uri }}'

Similar muli-recipient code send Notifications fine but Image is never attached…

          - condition: template
            value_template: '{{ notify_device != false }}'
          - repeat:
              for_each: !input notify_device
              sequence:
                - service: "notify.mobile_app_{{ device_attr(repeat.item, 'name') | slugify }}"
                  data:
                    title: !input notification_title
                    message: !input notification_message
                    data:
                      channel: !input notification_channel
                      group: !input notification_group
                      color: !input notification_color
                      image: '{{ snapshot_access_file_path }}'
                      clickAction: !input data_clickaction_url
                      sticky: !input notification_sticky
                      alert_once: !input notification_alert_once
                      notification_icon: !input notification_icon
                      ttl: 0
                      priority: high
                      attachment:
                        url: '{{ snapshot_access_file_path }}'
                        content_type: JPEG
                      url: !input data_clickaction_url
                      push:
                        sound:
                          name: !input notification_sound
                          volume: !input notification_volume
                          critical: '{{ notification_critical }}'
                      actions:
                        - action: '{{ action_type }}'
                          title: '{{ action_title }}'
                          uri: '{{ action_uri }}'

you must Explicitly scope the path variable inside the loop sequence. A nuance (aka pain and frustration) of the not-real programming language :frowning:

working multi-recipient code…

      - condition: template
        value_template: '{{ notify_device != false }}'
      - repeat:
          for_each: !input notify_device
          sequence:
            - variables:
                # Explicitly scope the path variable inside the loop sequence
                img_path: '{{ snapshot_access_file_path }}'
            - service: "notify.mobile_app_{{ device_attr(repeat.item, 'name') | slugify }}"
              data:
                title: !input notification_title
                message: !input notification_message
                data:
                  # Android standard key
                  image: '{{ img_path }}'
                  # iOS standard key
                  attachment:
                    url: '{{ img_path }}'
                    content_type: JPEG
                  channel: !input notification_channel
                  group: !input notification_group
                  color: !input notification_color
                  clickAction: !input data_clickaction_url
                  sticky: !input notification_sticky
                  alert_once: !input notification_alert_once
                  notification_icon: !input notification_icon
                  ttl: 0
                  priority: high
                  url: !input data_clickaction_url
                  push:
                    sound:
                      name: !input notification_sound
                      volume: !input notification_volume
                      critical: '{{ notification_critical }}'
                  actions:
                    - action: '{{ action_type }}'
                      title: '{{ action_title }}'
                      uri: '{{ action_uri }}'

No you don’t. That variable would have passed through, it’s something else your LLM did that screwed up the other loops.

Would be great if you could point to example code that works without doing what I found was the only thing that works… I looked for easily 2 hrs and used AI also… not a single example could be found where more than one entity was sent a notification with an image. Which is likely why the LLMs did not have any solutions… I suspect the other 5 blueprints I found, the authors ran into the same problem I did and decided not to work around it and just leave it a single entity.

In any other programming language (which I’m not even good at) this would be a non-issue since it would be a simple loop. Programming in HA is 100x harder especially since there are “undocumented nuances” like this.

Here’s one from my config

Look at state_parameter defined outside my loop.

          parameter: "{{ state_parameter }}"

There’s no nuance, ya did something wrong. :man_shrugging:

1 Like

maybe but all I know is the only code I changed is that one section, and it works while the other did not. The variable did not pass through into the loop, it works fine when there is no loop in the exact same place. Again, its way too hard to figure out why, and millions of lines of example code evaluated by 4 AIs could not figure it out either. It works now so I’ll just keep it the way it is.

If someone would only merge the Ring Camera fix from Nov 2025 then I’d be happy… seems like 3 months is way to long to merge a fix for something that has been broken literally forever.

AI doesn’t know HA well, it just follows patterns. AI is not “intelligent”, it’s machine learning and it only learns patterns. Stop heavily relying on it.

3 months is normal for the review process. It’s typically closer to 4-6 months depending on how active the code-owner is. Ring’s code owner is a volunteer, so I’d expect 4 - 6 months.

wish I could… the blueprints and dashboards I create are complex. blueprints are almost always 1000-2000 lines. Doing that manually is it not feasible. LLMs can code (even things I know how to) 1000s of times faster than I can, and search millions of lines of code and docs, and find methods for things I dont know how to do.

the fix was complete Nov 12th… just needs to be merged

Then it might be time to stop blaming HA when you heavily rely on a tool that has proven time and time again to be only 70% correct.

Because the guy never put in a PR… He only changed the code on his fork and never followed through with a PR against home assistant. Take it up with HusainCode.

2 Likes