Push Notifications now available!

replace /config/www/... with /local/...

More on this here: https://companion.home-assistant.io/docs/notifications/notification-attachments

So, I am able to get it to send when I manually type in the filename and location. I am trying to figure a way to autopopulate the field for the filename with either most recent photo, or current timestamp. When I send this code https://ui.nabu.casa/local/{{ now().strftime(”%Y%m%d-%H%M%S") }}.jpg", it sends a link like this to my phone that looks like this. https://.ui.nabu.casa/local/{{ now().strftime("%Y%m%d-%H%M%S") }}.jpg How would I have it populate the filename with the unique value?

you need to send the template through data_template and not data all you need to do is replace the first instance of it.

See rule #1: https://www.home-assistant.io/docs/automation/templating/#important-template-rules

Thanks for the reply, before I get too deep into this reading, will this work in nodered? I do not use HA for templates and automation stuff.

I don’t use nodered but I don’t see why it wouldn’t.

1 Like

Any idea when this will work on Android?

The code to give us camera snapshots and streams is already in HA, just need the Android app to support it by the looks of things

1 Like

Not any current feature requests for that stuff, you can submit them on github.

Is it possible to filter actions for which device/user that pressed the button?
In case of an alarm I have set up 3 actions

  • guest mode on
  • sound siren
  • view recordings

View recordings sends another notification to the phone that triggers it to start the nvr app through tasker, and the quickly clears the notification.

Now I would like to include my partners phone in this automation, the first two buttons should to the same in both cases but for the third I would like to see which device that wants to display the recordings… I saw that in the documentation there are some context available and I think it would work with user_id, but I cannot figure out read/use this value.

Could anyone help me how to either

  • trigger the automation only when user_id is correct
  • use the user_id in a template in the action part of an automation triggered by a mobile_app_notification_action

Done. Hopefully it gets implemented as this would make things so much easier and better when it comes to sending camera snapshots to our phones (ie: for doorbells)

To answer my own question in case anyone else wonders
in data_template or service_template described in the automation templating documentation you can use
{% if trigger.event.context.user_id == ‘your_user_id_here’ %}string_to_insert{% endif %}

I have been beating my brains out trying to get the correct syntax using data_template when sending an android message. I have tried all types of combinations, but this will give you an idea of what I want to do. I define an image filename and store it in input_text.camera_image, take a snapshot and store it in this file, and then try to send the image to my android phone.

    - service: input_text.set_value
      data_template:
        entity_id: input_text.camera_image
        value: "snapshot{{now().minute}}{{now().second}}.jpg"
    - service: camera.snapshot
      data_template:
        entity_id: camera.sun_room
        filename: "/config/www/cam_captures/{{states('input_text.camera_image')}}"
    - delay: 00:00:02
    - service: notify.mobile_app_xxxxxx
      data:
        title: Test Message at {{ now().strftime('%I:%M %p') }}
        message: "Snapshot of Sunroom!"
        data_template:
          image: https://mydns.duckdns.org/local/cam_captures/{{states('input_text.camera_image')}}"
          hide-thumbnail: false
          actions:
            - action: "URI"
              title: "View"
              uri: "/lovelace/cameras"

If I replace data_template: with data: and simply send the name of a file, everything works. I just cannot figure out the right syntax when using data_template. I typically get an error similar to this:

Invalid data for call_service at pos 4: extra keys not allowed @ data[‘data_template’]

Anyone have any ideas?

1 Like

You only need to replace the first instance of data with data_template the rest that are under it should remain as data.

Also hide-thumbnail: false is not a valid for the android app so you should remove that: https://companion.home-assistant.io/docs/notifications/notification-attachments#configuration

Thank you! Thought for sure I tried that combination but apparently not. No more error message, but I am not getting the image displayed in the notification. Back to the drawing board.

Your issue is that you are missing the opening double quotes

Should be: image: "http:/....{{template}}"

That plus I was missing the port number 8123. Thank you so much, I’m back to making progress.

I’m trying to get image notifications working with the MotionEye add-on images but not having any luck. Using the code from the start of this thread by flamingmoe:

message: 'doorbell test'
data:
  android:
    notification:
      image: https://redacted.ui.nabu.casa/api/hassio_ingress/JGsnwxzD9kZ2oiIhwe14VKW1Y_elQxhImLwIn6My24g/picture/3/current/

If I open that link in Chrome on a PC I get an image (so I know the link is fine, externally accessible) but the app notification just gives me the message text and no image. Tapping the notification simply opens the HA app. Any pointers?

You are using the old format: https://companion.home-assistant.io/docs/notifications/notification-attachments

yeah, I tried that too (forgot to put it in the previous post) and it didn’t work either. I tried using attachement, URI, nothing worked

image

gives me the message text only, tapping it simply opens the HA app

try to start fresh with the app if none of the options work, sounds like something needs to be cleaned up

I’ll have to give it a try. So my code below should work?

- service: notify.mobile_phones
  data:
    message: "Someone is at the front door"
    data:
      ttl: 0
      priority: high
      image: https://redacted.ui.nabu.casa/api/hassio_ingress/JGsnwxzD9kZ2oiIhwe14VKW1Y_elQxhImLwIn6My24g/picture/3/current/