Android actionable notifications

notification
Tags: #<Tag:0x00007f1ba2f58c18>

#141

Hi, I followed all the steps, there is a “fcm_android_registrations.conf” and it has a token too but when I try to send notification nothing show up on the phone?


#142

What phone and Android version are you using?


#143

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


#144

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!


#145

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?


#146

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"} }


#147

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


#148

You have already integrated in Ariela - Home Assistant Android Client


#149

Useing this and good so far


#150

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.


#151

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.


#152

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…


#153

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


#154

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"

#155

Hi Speakquietly,

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


#156

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.


#157

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?


#158

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

#159

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)


#160

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: