Android actionable notifications

LG V10 android version 5.1.1. I changed api 23 to 22 in android studio.

Hi! I’m not getting the toast message nor the fcm* file in my HASS directory after signing in to the app after installation. My HASS is behind nginx, FWIW.

EDIT: Unchecked and rechecked “Push Notification” in settings and it works now!

Hi guys!
Have i understood it right that i need a forked version of HASS to make it able to work with HANotify android app?

Hi guys!
Have i understood it right that i need a forked version of HASS to make it able to work with HANotify android app?

Nope, no need for a forked version. You just need to put the fcm-android.py into your config/custom_components/notify folder (you probably need to create it) then initialize it in the configuration.yaml file. Reboot and you should be good to go.

@mudasar8k I wonder if it has to do with some API restrictions. Does the notification work if you were to send it as a notification and not data fcm? This would bypass any of the FCM handling of the app.

{ "message": "Anne has arrived home", "data": { "message_type": "notification"} }

1 Like

Any chance this can fit in to native app?
https://community.home-assistant.io/t/alpha-testing-ha-client-native-android-client-for-home-assistant

You have already integrated in Ariela - Home Assistant Android Client

Useing this and good so far

1 Like

I had same experience.

Followed steps to the letter, but had to untick Notifications and retick in the app for it to create the .conf file and give me the toast.

When I unticked it, got the message no registration.

Working now though after doing the above.

I’ve been playing with this tonight and it is awesome! Thank you for all your work! This is exactly what I’ve been looking for! However I’m having issues using the parameters specified. As an example, I can’t the ‘tag’ parameter working. Here’s my config:

- alias: Send me the weather testing 1
  hide_entity: true
  trigger:
    platform: time
    at: '22:56:00'
  action:
    - service: notify.android
      data:
        tag: 1
      data_template:
        message: >-
          {% if is_state("sensor.dark_sky_precip","rain") or
                is_state("sensor.dark_sky_precip","snow") or
                is_state("sensor.dark_sky_precip","sleet") %}
            It's {{states.sensor.dark_sky_precip.state | upper}}ING! {{states.sensor.dark_sky_daily_max_precip_intensity.state}} inches are expected. {{states.sensor.forecast_today.state}}
          {% else %}
            {{states.sensor.forecast_today.state}}
          {% endif %}
- alias: Send me the weather testing 2
  hide_entity: true
  trigger:
    platform: time
    at: '22:56:30'
  action:
    - service: notify.android
      data: 
        tag: 1
      data_template:
        message: >-
          {% if is_state("sensor.dark_sky_precip","rain") or
                is_state("sensor.dark_sky_precip","snow") or
                is_state("sensor.dark_sky_precip","sleet") %}
            It's {{states.sensor.dark_sky_precip.state | upper}}ING! {{states.sensor.dark_sky_daily_max_precip_intensity.state}} inches are expected. {{states.sensor.forecast_today.state}}
          {% else %}
            {{states.sensor.forecast_today.state}}
          {% endif %}

I get the following error

Invalid service data for notify.android: extra keys not allowed @ data['tag']. Got 1

Any idea what I’m doing wrong? I get a similar error if I try using actions. For what it’s worth, I installed the HomeAssist apk.

Yeah, don’t use data: and data_template: together. Move your “tag: 1” line into the data_template area and you should be good. You might need to add some quotes too.

EDIT: You actually CAN use those together. Disregard the above answer…

Ah I wasn’t aware I couldn’t use both. I’ll give it a shot, thanks!

Thanks for creating this, I’ve been having some real trouble with notifications until now!

One thing though - I can’t figure out why I can’t get an image to show in my notifications? I have an automation to take a snapshot of a camera at my front door when someone pushes the doorbell, then I’m trying to send a notification with that image attached. All I get is text, i.e. just ‘title’ and ‘message’. Any idea what I’m doing wrong? The snapshot creates the jpg each time, but it doesn’t appear in the notification.

- alias: 'Doorbell'
  trigger:
      platform: state
      entity_id: switch.doorbell_switch
      from: 'off'
      to: 'on'
  action:
    - service: camera.snapshot
      data:
          entity_id: camera.front_door
          filename: '/home/homeassistant/.homeassistant/cam_captures/front_door.jpg'
    - delay: 
        seconds: 1
    - service: notify.android
      data:
          title: 'Doorbell'
          message: "Someone is at the door! {{ now().strftime('%I:%M %p') }}."
          data:
            image: "/home/homeassistant/.homeassistant/cam_captures/front_door.jpg"

Hi Speakquietly,

I tried what you mentioned as per above but still not working. It keeps crashing the app. Any Ideas?

Hey Crewski,

i’m using node red. Any ideas how and what node i can use to accomplish the same as per your example.?

Thanks.
Great work by the way.

I tried moving the tag into data_template, but I’m still having the same issue, same error too…

Here’s my config:

- alias: Send me the weather testing 1
  hide_entity: true
  trigger:
    platform: time
    at: '22:02:00'
  action:
    - service: notify.android
      data_template:
        tag: 1
        message: >-
          {% if is_state("sensor.dark_sky_precip","rain") or
                is_state("sensor.dark_sky_precip","snow") or
                is_state("sensor.dark_sky_precip","sleet") %}
            It's {{states.sensor.dark_sky_precip.state | upper}}ING! {{states.sensor.dark_sky_daily_max_precip_intensity.state}} inches are expected. {{states.sensor.forecast_today.state}}
          {% else %}
            {{states.sensor.forecast_today.state}}
          {% endif %}
- alias: Send me the weather testing 2
  hide_entity: true
  trigger:
    platform: time
    at: '22:02:30'
  action:
    - service: notify.android
      data_template:
        tag: 1
        message: >-
          {% if is_state("sensor.dark_sky_precip","rain") or
                is_state("sensor.dark_sky_precip","snow") or
                is_state("sensor.dark_sky_precip","sleet") %}
            It's {{states.sensor.dark_sky_precip.state | upper}}ING! {{states.sensor.dark_sky_daily_max_precip_intensity.state}} inches are expected. {{states.sensor.forecast_today.state}}
          {% else %}
            {{states.sensor.forecast_today.state}}
          {% endif %}

And here’s the error

Invalid service data for notify.android: extra keys not allowed @ data['tag']. Got '1'

I also tried putting double quotes around the 1 but no change. I wonder if this is related to the issues everyone else is having?

Any thoughts @Crewski?

What’s the error your getting in /dev-info? Is it similar to mine (below)?

Invalid service data for notify.android: extra keys not allowed @ data['tag']. Got 1

Hmmmmm, the data vs data_template might not have been the issue. According to the HTML5 manual (and my working HTML5 config), you might need an extra key data: https://www.home-assistant.io/components/notify.html5/#tag, so:

data:
  data:
    tag:

(See the 2nd example in the linked documentation)

Good catch, that was it! The notification triggered and (I think) the next was came in and replaced it. At least, I don’t have an error in the log. Also, I used both data_template: and data: which is what I was expecting to work.

Thank you! Now to play with the other parameters. :grin:

1 Like

Hey guys, sorry I’ve been gone for a while.

@travislpriest sounds like you all got the “tag” thing figured out.

@Eddie1974 I do have some experience with Node Red (I did my own home automation with it before moving to Home Assistant) but unfortunately I have not played with NR and how it interacts with Home Assistant. That is on my to do list to play with that, but time is sparse right now. If you figure it out, report back to help others. Thanks.

@3oh6 The image needs to be a URL that you can access. I store my image into the config/www folder since it is accessible as local. See my example below:

send_image_notificaion:
  sequence:
    - service: camera.snapshot
      data:
        entity_id: camera.amcrest_camera
        filename: /config/www/cam_captures/jakes_room_{{ now ().year }}_{{ now ().month }}_{{ now ().day }}_{{ now ().hour }}_{{ now ().minute }}.jpg
    - delay: 
        seconds: 5
    - service: notify.android
      data_template:
        title:  Camera Motion
        message:  Motion detected in Jake's room
        data:
          image:  "https://yourhainstance:haport/local/cam_captures/jakes_room_{{ now ().year }}_{{ now ().month }}_{{ now ().day }}_{{ now ().hour }}_{{ now ().minute }}.jpg"
1 Like

I’m getting the following error after restarting HA with the custom component file added and the config added into my configuration.yaml file. Any idea what’s going on here?

SyntaxError: invalid syntax
Fatal error while loading config: invalid syntax (fcm-android.py, line 7)
Failed config
  General Errors: 
    - invalid syntax (fcm-android.py, line 7)
Successful config (partial)

That is part of a larger error, but seemed to be the core part of it.

This is my config just to be clear. I haven’t added it to any automations in yet.

notify:
  - name: android
    platform: fcm-android

I assume I missed something? Any help would be appreciated.